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

#define INF 1234567890
#define ll long long

int res = INF;

vector<bool> Col(string &a, string &b)
{
	vector<bool> ret(6060, false);
	for(int i=0; i<a.size(); i++) // b를 i칸 시프트
		for(int j=i; j<a.size() && j-i<b.size(); j++) //
			if (a[j]!='?'&&b[j-i]!='?'&&a[j]!=b[j-i])
			{
				ret[i] = true;
				break;
			}
	return ret;
}

void Solve(string &a, string &b, string &c)
{
	vector<bool> ab, ac, bc;
	ab = Col(a, b);
	bc = Col(b, c);
	ac = Col(a, c);
	for(int i=0; i<=a.size(); i++) // b의 스타팅
		for(int j=i; j<=max(a.size(), i+b.size()); j++) // c의 스타팅
		{
			if (ab[i] || ac[j] || bc[j-i]) continue;
			int val = max({a.size(), i+b.size(), j+c.size()});
			res = min(res, val);
		}
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string a, b, c;
	cin >> a >> b >> c;
	Solve(a, b, c);
	Solve(a, c, b);
	Solve(b, a, c);
	Solve(b, c, a);
	Solve(c, a, b);
	Solve(c, b, a);
	cout << res;
	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<bits/stdc++.h>
using namespace std;

#define INF 1234567890
#define ll long long

int res = INF;

vector<bool> Col(string &a, string &b)
{
	vector<bool> ret(6060, false);
	for(int i=0; i<a.size(); i++) // b를 i칸 시프트
		for(int j=i; j<a.size() && j-i<b.size(); j++) //
			if (a[j]!='?'&&b[j-i]!='?'&&a[j]!=b[j-i])
			{
				ret[i] = true;
				break;
			}
	return ret;
}

void Solve(string &a, string &b, string &c)
{
	vector<bool> ab, ac, bc;
	ab = Col(a, b);
	bc = Col(b, c);
	ac = Col(a, c);
	for(int i=0; i<=a.size(); i++) // b의 스타팅
		for(int j=i; j<=max(a.size(), i+b.size()); j++) // c의 스타팅
		{
			if (ab[i] || ac[j] || bc[j-i]) continue;
			int val = max({a.size(), i+b.size(), j+c.size()});
			res = min(res, val);
		}
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string a, b, c;
	cin >> a >> b >> c;
	Solve(a, b, c);
	Solve(a, c, b);
	Solve(b, a, c);
	Solve(b, c, a);
	Solve(c, a, b);
	Solve(c, b, a);
	cout << res;
	return 0;
}
```