#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
int main() {
  char c;
  int d;
  cin >> c >> d;
  int r = 8;
  if (c == 'a' || c == 'h') r -= 3;
  if (d == 8 || d == 1) r -= 3;
  if ((c == 'a' || c == 'h') && (d == 8 || d == 1)) {
    r++;
  }
  cout << r;
  return 0;
}
