#include <bits/stdc++.h>
using namespace std;
string s;
unsigned long long tt[6] = {4, 5, 6, 3, 2, 1};
void read() { cin >> s; }
void solve() {
  unsigned long long ans = tt[s[s.size() - 1] - 'a'];
  s.erase(s.end() - 1);
  unsigned long long num = 0, pw = 1;
  for (int i = s.size(); i >= 1; i--) {
    num = num + (unsigned long long)(s[i - 1] - '0') * pw;
    if (i > 1) pw *= 10;
  }
  unsigned long long timeServed = (num - 1) % 4 <= 1 ? num - 1 : num - 3;
  unsigned long long passengers =
      (num - 1) % 4 <= 1 ? (num - 1) / 2 * 6 : (num - 3) / 2 * 6;
  if (((num - 1) % 4) % 2 == 1) passengers += (unsigned long long)6;
  cout << ans + timeServed + passengers << endl;
}
int main() {
  read();
  solve();
  return 0;
}
