#include <bits/stdc++.h>
long long int num(char a[]) {
  long long int i, r = 0;
  for (i = 0; a[i + 1] != '\0'; i++) r = r * 10 + (int)(a[i] - '0');
  return r;
}
int main() {
  char a[50], b;
  scanf("%s", a);
  long long int k = num(a), k1, ans = 0, i;
  for (i = 0; a[i] != '\0'; i++)
    ;
  b = a[i - 1];
  int v[6] = {1, 2, 3, 6, 5, 4};
  if (k % 4 == 0)
    k1 = k / 4 - 1;
  else
    k1 = k / 4;
  ans += k1 * 16;
  if (k % 2 == 0) ans += 7;
  ans += v['f' - b];
  printf("%lld\n", ans);
  return 0;
}
