#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

bool match(char x, char y){
	return (x=='?'||y=='?'||x==y);
}

int ab[MAXN], bc[MAXN], ac[MAXN];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string a,b,c; cin>>a>>b>>c;
	
	//int ans=1e9;
	int A=a.length(), B=b.length(), C=c.length();
	FOR(i,0,A-1) FOR(j,0,B-1) if(!match(a[i],b[j])) ab[i-j+50000]=1;
	FOR(i,0,A-1) FOR(j,0,C-1) if(!match(a[i],c[j])) ac[i-j+50000]=1;
	FOR(i,0,B-1) FOR(j,0,C-1) if(!match(b[i],c[j])) bc[i-j+50000]=1;
	
	int ans = 1e9;
	FOR(i,-4000,4000) FOR(j,-4000,4000) {
		int x=ab[50000+i]+ac[50000+j]+bc[-i+j+50000];
		if(x==0){
			int L = min({0,i,j});
			int R = max({A,B+i,C+j});
			ans = min(ans, R - L);
		}
	}
	cout<<ans;
}

### Prompt

Construct a CPP code solution to the problem outlined:

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;
typedef pair<ll,ll>pi;
const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

bool match(char x, char y){
	return (x=='?'||y=='?'||x==y);
}

int ab[MAXN], bc[MAXN], ac[MAXN];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string a,b,c; cin>>a>>b>>c;
	
	//int ans=1e9;
	int A=a.length(), B=b.length(), C=c.length();
	FOR(i,0,A-1) FOR(j,0,B-1) if(!match(a[i],b[j])) ab[i-j+50000]=1;
	FOR(i,0,A-1) FOR(j,0,C-1) if(!match(a[i],c[j])) ac[i-j+50000]=1;
	FOR(i,0,B-1) FOR(j,0,C-1) if(!match(b[i],c[j])) bc[i-j+50000]=1;
	
	int ans = 1e9;
	FOR(i,-4000,4000) FOR(j,-4000,4000) {
		int x=ab[50000+i]+ac[50000+j]+bc[-i+j+50000];
		if(x==0){
			int L = min({0,i,j});
			int R = max({A,B+i,C+j});
			ans = min(ans, R - L);
		}
	}
	cout<<ans;
}

```