#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
int main() {
  long long int n;
  char c;
  scanf("%I64d%c", &n, &c);
  n--;
  long long int ans = 0;
  ans += 16 * (n / 4);
  n %= 4;
  if (n % 2 == 1) {
    ans += 7;
  }
  switch (c) {
    case 'c':
      ans++;
    case 'b':
      ans++;
    case 'a':
      ans++;
    case 'd':
      ans++;
    case 'e':
      ans++;
    case 'f':
      ans++;
  }
  printf("%I64d", ans);
}
