#include <bits/stdc++.h>
using namespace std;
long long a, b, c = 0, d[1010][6], i, j, n, m;
int main() {
  string s, s1, s2;
  n = 0;
  cin >> s;
  i = 0;
  while (i < s.length() && isdigit(s[i])) {
    n = (n * 10) + (s[i] - 48);
    i++;
  }
  char ch = s[i];
  n--;
  a = n / 4;
  int x = 0, y = 2;
  c = 0;
  while (y < 1000) {
    for (i = 0; i < 2; i++) {
      for (j = 5; j >= 3; j--) c++, d[x][j] = c, d[y][j] = c;
      for (j = 0; j < 3; j++) c++, d[x][j] = c, d[y][j] = c;
      x++, y++;
      c++;
    }
    x += 2;
    y += 2;
    c += 2;
  }
  if (n < 4) {
    b = d[n][ch - 'a'];
    cout << b << endl;
  } else {
    if (n % 4 < 2) {
      if (n % 4 == 0) b = (((n - (n % 4)) / 2) * 6) + n + (d[n % 4][ch - 'a']);
      if (n % 4 == 1)
        b = (((n - (n % 4)) / 2) * 6) + n - 1 + (d[n % 4][ch - 'a']);
    } else if (n % 4 >= 2) {
      if (n % 4 == 2)
        b = (((n - (n % 4)) / 2) * 6) + n - 2 + (d[n % 4][ch - 'a']);
      if (n % 4 == 3)
        b = (((n - (n % 4)) / 2) * 6) + n - 3 + (d[n % 4][ch - 'a']);
    }
    cout << b << endl;
  }
  return 0;
}
