#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  vector<string> s(3);
  for (int i = 0; i < 3; i++) cin >> s[i];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 4444; j++) s[i].push_back('?');
  }
  sort(s.begin(), s.end());
  auto match = [] (const char& a, const char& b) {
    return a == b || a == '?' || b == '?';
  };
  int ans = 1 << 30;
  do {
    int x = (int) s[0].size() - 4444, y = (int) s[1].size() - 4444, z = (int) s[2].size() - 4444;
    bitset<6666> ab, ac, bc;
    ab.set();
    ac.set();
    bc.set();
    for (int st = 0; st <= 2222; st++) {
      for (int i = 0; i < y; i++) {
        if (!match(s[0][st + i], s[1][i])) ab[st] = 0;
      }
      for (int i = 0; i < z; i++) {
        if (!match(s[0][st + i], s[2][i])) ac[st] = 0;
        if (!match(s[1][st + i], s[2][i])) bc[st] = 0;
      }
    }
    for (int i = 0; i <= 2020; i++) for (int j = i; j <= 2020 + i; j++) {
      if (ab[i] && ac[j] && bc[j - i]) {
        ans = min(ans, max({x, i + y, j + z}));
      }
    }
  } while (next_permutation(s.begin(), s.end()));
  cout << ans << endl;
  return 0;
}
### Prompt

Your task is to create 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
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  vector<string> s(3);
  for (int i = 0; i < 3; i++) cin >> s[i];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 4444; j++) s[i].push_back('?');
  }
  sort(s.begin(), s.end());
  auto match = [] (const char& a, const char& b) {
    return a == b || a == '?' || b == '?';
  };
  int ans = 1 << 30;
  do {
    int x = (int) s[0].size() - 4444, y = (int) s[1].size() - 4444, z = (int) s[2].size() - 4444;
    bitset<6666> ab, ac, bc;
    ab.set();
    ac.set();
    bc.set();
    for (int st = 0; st <= 2222; st++) {
      for (int i = 0; i < y; i++) {
        if (!match(s[0][st + i], s[1][i])) ab[st] = 0;
      }
      for (int i = 0; i < z; i++) {
        if (!match(s[0][st + i], s[2][i])) ac[st] = 0;
        if (!match(s[1][st + i], s[2][i])) bc[st] = 0;
      }
    }
    for (int i = 0; i <= 2020; i++) for (int j = i; j <= 2020 + i; j++) {
      if (ab[i] && ac[j] && bc[j - i]) {
        ans = min(ans, max({x, i + y, j + z}));
      }
    }
  } while (next_permutation(s.begin(), s.end()));
  cout << ans << endl;
  return 0;
}
```