#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b, c;
  cin >> a >> b >> c;
  int s = 0;
  int t = 0;
  int u = 0;
  int v = 0;
  int w = 0;
  int x = 0;
  for (int i = 0; i < max(c.size(), max(a.size(), b.size())); i++) {
    if (a.at(a.size() - 1 - i) == b.at(i) || a.at(a.size() - 1 - i) == '?' ||
        b.at(i) == '?') {
      s++;
    }
    if (b.at(b.size() - 1 - i) == c.at(i) || b.at(b.size() - 1 - i) == '?' ||
        c.at(i) == '?') {
      t++;
    }
    if (c.at(c.size() - 1 - i) == a.at(i) || c.at(c.size() - 1 - i) == '?' ||
        a.at(i) == '?') {
      u++;
    }
    if (a.at(a.size() - 1 - i) == c.at(i) || a.at(a.size() - 1 - i) == '?' ||
        c.at(i) == '?') {
      v++;
    }
    if (b.at(b.size() - 1 - i) == a.at(i) || b.at(b.size() - 1 - i) == '?' ||
        a.at(i) == '?') {
      w++;
    }
    if (c.at(c.size() - 1 - i) == b.at(i) || c.at(c.size() - 1 - i) == '?' ||
        b.at(i) == '?') {
      x++;
    }
    cout << a.size() + b.size() + c.size() -
                max(s + t,
                    max(v + x, max(w + v, max(t + u, max(u + s, x + w)))));
  }
}
