#include <bits/stdc++.h>
using namespace std;
int main() {
  long long r;
  char m;
  cin >> r >> m;
  long long res = 0;
  long long full = (r - 1) / 4;
  res += full * (6 * 2 + 4);
  r %= 4;
  if (r == 0) r = 4;
  if (r % 2 == 0) {
    res += 7;
  }
  switch (m) {
    case 'a':
      res += 4;
      break;
    case 'b':
      res += 5;
      break;
    case 'c':
      res += 6;
      break;
    case 'f':
      res += 1;
      break;
    case 'e':
      res += 2;
      break;
    case 'd':
      res += 3;
      break;
  }
  cout << res << endl;
  return 0;
}
