#include<map>
#include<queue>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<vector>
#include<cstring>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
const int N=1e5+10,M=2e3+10;

char a[M],b[M],c[M];
int A,B,C,ans;
bool ab[N],ac[N],bc[N];
//ab[i]表示以a[i..(A-1)]是否与b[0,B)有冲突 

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

int main() {
	scanf("%s %s %s",a,b,c);
	A=strlen(a);
	B=strlen(b);
	C=strlen(c);
	for(int i=0;i<A;i++) for(int j=0;j<B;j++) if(!pd(a[i],b[j])) ab[i-j+M*4]=1;
	for(int i=0;i<A;i++) for(int j=0;j<C;j++) if(!pd(a[i],c[j])) ac[i-j+M*4]=1;
	for(int i=0;i<B;i++) for(int j=0;j<C;j++) if(!pd(b[i],c[j])) bc[i-j+M*4]=1;
	
	ans=A+B+C;
	for(int i=-2*M;i<=2*M;i++) for(int j=-2*M;j<=2*M;j++) if(!ab[i+M*4]&&!ac[j+M*4]&&!bc[j-i+M*4]) {
		int L=min(0,min(i,j)),R=max(A,max(i+B,j+C));
		ans=min(ans,R-L);
	}
	printf("%d\n",ans); 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
#include<map>
#include<queue>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<vector>
#include<cstring>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
const int N=1e5+10,M=2e3+10;

char a[M],b[M],c[M];
int A,B,C,ans;
bool ab[N],ac[N],bc[N];
//ab[i]表示以a[i..(A-1)]是否与b[0,B)有冲突 

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

int main() {
	scanf("%s %s %s",a,b,c);
	A=strlen(a);
	B=strlen(b);
	C=strlen(c);
	for(int i=0;i<A;i++) for(int j=0;j<B;j++) if(!pd(a[i],b[j])) ab[i-j+M*4]=1;
	for(int i=0;i<A;i++) for(int j=0;j<C;j++) if(!pd(a[i],c[j])) ac[i-j+M*4]=1;
	for(int i=0;i<B;i++) for(int j=0;j<C;j++) if(!pd(b[i],c[j])) bc[i-j+M*4]=1;
	
	ans=A+B+C;
	for(int i=-2*M;i<=2*M;i++) for(int j=-2*M;j<=2*M;j++) if(!ab[i+M*4]&&!ac[j+M*4]&&!bc[j-i+M*4]) {
		int L=min(0,min(i,j)),R=max(A,max(i+B,j+C));
		ans=min(ans,R-L);
	}
	printf("%d\n",ans); return 0;
}

```