Problem Description
Coco the Monkey is still very obsessed with strings.
Sometimes, Coco finds some strings scary, as they frighten Coco the Monkey. Scary strings contain substrings that Coco the Monkey hate.
Coco the Monkey considers a string to be scary, if it contains strings A, B and C as substrings.
Coco the Monkey is now busy hiding on a coconut tree after having a nightmare due to scary strings. Damian wants to frighten Coco the Monkey even more, so he wants to construct a scary string to show Coco the Monkey. Constructing a string is a tiring task, so Damian wants to construct a string that is as short as possible.
Help Damian find the length of the shortest scary string that he can construct.
Input
The first line of input will contain string A, the second line will contain string B and the third line will contain string C. All three strings contain only lowercase english alphabets and do not contain any other characters.
Output
Output a single string, the length of the shortest scary string that Damian can construct.
Limits
Subtask 1 (38%): 1 ≤ | A |, | B |, | C | ≤ 500.
Subtask 2 (62%): 1 ≤ | A |, | B |, | C | ≤ 100 000.
Subtask 3 (0%): Sample Testcases
Sample Testcase 1
Input
rar
the
cat
Output
8