#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a;
  char s;
  cin >> a;
  long long sum = 0;
  cin >> s;
  if (a % 2 == 0) {
    if ((a - 1) % 4 == 1) {
      long long z = a;
      long long x = z / 4;
      long long c = z - x * 2;
      sum = sum + c + x * 2;
      sum += (c - 1) * 6;
      if (s == 'f')
        sum = sum;
      else if (s == 'e')
        sum++;
      else if (s == 'd')
        sum = sum + 2;
      else if (s == 'a')
        sum = sum + 3;
      else if (s == 'b')
        sum = sum + 4;
      else
        sum = sum + 5;
    } else {
      long long z = a - 2;
      long long x = z / 4;
      long long c = z - x * 2;
      sum = sum + c + x * 2;
      sum += (c - 1) * 6;
      if (s == 'f')
        sum = sum;
      else if (s == 'e')
        sum++;
      else if (s == 'd')
        sum = sum + 2;
      else if (s == 'a')
        sum = sum + 3;
      else if (s == 'b')
        sum = sum + 4;
      else
        sum = sum + 5;
    }
  } else {
    if (a % 4 == 1) {
      long long z = a;
      long long x = z / 4;
      long long c = z - x * 2;
      sum = sum + c + x * 2;
      sum += (c - 1) * 6;
      if (s == 'f')
        sum = sum;
      else if (s == 'e')
        sum++;
      else if (s == 'd')
        sum = sum + 2;
      else if (s == 'a')
        sum = sum + 3;
      else if (s == 'b')
        sum = sum + 4;
      else
        sum = sum + 5;
    } else {
      long long z = a - 2;
      long long x = z / 4;
      long long c = z - x * 2;
      sum = sum + c + x * 2;
      sum += (c - 1) * 6;
      if (s == 'f')
        sum = sum;
      else if (s == 'e')
        sum++;
      else if (s == 'd')
        sum = sum + 2;
      else if (s == 'a')
        sum = sum + 3;
      else if (s == 'b')
        sum = sum + 4;
      else
        sum = sum + 5;
    }
  };
  cout << sum;
  return 0;
}
