#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  char seat;
  int k;
  long long time = 0;
  scanf("%I64d%c", &n, &seat);
  switch (seat) {
    case 'a':
      k = 4;
      break;
    case 'b':
      k = 5;
      break;
    case 'c':
      k = 6;
      break;
    case 'd':
      k = 3;
      break;
    case 'e':
      k = 2;
      break;
    case 'f':
      k = 1;
      break;
  }
  if (n == 1 || n == 3) {
    cout << k;
    return 0;
  }
  if (n == 2 || n == 4) {
    cout << k + 6 + 1;
    return 0;
  }
  if (n % 4 == 1 || n % 4 == 3) {
    cout << (n / 4) * 16 + k;
    return 0;
  }
  if (n % 4 == 2 || n % 4 == 0) {
    cout << ((n - (n % 4 == 0)) / 4) * 16 + 1 + 6 + k;
  }
  return 0;
}
