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