#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  const int data[4][6] = {
      {4, 5, 6, 3, 2, 1},
      {11, 12, 13, 10, 9, 8},
      {4, 5, 6, 3, 2, 1},
      {11, 12, 13, 10, 9, 8},
  };
  long long n;
  cin >> n;
  char c;
  cin >> c;
  cin >> n >> c;
  --n;
  long long ans = n / 4 * 16;
  ans += data[n % 2][c - 'a'];
  cout << ans << "\n";
}
