#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  char s;
  long long sum = 0;
  cin >> n;
  cin >> s;
  long long k;
  k = n / 4;
  if (n % 4 == 0) k = k - 1;
  sum += 16 * k;
  if (n % 4 == 2 || n % 4 == 0) sum += 7;
  if (s == 'f')
    sum += 1;
  else if (s == 'e')
    sum += 2;
  else if (s == 'd')
    sum += 3;
  else if (s == 'c')
    sum += 6;
  else if (s == 'b')
    sum += 5;
  else if (s == 'a')
    sum += 4;
  cout << sum;
}
