#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main(void)
{
bool vac=true,check=false;
char tran[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
int num[1000] = { 0 };
int love[4] = { 12,15,22,5 };
string input;
while (getline(cin, input))
{
int counter = 0;
for (int i = 0; i < input.length(); i++)
{
vac = false;
if (isupper(input[i]))
input[i] = tolower(input[i]);
for (int j = 0; j <=25; j++)
{
if (tran[j] == input[i])
{
num[counter] = j + 1;
vac = true;
break;
}
}
if(vac==true)counter++;
}
for (int i = 0; i <= 25; i++)
{
for (int k = 0; k < counter-3; k++)
{
if (num[k] == love[0])
{
check = true;
for (int g = 1; g <= 3; g++)
{
if (num[k + g] != love[g])
{
check = false;
break;
}
}
}
else check = false;
if (check == true)
{
cout << i << endl;
break;
}
}
for (int j = 0; j < counter; j++)
{
num[j]++;
if (num[j] == 27)num[j] = 1;
}
}
}
return 0;
}