#include<bits/stdc++.h>
#define rgi register int
#define ll long long
using namespace std;
const int maxn=6666;
std::string a,b,c; 
bool ab[maxn<<1],ac[maxn<<1],bc[maxn<<1];
int ans=maxn<<2;
inline bool cmp(char c1,char c2) {return c1==c2||c1=='?'||c2=='?';}
signed main()
{
	std::cin>>a>>b>>c; int lena=a.length(),lenb=b.length(),lenc=c.length();
	for(rgi i=0;i<lena;++i) for(rgi j=0;j<lenb;++j) if(!cmp(a[i],b[j])) ab[i-j+maxn]=1;
	for(rgi i=0;i<lena;++i) for(rgi j=0;j<lenc;++j) if(!cmp(a[i],c[j])) ac[i-j+maxn]=1;
	for(rgi i=0;i<lenb;++i) for(rgi j=0;j<lenc;++j) if(!cmp(b[i],c[j])) bc[i-j+maxn]=1;
	for(rgi i=-4001;i<=4001;++i) for(rgi j=-4001;j<=4001;++j)
		if(!ab[i+maxn]&&!ac[j+maxn]&&!bc[j-i+maxn])
			ans=std::min(ans,std::max(lena,std::max(i+lenb,j+lenc))-std::min(0,std::min(i,j)));
	std::cout<<ans;
	return 0;
}
// ----------------------------
// by imzzy
### Prompt

Your task is to create 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>
#define rgi register int
#define ll long long
using namespace std;
const int maxn=6666;
std::string a,b,c; 
bool ab[maxn<<1],ac[maxn<<1],bc[maxn<<1];
int ans=maxn<<2;
inline bool cmp(char c1,char c2) {return c1==c2||c1=='?'||c2=='?';}
signed main()
{
	std::cin>>a>>b>>c; int lena=a.length(),lenb=b.length(),lenc=c.length();
	for(rgi i=0;i<lena;++i) for(rgi j=0;j<lenb;++j) if(!cmp(a[i],b[j])) ab[i-j+maxn]=1;
	for(rgi i=0;i<lena;++i) for(rgi j=0;j<lenc;++j) if(!cmp(a[i],c[j])) ac[i-j+maxn]=1;
	for(rgi i=0;i<lenb;++i) for(rgi j=0;j<lenc;++j) if(!cmp(b[i],c[j])) bc[i-j+maxn]=1;
	for(rgi i=-4001;i<=4001;++i) for(rgi j=-4001;j<=4001;++j)
		if(!ab[i+maxn]&&!ac[j+maxn]&&!bc[j-i+maxn])
			ans=std::min(ans,std::max(lena,std::max(i+lenb,j+lenc))-std::min(0,std::min(i,j)));
	std::cout<<ans;
	return 0;
}
// ----------------------------
// by imzzy
```