#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
char s[30];
int con(char p) {
  switch (p) {
    case 'f':
      return 1;
    case 'e':
      return 2;
    case 'd':
      return 3;
    case 'a':
      return 4;
    case 'b':
      return 5;
    default:
      return 6;
  }
}
int main() {
  long long n = 0;
  char p;
  scanf("%s", s);
  int l = strlen(s);
  p = s[l - 1];
  long long bas = 1;
  for (int i = l - 2; i >= 0; i--) {
    n += bas * (s[i] - '0');
    bas *= 10;
  }
  long long num = (n % 4) ? (n / 4 + 1) : n / 4;
  long long ans = 16 * (num - 1) + 7 * ((n % 4) % 2 == 0) + con(p);
  cout << ans << endl;
  return 0;
}
