#include <bits/stdc++.h>
using namespace std;
int get_seat(char x) {
  if (x == 'f')
    return 1;
  else if (x == 'e')
    return 2;
  else if (x == 'd')
    return 3;
  else if (x == 'a')
    return 4;
  else if (x == 'b')
    return 5;
  else if (x == 'c')
    return 6;
  else
    return 0;
}
int main() {
  string seat_no;
  long long row_no = 0, i;
  i = 0;
  cin >> seat_no;
  while (isdigit(seat_no[i])) {
    row_no = row_no * 10 + (seat_no[i] - 48);
    i++;
  }
  char col = seat_no[seat_no.length() - 1];
  long long seconds = 0;
  if (row_no % 4 != 0) {
    seconds += (row_no / 4) * 16;
  } else
    seconds += ((row_no - 1) / 4) * 16;
  row_no = row_no % 4;
  if (row_no % 2 != 0)
    seconds += get_seat(col);
  else
    seconds += (7 + get_seat(col));
  cout << seconds;
  return 0;
}
