#include <bits/stdc++.h>
using namespace std;
long long r, ans;
char c, s[55];
char id[] = {"fedabc"};
int main() {
  scanf("%s", s);
  int x = strlen(s);
  for (int i = 0; i < x - 1; i++) r = (r * 10 + s[i] - '0');
  c = s[x - 1];
  r--;
  ans = (r / 4) * 13 + (r / 4) * 3;
  r %= 4;
  if (r == 1 || r == 3) ans += 7;
  for (int i = 0; i < 6; i++)
    if (c == id[i]) ans += (i + 1);
  cout << ans;
}
