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

void chmin(int &a, int b) { if (b < a) a = b; }
bool check(string &x, string &y, int n){
    int nx = x.length(), ny = y.length();
    bool res = 1;
    for(int i = max(n,4000); i < min(n+nx,4000+ny); i++) if(x[i-n]!='?' && y[i-4000]!='?' && x[i-n]!=y[i-4000]) res = 0;
    return res;
}

int main(){
    string a, b, c; cin >> a >> b >> c;
    int na = a.length(), nb = b.length(), nc = c.length();
    vector<bool> ab(8000), ac(8000), bc(8000);
    rep(i,8000){ ab[i] = check(a,b,i); ac[i] = check(a,c,i); bc[i] = check(b,c,i); }
    int ans = 6000;
    rep(i,8000) rep(j,8000) if((abs(i-j)>=2000 || ab[4000+i-j]) && ac[i] && bc[j]) chmin(ans,max({i+na,j+nb,4000+nc})-min({i,j,4000}));
    cout << ans << endl;
}
### Prompt

Create a solution in cpp for 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>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void chmin(int &a, int b) { if (b < a) a = b; }
bool check(string &x, string &y, int n){
    int nx = x.length(), ny = y.length();
    bool res = 1;
    for(int i = max(n,4000); i < min(n+nx,4000+ny); i++) if(x[i-n]!='?' && y[i-4000]!='?' && x[i-n]!=y[i-4000]) res = 0;
    return res;
}

int main(){
    string a, b, c; cin >> a >> b >> c;
    int na = a.length(), nb = b.length(), nc = c.length();
    vector<bool> ab(8000), ac(8000), bc(8000);
    rep(i,8000){ ab[i] = check(a,b,i); ac[i] = check(a,c,i); bc[i] = check(b,c,i); }
    int ans = 6000;
    rep(i,8000) rep(j,8000) if((abs(i-j)>=2000 || ab[4000+i-j]) && ac[i] && bc[j]) chmin(ans,max({i+na,j+nb,4000+nc})-min({i,j,4000}));
    cout << ans << endl;
}
```