#include <bits/stdc++.h>
using namespace std;
double PI = 3.1415926535897932384626433832795;
string s = "gfedabc";
int main() {
  long long n, ans = 0;
  char c;
  cin >> n >> c;
  if (n % 2 == 0) ans += 7;
  ans += ((n + 3) / 4 - 1) * 6 * 2 + ((n + 3) / 4 - 1) + 3 * ((n + 3) / 4 - 1);
  ans += s.find(c);
  cout << ans;
  return 0;
}
