#include <bits/stdc++.h>
using namespace std;
const int maxn = 200200;
long long n, m, k;
long long ans;
char a[maxn];
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long hs(char x) {
  if (x <= 'c')
    return x - 'a' + 4;
  else
    return 'f' - x + 1;
}
int main() {
  scanf("%I64d", &n);
  scanf("%s", a);
  ans += ((n - 1) / 4) * 12;
  int x = n % 4;
  if (x == 2 || x == 1)
    ans += n - 1;
  else
    ans += n - 3;
  ans += hs(a[0]);
  n = n - (n / 4 * 4);
  if (n == 2 || n == 0) ans += 6;
  cout << ans << endl;
}
