#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string a, b, c; cin >> a >> b >> c;
    int al = a.length();
    int bl = b.length();
    int cl = c.length();

    auto f = [](char c1, char c2) {
        return c1 != '?' && c2 != '?' && c1 != c2;
    };

    vector<bool> ab(al+bl+cl*2+1);
    vector<bool> ac(al+bl*2+cl+1);
    vector<bool> bc(al*2+bl*3+cl*3+1);
    for (int i = 0; i < al; i++) {
        for (int j = 0; j < bl; j++)
            if (f(a[i], b[j])) ab[i-j+bl+cl] = true;
        for (int k = 0; k < cl; k++)
            if (f(a[i], c[k])) ac[i-k+bl+cl] = true;
    }
    for (int j = 0; j < bl; j++) {
        for (int k = 0; k < cl; k++) {
            if (f(b[j], c[k]))
                bc[j-k+al+bl+cl*2] = true;
        }
    }

    int ans = al + bl + cl;
    for (int x = -(bl+cl); x <= al+cl; x++) {
        for (int y = -(bl+cl); y <= al+bl; y++) {
            if (ab[x+bl+cl]) continue;
            if (ac[y+bl+cl]) continue;
            if (bc[y-x+al+bl+cl*2]) continue;
            int l = min(0, min(x, y));
            int r = max(al, max(bl+x, cl+y));
            ans = min(ans, r - l);
        }
    }
    cout << ans << "\n";
}
### Prompt

In cpp, your task is to solve 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 <iostream>
#include <vector>
#include <string>
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string a, b, c; cin >> a >> b >> c;
    int al = a.length();
    int bl = b.length();
    int cl = c.length();

    auto f = [](char c1, char c2) {
        return c1 != '?' && c2 != '?' && c1 != c2;
    };

    vector<bool> ab(al+bl+cl*2+1);
    vector<bool> ac(al+bl*2+cl+1);
    vector<bool> bc(al*2+bl*3+cl*3+1);
    for (int i = 0; i < al; i++) {
        for (int j = 0; j < bl; j++)
            if (f(a[i], b[j])) ab[i-j+bl+cl] = true;
        for (int k = 0; k < cl; k++)
            if (f(a[i], c[k])) ac[i-k+bl+cl] = true;
    }
    for (int j = 0; j < bl; j++) {
        for (int k = 0; k < cl; k++) {
            if (f(b[j], c[k]))
                bc[j-k+al+bl+cl*2] = true;
        }
    }

    int ans = al + bl + cl;
    for (int x = -(bl+cl); x <= al+cl; x++) {
        for (int y = -(bl+cl); y <= al+bl; y++) {
            if (ab[x+bl+cl]) continue;
            if (ac[y+bl+cl]) continue;
            if (bc[y-x+al+bl+cl*2]) continue;
            int l = min(0, min(x, y));
            int r = max(al, max(bl+x, cl+y));
            ans = min(ans, r - l);
        }
    }
    cout << ans << "\n";
}
```