#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <sstream>
#include <queue>
#include <span>
#include <numeric>
#include <unordered_set>
using namespace std;
template<typename T,
typename = typename enable_if<is_arithmetic<T>::value, T>::type
>
unordered_set<T> intersection(const unordered_set<T> &s1, const unordered_set<T> &s2) {
unordered_set<T> ans;
for (const auto &el: s1) {
if (s2.contains(el)) {
ans.insert(el);
}
}
return ans;
}
int main() {
string s;
int score = 0;
int n = 0;
array<unordered_set<char>, 3> rucksacks;
while (getline(cin, s)) {
rucksacks[n % 3] = unordered_set<char>(s.begin(), s.end());
n++;
if (n % 3 != 0) continue;
char c = *accumulate(rucksacks.begin(), rucksacks.end(), rucksacks[0], intersection<char>).begin();
score += c >= 'a' ? c - 'a' + 1 : c - 'A' + 27;
}
cout << score << endl;
}