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