#include <bits/stdc++.h>
using namespace std;
int n, ans;
char ch;
int main() {
  cin >> ch >> n;
  ans = 8;
  if (ch == 'a' || ch == 'h') ans -= 3;
  if (n == 1 || n == 8) ans -= 3;
  if ((n == 1 || n == 8) && (ch == 'a' || ch == 'h')) ans++;
  printf("%d\n", ans);
  return 0;
}
