#include <bits/stdc++.h>
using namespace std;
struct Task {
  int solve(string filePrefix) {
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    long long n = -1;
    char ch = 'x';
    cin >> n >> ch;
    ;
    ;
    const vector<int> inrowdelay = {4, 5, 6, 3, 2, 1};
    const vector<int> interrowdelay = {0, 7, 0, 7};
    --n;
    long long sol = 16 * (n / 4) + interrowdelay[n % 4] + inrowdelay[ch - 'a'];
    cout << sol << endl;
    return 0;
  }
};
int solve(std::string s) {
  Task t;
  return t.solve(s);
}
int main(int argc, char *argv[]) {
  int ret = 0;
  ret = solve("");
  return ret;
}
