#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
char a[N],b[N],c[N];
int ab[N],bc[N],ac[N];
int ch(char x,char y){
  if(x==y || x=='?' || y=='?')return 1;
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin>>a+1>>b+1>>c+1;
  int A=strlen(a+1);
  int B=strlen(b+1);
  int C=strlen(c+1);
  for(int i=1;i<=A;i++){
    for(int j=1;j<=B;j++){
      if(!ch(a[i],b[j]))ab[i-j+20000]=1;
    }
  }
  for(int i=1;i<=A;i++){
    for(int j=1;j<=C;j++){
      if(!ch(a[i],c[j]))ac[i-j+20000]=1;
    }
  }
  for(int i=1;i<=B;i++){
    for(int j=1;j<=C;j++){
      if(!ch(b[i],c[j]))bc[i-j+20000]=1;
    }
  }
  int ans=A+B+C;
  for(int i=-4000;i<=4000;i++){
    for(int j=-4000;j<=4000;j++){
      if(!ab[i+20000] && !bc[j+20000] && !ac[i+j+20000]){
//        cout<<i<<' '<<j<<'\n';
//        if(i==4&&j==-2)cout<<1<<endl;
          int x=min(0,min(i,i+j));
          int y=max(0,B-(A-i));
          int z=max(0,C-(A-(i+j)));
          ans=min(ans,max(y,z)-x+A);
      }
    }
  }
  cout<<ans<<'\n';
  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
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
char a[N],b[N],c[N];
int ab[N],bc[N],ac[N];
int ch(char x,char y){
  if(x==y || x=='?' || y=='?')return 1;
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin>>a+1>>b+1>>c+1;
  int A=strlen(a+1);
  int B=strlen(b+1);
  int C=strlen(c+1);
  for(int i=1;i<=A;i++){
    for(int j=1;j<=B;j++){
      if(!ch(a[i],b[j]))ab[i-j+20000]=1;
    }
  }
  for(int i=1;i<=A;i++){
    for(int j=1;j<=C;j++){
      if(!ch(a[i],c[j]))ac[i-j+20000]=1;
    }
  }
  for(int i=1;i<=B;i++){
    for(int j=1;j<=C;j++){
      if(!ch(b[i],c[j]))bc[i-j+20000]=1;
    }
  }
  int ans=A+B+C;
  for(int i=-4000;i<=4000;i++){
    for(int j=-4000;j<=4000;j++){
      if(!ab[i+20000] && !bc[j+20000] && !ac[i+j+20000]){
//        cout<<i<<' '<<j<<'\n';
//        if(i==4&&j==-2)cout<<1<<endl;
          int x=min(0,min(i,i+j));
          int y=max(0,B-(A-i));
          int z=max(0,C-(A-(i+j)));
          ans=min(ans,max(y,z)-x+A);
      }
    }
  }
  cout<<ans<<'\n';
  return 0;
}
```