#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * f;
}
inline void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  int len = 0, w[11];
  do {
    w[len++] = x % 10 + '0';
    x /= 10;
  } while (x);
  while (len--) {
    putchar(w[len]);
  }
}
inline int max(int x, int y) { return x > y ? x : y; }
inline int min(int x, int y) { return x < y ? x : y; }
inline int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }
inline void msort(int a[], int s, int t) {
  int r[100001];
  int m, i, j, k;
  if (s == t) {
    return;
  }
  m = (s + t) / 2;
  msort(a, s, m);
  msort(a, m + 1, t);
  i = s, j = m + 1, k = s;
  while (i <= m && j <= t) {
    if (a[i] <= a[j]) {
      r[k] = a[i], i++, k++;
    }
    if (a[i] >= a[j]) {
      r[k] = a[j], j++, k++;
    }
  }
  while (i <= m) {
    r[k] = a[i], i++, k++;
  }
  while (j <= t) {
    r[k] = a[j], j++, k++;
  }
  for (i = s; i <= t; i++) {
    a[i] = r[i];
  }
}
string str;
int i, j, k, n, m, x, y, t;
long long s;
int d[7];
int main() {
  cin >> str;
  d[0] = 0;
  d[1] = 4;
  d[2] = 5;
  d[3] = 6;
  d[4] = 3;
  d[5] = 2;
  d[6] = 1;
  long long ljj = str[str.size() - 1] - 'a' + 1;
  for (i = 0; i <= str.size() - 2; i++) s = s * 10 + str[i] - 48;
  if (s % 4 == 3 || s % 4 == 0) s -= 2;
  long long Acheing = (s - 1) / 4 * 2 + s % 4 - 1;
  Acheing = Acheing * 6;
  Acheing += d[ljj] + s - 1;
  cout << Acheing << endl;
}
