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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

bool match(char a, char b) {
    return a == b || a == '?' || b == '?';
}

// mismatch
bool ab[8010], ac[8010], bc[8010];

int main() {
    string a, b, c;
    cin >> a >> b >> c;

    int na = a.size(), nb = b.size(), nc = c.size();
    int w = max({na, nb, nc}) * 2;

    rep(i,na) rep(j,nb) if ( ! match(a[i], b[j])) ab[i-j+w] = true;
    rep(i,na) rep(j,nc) if ( ! match(a[i], c[j])) ac[i-j+w] = true;
    rep(i,nb) rep(j,nc) if ( ! match(b[i], c[j])) bc[i-j+w] = true;

    int mn = INT_MAX;
    for (int i=-w; i<=w; ++i) {
        for (int j=-w; j<=w; ++j) {
            if (ab[i+w] || ac[j+w] || bc[j-i+w]) continue;
            int l = min({0, i, j});
            int r = max({na, i+nb, j+nc});
            mn = min(mn, r-l);
        }
    }
    cout << mn << endl;

    return 0;
}
### Prompt

Your challenge is to write a CPP solution 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>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

bool match(char a, char b) {
    return a == b || a == '?' || b == '?';
}

// mismatch
bool ab[8010], ac[8010], bc[8010];

int main() {
    string a, b, c;
    cin >> a >> b >> c;

    int na = a.size(), nb = b.size(), nc = c.size();
    int w = max({na, nb, nc}) * 2;

    rep(i,na) rep(j,nb) if ( ! match(a[i], b[j])) ab[i-j+w] = true;
    rep(i,na) rep(j,nc) if ( ! match(a[i], c[j])) ac[i-j+w] = true;
    rep(i,nb) rep(j,nc) if ( ! match(b[i], c[j])) bc[i-j+w] = true;

    int mn = INT_MAX;
    for (int i=-w; i<=w; ++i) {
        for (int j=-w; j<=w; ++j) {
            if (ab[i+w] || ac[j+w] || bc[j-i+w]) continue;
            int l = min({0, i, j});
            int r = max({na, i+nb, j+nc});
            mn = min(mn, r-l);
        }
    }
    cout << mn << endl;

    return 0;
}
```