#include<bits/stdc++.h>
using namespace std;
int ab[50000],ac[50000],bc[50000];
bool check(char  i,char j){
	if(i=='?'||j=='?'||i==j) return 1;
	return 0;
}
int main(){
	 string a,b,c;
	 cin>>a>>b>>c;
	 int la=a.size(),lb=b.size(),lc=c.size();
	 for(int i=0;i<la;i++){
	 	for(int j=0;j<lb;j++){
		 if(!check(a[i],b[j]))ab[i-j+10000]=1;
	  }
	  for(int j=0;j<lc;j++){
	  	if(!check(a[i],c[j])) ac[i-j+10000]=1;
	  }
	}
	for(int i=0;i<lb;i++){
		for(int j=0;j<lc;j++){
			if(!check(b[i],c[j])) bc[i-j+10000]=1;
		}
	}
	int ans=1e9;
	for(int i=-4000;i<=4000;i++){
		for(int j=-4000;j<=4000;j++){
			if(!ab[10000+i]&&!ac[10000+j]&&!bc[j-i+10000]){
			int l=min(0,min(i,j));
			int r=max(la,max(lb+i,lc+j));
			ans=min(r-l,ans);
		}
	}
 }
	cout<<ans<<'\n';
}

### Prompt

Please create a solution in CPP 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;
int ab[50000],ac[50000],bc[50000];
bool check(char  i,char j){
	if(i=='?'||j=='?'||i==j) return 1;
	return 0;
}
int main(){
	 string a,b,c;
	 cin>>a>>b>>c;
	 int la=a.size(),lb=b.size(),lc=c.size();
	 for(int i=0;i<la;i++){
	 	for(int j=0;j<lb;j++){
		 if(!check(a[i],b[j]))ab[i-j+10000]=1;
	  }
	  for(int j=0;j<lc;j++){
	  	if(!check(a[i],c[j])) ac[i-j+10000]=1;
	  }
	}
	for(int i=0;i<lb;i++){
		for(int j=0;j<lc;j++){
			if(!check(b[i],c[j])) bc[i-j+10000]=1;
		}
	}
	int ans=1e9;
	for(int i=-4000;i<=4000;i++){
		for(int j=-4000;j<=4000;j++){
			if(!ab[10000+i]&&!ac[10000+j]&&!bc[j-i+10000]){
			int l=min(0,min(i,j));
			int r=max(la,max(lb+i,lc+j));
			ans=min(r-l,ans);
		}
	}
 }
	cout<<ans<<'\n';
}

```