#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
ab?d
c??f
def?h
*/

int ans=1e9;
string a,b,c;
bool ab[20010],ac[20010],bc[20010];

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

int main(void){
	cin>>a>>b>>c;
	int am=a.size(),bm=b.size(),cm=c.size();  // b.size()みたいなのは符号なし整数型で、intとの演算で負になったらオーバーフローするからWAになる。

	rep(i,am)rep(j,bm)if(!match(a[i],b[j]))ab[i-j+10000]=true;
	rep(i,am)rep(j,cm)if(!match(a[i],c[j]))ac[i-j+10000]=true;
	rep(i,bm)rep(j,cm)if(!match(b[i],c[j]))bc[i-j+10000]=true;
	
	reg(i,-4000,4000){  // b
		reg(j,-4000,4000){  // c
			bool ok=true;
			if(ab[i+10000])ok=false;
			if(ac[j+10000])ok=false;
			if(bc[j-i+10000])ok=false;
			if(ok)ans = min(ans, max({am, bm+i, cm+j})-min({0,i,j}));
		}
	}
	cout<<ans<<endl;
	return 0;
}
### Prompt

Your challenge is to write 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
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
ab?d
c??f
def?h
*/

int ans=1e9;
string a,b,c;
bool ab[20010],ac[20010],bc[20010];

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

int main(void){
	cin>>a>>b>>c;
	int am=a.size(),bm=b.size(),cm=c.size();  // b.size()みたいなのは符号なし整数型で、intとの演算で負になったらオーバーフローするからWAになる。

	rep(i,am)rep(j,bm)if(!match(a[i],b[j]))ab[i-j+10000]=true;
	rep(i,am)rep(j,cm)if(!match(a[i],c[j]))ac[i-j+10000]=true;
	rep(i,bm)rep(j,cm)if(!match(b[i],c[j]))bc[i-j+10000]=true;
	
	reg(i,-4000,4000){  // b
		reg(j,-4000,4000){  // c
			bool ok=true;
			if(ab[i+10000])ok=false;
			if(ac[j+10000])ok=false;
			if(bc[j-i+10000])ok=false;
			if(ok)ans = min(ans, max({am, bm+i, cm+j})-min({0,i,j}));
		}
	}
	cout<<ans<<endl;
	return 0;
}
```