Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

E. Test

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputSometimes it is hard to prepare tests for programming problems. Now Bob is preparing tests to new problem about strings — input data to his problem is one string. Bob has 3 wrong solutions to this problem. The first gives the wrong answer if the input data contains the substring *s*_{1}, the second enters an infinite loop if the input data contains the substring *s*_{2}, and the third requires too much memory if the input data contains the substring *s*_{3}. Bob wants these solutions to fail single test. What is the minimal length of test, which couldn't be passed by all three Bob's solutions?

Input

There are exactly 3 lines in the input data. The *i*-th line contains string *s*_{i}. All the strings are non-empty, consists of lowercase Latin letters, the length of each string doesn't exceed 10^{5}.

Output

Output one number — what is minimal length of the string, containing *s*_{1}, *s*_{2} and *s*_{3} as substrings.

Examples

Input

ab

bc

cd

Output

4

Input

abacaba

abaaba

x

Output

11

Codeforces (c) Copyright 2010-2017 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Apr/29/2017 20:27:17 (c3).

Desktop version, switch to mobile version.
User lists

Name |
---|