#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int o, n = 0, x, z, i, t = 0, w, j, p, h, max = 0, y = 0, k, m, l,
                   r, q = 1;
  char g;
  string v;
  string s;
  cin >> s;
  l = s.size();
  for (int i = 0; i < l - 1; i++) {
    n = n * 10 + (s[i] - '0');
  }
  g = s[l - 1];
  if (1) {
    if (g == 'f')
      j = 1;
    else if (g == 'e')
      j = 2;
    else if (g == 'd')
      j = 3;
    else if (g == 'a')
      j = 4;
    else if (g == 'b')
      j = 5;
    else if (g == 'c')
      j = 6;
    q--;
  }
  if (n == 1 || n == 3) {
    cout << j;
  } else if (n == 2 || n == 4) {
    cout << 7 + j;
  } else {
    p = (n + 1) / 2;
    if (p % 2 == 0) {
      t = n - 3;
      z = (p - 2) / 2;
      y = z * 12;
      if (n == p * 2) y = y + 6;
      cout << y + t + j;
    } else {
      t = n - 1;
      z = (p - 1) / 2;
      y = z * 12;
      if (n == p * 2) y = y + 6;
      cout << y + t + j;
    }
  }
}
