#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr int base = 50000;

std::string a, b, c;
bool ab[100000], ac[100000], bc[100000];

bool match( char ch1, char ch2 )
{ return ch1 == '?' || ch2 == '?' || ch1 == ch2; }

int main()
{
  std::cin >> a >> b >> c;

  int A = a.size();
  int B = b.size();
  int C = c.size();
  int ans = 1<<30;

  rep( ai, A ) rep( bi, B ) if( !match( a[ai], b[bi] ) )
    ab[bi-ai+base] = true;
  rep( ai, A ) rep( ci, C ) if( !match( a[ai], c[ci] ) )
    ac[ci-ai+base] = true;
  rep( bi, B ) rep( ci, C ) if( !match( b[bi], c[ci] ) )
    bc[ci-bi+base] = true;
  
  for( int i = -4000; i <= 4000; ++i ) for( int j = -4000; j <= 4000; ++j ) if( !ab[-i+base] && !ac[-j+base] && !bc[i-j+base] )
  {
    int L = std::min( 0, std::min( i, j ) );
    int R = std::max( A, std::max( i+B, j+C ) );

    ans = std::min( ans, R-L );
  }

  printf( "%d\n", ans );

  return 0;
}
### Prompt

Generate 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 <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr int base = 50000;

std::string a, b, c;
bool ab[100000], ac[100000], bc[100000];

bool match( char ch1, char ch2 )
{ return ch1 == '?' || ch2 == '?' || ch1 == ch2; }

int main()
{
  std::cin >> a >> b >> c;

  int A = a.size();
  int B = b.size();
  int C = c.size();
  int ans = 1<<30;

  rep( ai, A ) rep( bi, B ) if( !match( a[ai], b[bi] ) )
    ab[bi-ai+base] = true;
  rep( ai, A ) rep( ci, C ) if( !match( a[ai], c[ci] ) )
    ac[ci-ai+base] = true;
  rep( bi, B ) rep( ci, C ) if( !match( b[bi], c[ci] ) )
    bc[ci-bi+base] = true;
  
  for( int i = -4000; i <= 4000; ++i ) for( int j = -4000; j <= 4000; ++j ) if( !ab[-i+base] && !ac[-j+base] && !bc[i-j+base] )
  {
    int L = std::min( 0, std::min( i, j ) );
    int R = std::max( A, std::max( i+B, j+C ) );

    ans = std::min( ans, R-L );
  }

  printf( "%d\n", ans );

  return 0;
}
```