programming-contest

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

Input
There are exactly 3 lines in the input data. The i-th line contains string si. All the strings are non-empty, consists of lowercase Latin letters, the length of each string doesn't exceed 105.

Output
Output one number — what is minimal length of the string, containing s1, s2 and s3 as substrings.

SAMPLE INPUT
ab
bc
cd

SAMPLE OUTPUT
4

Source: hackerearth | Difficulty: EASY


Solutions: