#include <bits/stdc++.h>
using namespace std;
void yay(int flag) {
  if (flag == 0)
    cout << "NO";
  else
    cout << "YES";
  cout << endl;
}
int eve(long long int x) {
  if (x % 2 == 0) return 1;
  return 0;
}
void solve() {
  long long int n;
  cin >> n;
  char c;
  cin >> c;
  long long int t, ans = 0;
  t = (n - 1) / 4;
  ans += t * 4 + t * 12;
  n -= t * 4;
  t = (n + 1) % 2;
  ans += t + t * 6;
  if (c > 'c')
    ans += 'f' - c + 1;
  else
    ans += 3 + c - 'a' + 1;
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  int t = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
}
