#include <bits/stdc++.h>
using namespace std;
int64_t TN = 1;
void solve() {
  string s;
  int a, b, sum = 0;
  cin >> s;
  b = s[1] - 48;
  a = s[0] - 'a' + 1;
  int64_t v[10][10];
  for (int i = 0; i < 10; ++i)
    for (int j = 0; j < 10; ++j) v[i][j] = 0;
  v[a + 1][b] = 1;
  v[a - 1][b] = 1;
  v[a][b + 1] = 1;
  v[a][b - 1] = 1;
  v[a - 1][b - 1] = 1;
  v[a - 1][b + 1] = 1;
  v[a + 1][b + 1] = 1;
  v[a + 1][b - 1] = 1;
  for (long long i = 0; i < 8; ++i)
    for (long long j = 0; j < 8; ++j) sum += v[i + 1][j + 1];
  cout << sum;
}
int main() {
  for (int i = 0; i < TN; ++i) {
    solve();
  }
  return 0;
}
