/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
bool same(char c1,char c2){
	return (c1=='?'||c2=='?'||c1==c2);
}
string a,b,c;
int A,B,C;
const int M=20000;
bool ab[1000000],ac[1000000],bc[1000000];
int main(){
	fastio;
	cin>>a>>b>>c;
	A=a.length();
	B=b.length();
	C=c.length();
	rep(i,A) rep(j,B) if(!same(a[i],b[j])) ab[i-j+M]=1;
	rep(i,A) rep(j,C) if(!same(a[i],c[j])) ac[i-j+M]=1;
	rep(i,B) rep(j,C) if(!same(b[i],c[j])) bc[i-j+M]=1;
	int res=INF; 
	rb(i,-5000,5000){
		rb(j,-5000,5000){
			if(!ab[M+i]&&!ac[M+j]&&!bc[j-i+M]){
				int L = min(0, min(i, j));
 				int R = max(A, max(B + i, C + j));
 				res = min(res, R - L);
			} 
		}
		

	}
	cout<<res<<endl;
	return 0;
}

### Prompt

Generate 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
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
bool same(char c1,char c2){
	return (c1=='?'||c2=='?'||c1==c2);
}
string a,b,c;
int A,B,C;
const int M=20000;
bool ab[1000000],ac[1000000],bc[1000000];
int main(){
	fastio;
	cin>>a>>b>>c;
	A=a.length();
	B=b.length();
	C=c.length();
	rep(i,A) rep(j,B) if(!same(a[i],b[j])) ab[i-j+M]=1;
	rep(i,A) rep(j,C) if(!same(a[i],c[j])) ac[i-j+M]=1;
	rep(i,B) rep(j,C) if(!same(b[i],c[j])) bc[i-j+M]=1;
	int res=INF; 
	rb(i,-5000,5000){
		rb(j,-5000,5000){
			if(!ab[M+i]&&!ac[M+j]&&!bc[j-i+M]){
				int L = min(0, min(i, j));
 				int R = max(A, max(B + i, C + j));
 				res = min(res, R - L);
			} 
		}
		

	}
	cout<<res<<endl;
	return 0;
}

```