#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln =  '\n';

const int mx=100010;
const ll mod=1e9+7;

bool same(char x, char y){
  return (x==y || x=='?' || y=='?');
}

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  int asz = a.size();
  int bsz = b.size();
  int csz = c.size();
  
  vector<bool> ab(mx,true),bc(mx,true),ac(mx,true);
  rep(i,asz)rep(j,bsz)if(!same(a[i],b[j])){
    ab[50000+i-j] = false;
  }
  rep(i,asz)rep(j,csz)if(!same(a[i],c[j])){
    ac[50000+i-j] = false;
  }
  rep(i,bsz)rep(j,csz)if(!same(b[i],c[j])){
    bc[50000+i-j] = false;
  }
  int ans = inf;
  for(int i=-4000; i<4001; i++)for(int j=-4000; j<4001; j++){
    if(ab[50000+i] && ac[50000+j] && bc[50000+j-i]){
      int tmp = max(asz,max(bsz+i,csz+j)) - min(0,min(i,j));
      ans = min(ans, tmp);
    }
  }
  cout << ans << ln;
  return 0;
}
### Prompt

Please create a solution in CPP 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>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln =  '\n';

const int mx=100010;
const ll mod=1e9+7;

bool same(char x, char y){
  return (x==y || x=='?' || y=='?');
}

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  int asz = a.size();
  int bsz = b.size();
  int csz = c.size();
  
  vector<bool> ab(mx,true),bc(mx,true),ac(mx,true);
  rep(i,asz)rep(j,bsz)if(!same(a[i],b[j])){
    ab[50000+i-j] = false;
  }
  rep(i,asz)rep(j,csz)if(!same(a[i],c[j])){
    ac[50000+i-j] = false;
  }
  rep(i,bsz)rep(j,csz)if(!same(b[i],c[j])){
    bc[50000+i-j] = false;
  }
  int ans = inf;
  for(int i=-4000; i<4001; i++)for(int j=-4000; j<4001; j++){
    if(ab[50000+i] && ac[50000+j] && bc[50000+j-i]){
      int tmp = max(asz,max(bsz+i,csz+j)) - min(0,min(i,j));
      ans = min(ans, tmp);
    }
  }
  cout << ans << ln;
  return 0;
}
```