#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	string S[3];
	rep(i, 3) cin >> S[i];
	int L[3];
	rep(i, 3) L[i] = S[i].size();

	bool dame[3][3][4020] = {};
	rep(i, 3) rep(j, 3) if (i != j) {
		rep(k, L[i]) {
			rep(x, min(L[i] - k, L[j])) {
				if (S[i][k + x] != '?' && S[j][x] != '?' && S[i][k + x] != S[j][x]) {
					dame[i][j][k] = 1;
					break;
				}
			}
		}
	}

	int P[3] = { 0,1,2 };
	int saishou = 6000;
	rep(x, 6) {
		int i = P[0];
		int j = P[1];
		int k = P[2];

		rep(p, L[i] + 1) {
			int tmp = max(L[i], L[j] + p);
			if (tmp >= saishou) break;
			if (!dame[i][j][p]) {
				rep(q, saishou - L[k] - p) {
					if (!dame[j][k][q] && !dame[i][k][p + q]) {
						saishou = max(tmp, L[k] + p + q);
						break;
					}
				}
			}
		}
		next_permutation(P, P + 3);
	}

	co(saishou);


	Would you please 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
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	string S[3];
	rep(i, 3) cin >> S[i];
	int L[3];
	rep(i, 3) L[i] = S[i].size();

	bool dame[3][3][4020] = {};
	rep(i, 3) rep(j, 3) if (i != j) {
		rep(k, L[i]) {
			rep(x, min(L[i] - k, L[j])) {
				if (S[i][k + x] != '?' && S[j][x] != '?' && S[i][k + x] != S[j][x]) {
					dame[i][j][k] = 1;
					break;
				}
			}
		}
	}

	int P[3] = { 0,1,2 };
	int saishou = 6000;
	rep(x, 6) {
		int i = P[0];
		int j = P[1];
		int k = P[2];

		rep(p, L[i] + 1) {
			int tmp = max(L[i], L[j] + p);
			if (tmp >= saishou) break;
			if (!dame[i][j][p]) {
				rep(q, saishou - L[k] - p) {
					if (!dame[j][k][q] && !dame[i][k][p + q]) {
						saishou = max(tmp, L[k] + p + q);
						break;
					}
				}
			}
		}
		next_permutation(P, P + 3);
	}

	co(saishou);


	Would you please return 0;
}
```