#include <bits/stdc++.h>
using namespace std;
bool boom[300000] = {false};
int sit[6] = {3, 4, 5, 2, 1, 0};
int main() {
  char c;
  long long x;
  scanf("%lld%c", &x, &c);
  x--;
  long long ans = 0;
  ans = x / 4 * (6 + 1 + 6 + 1 + 2);
  x %= 2;
  ans += (x)*7 + sit[c - 'a'] + 1;
  printf("%lld", ans);
}
