#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unordered_set<ll> uset;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=0;i<=n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#pragma gcc optimize("O3")
#pragma gcc optimize("unroll-loops")
#pragma gcc target("avx2,see4")
#define base 2100
bool ok[3][base*2];
void calc(ll id,string a,string b){
	for(int i=-base;i<base;i++){
		bool same=1;
		for(int j=0;j<a.size();j++){
			int k=j-i;
			if(0<=k&&k<b.size()){
				if(a[j]!='?'&&b[k]!='?'&&a[j]!=b[k]){
					same=0;
					break;
				}
			}
		}
		ok[id][i+base]=same;
	}
}
ll solve(string a,string b,string c){
	calc(0,a,b);
	calc(1,a,c);
	calc(2,b,c);
	int ans=1e9;
	for(int i=-base;i<base;i++)for(int j=-base;j<base;j++){
		if(ok[0][i+base]&&ok[1][j+base]){
			int d=j-i;
			if(-base<=d&&d<base&&ok[2][d+base]==0)continue;
			 int l=0; chmin(l,min(i,j));
			 int r=a.size(); chmax(r,max(i+(int)b.size(),j+(int)c.size()));
			 chmin(ans,r-l);
		}
	}
	return ans;
}
int main(){
	string a,b,c;
	cin>>a>>b>>c;
	ll ans=solve(a,b,c);
	chmin(ans,solve(b,a,c));
	chmin(ans,solve(c,a,b));
	cout<<ans<<endl;
}

### Prompt

Please provide a cpp coded solution to the problem described below:

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<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unordered_set<ll> uset;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=0;i<=n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#pragma gcc optimize("O3")
#pragma gcc optimize("unroll-loops")
#pragma gcc target("avx2,see4")
#define base 2100
bool ok[3][base*2];
void calc(ll id,string a,string b){
	for(int i=-base;i<base;i++){
		bool same=1;
		for(int j=0;j<a.size();j++){
			int k=j-i;
			if(0<=k&&k<b.size()){
				if(a[j]!='?'&&b[k]!='?'&&a[j]!=b[k]){
					same=0;
					break;
				}
			}
		}
		ok[id][i+base]=same;
	}
}
ll solve(string a,string b,string c){
	calc(0,a,b);
	calc(1,a,c);
	calc(2,b,c);
	int ans=1e9;
	for(int i=-base;i<base;i++)for(int j=-base;j<base;j++){
		if(ok[0][i+base]&&ok[1][j+base]){
			int d=j-i;
			if(-base<=d&&d<base&&ok[2][d+base]==0)continue;
			 int l=0; chmin(l,min(i,j));
			 int r=a.size(); chmax(r,max(i+(int)b.size(),j+(int)c.size()));
			 chmin(ans,r-l);
		}
	}
	return ans;
}
int main(){
	string a,b,c;
	cin>>a>>b>>c;
	ll ans=solve(a,b,c);
	chmin(ans,solve(b,a,c));
	chmin(ans,solve(c,a,b));
	cout<<ans<<endl;
}

```