#include <bits/stdc++.h>
using namespace std;
const int inf = 1234567890;
const long long infl = 8876543210123456789ll;
const int mod = 1000000007;
void init() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(17);
  cout << fixed;
}
template <class RandomAccessIterator>
void print(RandomAccessIterator a, RandomAccessIterator b) {
  for (; a < b; ++a) {
    cout << (*a) << '\n';
  }
}
template <class RandomAccessIterator>
void println(RandomAccessIterator a, RandomAccessIterator b) {
  for (; a < b; ++a) {
    cout << (*a) << ' ';
  }
  cout << '\n';
}
template <class RandomAccessIterator>
void rarr(RandomAccessIterator a, RandomAccessIterator b) {
  for (; a < b; ++a) {
    cin >> (*a);
  }
}
template <class RandomAccessIterator>
void rgraph(RandomAccessIterator a, int vert, int edj) {
  for (int i = 0; i < (edj); ++i) {
    int u, v;
    cin >> u >> v;
    a[--u].push_back(--v);
    a[v].push_back(u);
  }
}
template <class RandomAccessIterator>
void rdgraph(RandomAccessIterator a, int vert, int edj) {
  for (int i = 0; i < (edj); ++i) {
    int u, v;
    cin >> u >> v;
    a[--u].push_back(--v);
  }
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
  long long n;
  char c;
  scanf("%lld%c", &n, &c);
  unsigned long long lap = ((n - 1) / 4) * 16;
  unsigned long long r = ((n + 1) % 2) * 7;
  unsigned long long s = 0;
  if (c <= 'c') {
    s = 3 + c - 'a' + 1;
  } else {
    s = 'f' - c + 1;
  }
  cout << (lap + r + s) << '\n';
}
