#include <bits/stdc++.h>
using namespace std;
const int mod_max = 1000000007;
long long row;
char seat;
long long seatToInt(char a) {
  if (a == 'f') return 1;
  if (a == 'e') return 2;
  if (a == 'd') return 3;
  if (a == 'a') return 4;
  if (a == 'b') return 5;
  if (a == 'c') return 6;
  return 0;
}
int main() {
  cin >> row >> seat;
  long long sum = 0;
  sum += ((row - 1) / 4) * 16;
  row %= 4;
  if (row % 2 == 1)
    sum += seatToInt(seat);
  else
    sum += 7 + seatToInt(seat);
  cout << sum << endl;
}
