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

bool match(char c1, char c2){
    return ((c1 == c2) || (c1 == '?') || (c2 == '?'));
}

int main(){
    string A, B, C; cin >> A >> B >> C;
    int LA = A.length(), LB = B.length(), LC = C.length();

    vector<bool> AB(100000,true), AC(100000,true), BC(100000,true);

    rep(i, LA) rep(j, LB) if(!match(A[i], B[j])) AB[i-j+50000] = false;
    rep(i, LA) rep(j, LC) if(!match(A[i], C[j])) AC[i-j+50000] = false;
    rep(i, LB) rep(j, LC) if(!match(B[i], C[j])) BC[i-j+50000] = false;

    int ans = 1e8;
    for(int i = -4000; i<=4000; i++){
        for(int j = -4000; j<=4000; j++){
            if(AB[i+50000] && AC[j+50000] && BC[j-i+50000]){
                int L = min(0, min(i,j));
                int R = max(LA,max(i+LB, j+LC));
                ans = min(ans, R-L);            
            }
        }
    }

    cout << ans << endl;
    
    

}
### 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;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

bool match(char c1, char c2){
    return ((c1 == c2) || (c1 == '?') || (c2 == '?'));
}

int main(){
    string A, B, C; cin >> A >> B >> C;
    int LA = A.length(), LB = B.length(), LC = C.length();

    vector<bool> AB(100000,true), AC(100000,true), BC(100000,true);

    rep(i, LA) rep(j, LB) if(!match(A[i], B[j])) AB[i-j+50000] = false;
    rep(i, LA) rep(j, LC) if(!match(A[i], C[j])) AC[i-j+50000] = false;
    rep(i, LB) rep(j, LC) if(!match(B[i], C[j])) BC[i-j+50000] = false;

    int ans = 1e8;
    for(int i = -4000; i<=4000; i++){
        for(int j = -4000; j<=4000; j++){
            if(AB[i+50000] && AC[j+50000] && BC[j-i+50000]){
                int L = min(0, min(i,j));
                int R = max(LA,max(i+LB, j+LC));
                ans = min(ans, R-L);            
            }
        }
    }

    cout << ans << endl;
    
    

}
```