#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 10000;

int main()
{
string v[3];
cin >> v[0] >> v[1] >> v[2] ;
sort(v,v+3);
do{
bool a[5000]={};
bool b[5000]={};
bool c[5000]={};
ll aa=v[0].size();
ll bb=v[1].size();
ll cc=v[2].size();
rep(i,aa)rep(j,bb)if(i+j<aa&&v[0][i+j]!='?'&&v[1][j]!='?'&&v[0][i+j]!=v[1][j]){a[i]=1;}
rep(i,aa)rep(j,cc)if(i+j<aa&&v[0][i+j]!='?'&&v[2][j]!='?'&&v[0][i+j]!=v[2][j]){b[i]=1;}
rep(i,bb)rep(j,cc)if(i+j<bb&&v[1][i+j]!='?'&&v[2][j]!='?'&&v[1][i+j]!=v[2][j]){c[i]=1;}

rep(i,2001)rep(j,2001){
  ll f[3]={aa,bb+i,cc+i+j};
  sort(f,f+3);
  if(!a[i]&&!b[i+j]&&!c[j])ans=min(ans,f[2]);
}
}while(next_permutation(v,v+3));
cout << ans << endl;
return 0;
}
### 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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 10000;

int main()
{
string v[3];
cin >> v[0] >> v[1] >> v[2] ;
sort(v,v+3);
do{
bool a[5000]={};
bool b[5000]={};
bool c[5000]={};
ll aa=v[0].size();
ll bb=v[1].size();
ll cc=v[2].size();
rep(i,aa)rep(j,bb)if(i+j<aa&&v[0][i+j]!='?'&&v[1][j]!='?'&&v[0][i+j]!=v[1][j]){a[i]=1;}
rep(i,aa)rep(j,cc)if(i+j<aa&&v[0][i+j]!='?'&&v[2][j]!='?'&&v[0][i+j]!=v[2][j]){b[i]=1;}
rep(i,bb)rep(j,cc)if(i+j<bb&&v[1][i+j]!='?'&&v[2][j]!='?'&&v[1][i+j]!=v[2][j]){c[i]=1;}

rep(i,2001)rep(j,2001){
  ll f[3]={aa,bb+i,cc+i+j};
  sort(f,f+3);
  if(!a[i]&&!b[i+j]&&!c[j])ans=min(ans,f[2]);
}
}while(next_permutation(v,v+3));
cout << ans << endl;
return 0;
}
```