#include <bits/stdc++.h>
#include <stdio.h>
typedef long long ll;
#define M 1000000007
using namespace std;
void test_case() {
int n;
cin >> n;
}
string s[100];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n = 13;
for (int i = 0; i < n; ++i) {
cin >> s[i];
}
map<char, int> needed;
for (int i = 0; i < n; ++i) {
map<char, int> ne;
for (int j = 0; j < n; ++j) {
ne[s[i][j]]++;
}
for (auto it = ne.begin(); it != ne.end(); it++) {
needed[it->first] = max(needed[it->first], it->second);
}
}
int total = 0;
for (auto it = needed.begin(); it != needed.end(); it++) {
//cout << it->first << ": " << it->second << endl;
total += it->second;
}
string ans = s[0];
for (int i = 1; i < n; ++i) {
// insert characters
int pos = 0;
int p = 0;
for (; p < 100; ++p) {
char c = s[i][p];
int f = false;
int j = pos;
for (j = pos; j < (int)ans.length(); ++j) {
if (ans[j] == c) {
f = 1;
break;
}
}
if (f) {
pos = j + 1;
continue;
}
break;
//ans.insert(pos, 1, c);
//pos++;
}
for (; p < 100; ++p) {
ans += s[i][p];
}
}
FILE* f;
f = fopen("out", "w");
fputs(ans.c_str(), f);
fclose(f);
cout << ans.length() << endl;
//cout << "total: " << total << endl;
return 0;
}