#include <bits/stdc++.h>
using namespace std;

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  int as = a.size(), bs = b.size(), cs = c.size();
  vector<bool> ab(8001), ac(8001), bc(8001);
  for (int i = -4000; i <= 4000; i++) {
    for (int j = 0; j < 2000; j++) {
      if (j - i < 0) continue;
      if (j < as && j - i < bs
          && a.at(j) != '?' && b.at(j - i) != '?' && a.at(j) != b.at(j - i)) {
        ab.at(i + 4000) = true;
      }
      if (j < as && j - i < cs
          && a.at(j) != '?' && c.at(j - i) != '?' && a.at(j) != c.at(j - i)) {
        ac.at(i + 4000) = true;
      }
      if (j < bs && j - i < cs
          && b.at(j) != '?' && c.at(j - i) != '?' && b.at(j) != c.at(j - i)) {
        bc.at(i + 4000) = true;
      }
    }
  }
  int ans = 6000;
  for (int i = -4000; i <= 4000; i++) {
    for (int j = -4000; j <= 4000; j++) {
      if (!ab.at(i + 4000) && !ac.at(j + 4000)
          && (j - i + 4000 < 0 || 8000 < j - i + 4000 || !bc.at(j - i + 4000))) {
        int l = min({0, i, j}), r = max({as, bs + i, cs + j});
        ans = min(ans, r - l);
      }
    }
  }
  cout << ans << endl;
}

### 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 <bits/stdc++.h>
using namespace std;

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  int as = a.size(), bs = b.size(), cs = c.size();
  vector<bool> ab(8001), ac(8001), bc(8001);
  for (int i = -4000; i <= 4000; i++) {
    for (int j = 0; j < 2000; j++) {
      if (j - i < 0) continue;
      if (j < as && j - i < bs
          && a.at(j) != '?' && b.at(j - i) != '?' && a.at(j) != b.at(j - i)) {
        ab.at(i + 4000) = true;
      }
      if (j < as && j - i < cs
          && a.at(j) != '?' && c.at(j - i) != '?' && a.at(j) != c.at(j - i)) {
        ac.at(i + 4000) = true;
      }
      if (j < bs && j - i < cs
          && b.at(j) != '?' && c.at(j - i) != '?' && b.at(j) != c.at(j - i)) {
        bc.at(i + 4000) = true;
      }
    }
  }
  int ans = 6000;
  for (int i = -4000; i <= 4000; i++) {
    for (int j = -4000; j <= 4000; j++) {
      if (!ab.at(i + 4000) && !ac.at(j + 4000)
          && (j - i + 4000 < 0 || 8000 < j - i + 4000 || !bc.at(j - i + 4000))) {
        int l = min({0, i, j}), r = max({as, bs + i, cs + j});
        ans = min(ans, r - l);
      }
    }
  }
  cout << ans << endl;
}

```