#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

const int N = 2010;
const int M = N * 5;
string a, b, c;
bool ab[M], ac[M], bc[M];

int match(char a, char b) {
	return a == b || a == '?' || b == '?';
}

int main() {
	cin >> a >> b >> c;
	int len_a = a.size(), len_b = b.size(), len_c = c.size();

	for (int i = 0; i < len_a; i++)
		for (int j = 0; j < len_b; j++)
			if (!match(a[i], b[j]))
				ab[i - j + 2 * N] = true;
	for (int i = 0; i < len_a; i++)
		for (int j = 0; j < len_c; j++)
			if (!match(a[i], c[j]))
				ac[i - j + 2 * N] = true;
	for (int i = 0; i < len_b; i++)
		for (int j = 0; j < len_c; j++)
			if (!match(b[i], c[j]))
				bc[i - j + 2 * N] = true;

	int res = M;
	for (int i = -(len_b + len_c); i <= len_a + max(len_b, len_c); i++)
		for (int j = -(len_b + len_c); j <= len_a + max(len_b, len_c); j++)
			if (!ab[i + 2 * N] && !ac[j + 2 * N] && !bc[j - i + 2 * N]) {
				int L = min(0, min(i, j));
				int R = max(len_a, max(len_b + i, len_c + j));
				res = min(res, R - L);
			}

	cout << res << endl;

	return 0;
}

### Prompt

Create a solution in CPP for 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 <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

const int N = 2010;
const int M = N * 5;
string a, b, c;
bool ab[M], ac[M], bc[M];

int match(char a, char b) {
	return a == b || a == '?' || b == '?';
}

int main() {
	cin >> a >> b >> c;
	int len_a = a.size(), len_b = b.size(), len_c = c.size();

	for (int i = 0; i < len_a; i++)
		for (int j = 0; j < len_b; j++)
			if (!match(a[i], b[j]))
				ab[i - j + 2 * N] = true;
	for (int i = 0; i < len_a; i++)
		for (int j = 0; j < len_c; j++)
			if (!match(a[i], c[j]))
				ac[i - j + 2 * N] = true;
	for (int i = 0; i < len_b; i++)
		for (int j = 0; j < len_c; j++)
			if (!match(b[i], c[j]))
				bc[i - j + 2 * N] = true;

	int res = M;
	for (int i = -(len_b + len_c); i <= len_a + max(len_b, len_c); i++)
		for (int j = -(len_b + len_c); j <= len_a + max(len_b, len_c); j++)
			if (!ab[i + 2 * N] && !ac[j + 2 * N] && !bc[j - i + 2 * N]) {
				int L = min(0, min(i, j));
				int R = max(len_a, max(len_b + i, len_c + j));
				res = min(res, R - L);
			}

	cout << res << endl;

	return 0;
}

```