#define _CRT_SECURE_NO_WARNINGS
#include <cassert>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
ll MOD = 1000000007LL;


bool eq(char a, char b) {
	return a=='?' || b=='?' || a==b;
}

const int SZ = 2033;
char A[SZ], B[SZ], C[SZ];
int LA, LB, LC;
bool AB[SZ*8], BC[SZ*8], AC[SZ*8];

void process(char*S, char*T, bool *shift) {
	for (int i=0; S[i]; i++) for (int j=0; T[j]; j++)
		if (!eq(S[i], T[j]))
			shift[4*SZ + i-j] = true;
}


int main() {
	cin >> A >> B >> C;
	LA = strlen(A);
	LB = strlen(B);
	LC = strlen(C);

	process(A, B, AB);
	process(B, C, BC);
	process(A, C, AC);

	int ans = 1e9;
	for (int ab=-4000; ab<=4000; ab++) for (int bc=-4000; bc<=4000; bc++) {
		if (!AB[4*SZ+ab] && !BC[4*SZ+bc] && !AC[4*SZ+ab+bc]) {
			int L = min(0, min(ab, ab+bc));
			int R = max(LA, max(ab+LB, ab+bc+LC));
			ans = min(ans, R - L);
		}
	}

	cout << ans << endl;


	return 0;
}
### Prompt

Please formulate a Cpp solution to the following problem:

Snuke has a string s. From this string, Anuke, Bnuke, and Cnuke obtained strings a, b, and c, respectively, as follows:

* Choose a non-empty (contiguous) substring of s (possibly s itself). Then, replace some characters (possibly all or none) in it with `?`s.



For example, if s is `mississippi`, we can choose the substring `ssissip` and replace its 1-st and 3-rd characters with `?` to obtain `?s?ssip`.

You are given the strings a, b, and c. Find the minimum possible length of s.

Constraints

* 1 \leq |a|, |b|, |c| \leq 2000
* a, b, and c consists of lowercase English letters and `?`s.

Input

Input is given from Standard Input in the following format:


a
b
c


Output

Print the minimum possible length of s.

Examples

Input

a?c
der
cod


Output

7


Input

atcoder
atcoder
???????


Output

7

### Response

```cpp
#define _CRT_SECURE_NO_WARNINGS
#include <cassert>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
ll MOD = 1000000007LL;


bool eq(char a, char b) {
	return a=='?' || b=='?' || a==b;
}

const int SZ = 2033;
char A[SZ], B[SZ], C[SZ];
int LA, LB, LC;
bool AB[SZ*8], BC[SZ*8], AC[SZ*8];

void process(char*S, char*T, bool *shift) {
	for (int i=0; S[i]; i++) for (int j=0; T[j]; j++)
		if (!eq(S[i], T[j]))
			shift[4*SZ + i-j] = true;
}


int main() {
	cin >> A >> B >> C;
	LA = strlen(A);
	LB = strlen(B);
	LC = strlen(C);

	process(A, B, AB);
	process(B, C, BC);
	process(A, C, AC);

	int ans = 1e9;
	for (int ab=-4000; ab<=4000; ab++) for (int bc=-4000; bc<=4000; bc++) {
		if (!AB[4*SZ+ab] && !BC[4*SZ+bc] && !AC[4*SZ+ab+bc]) {
			int L = min(0, min(ab, ab+bc));
			int R = max(LA, max(ab+LB, ab+bc+LC));
			ans = min(ans, R - L);
		}
	}

	cout << ans << endl;


	return 0;
}
```