#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  char c;
  cin >> c >> n;
  if ((c == 'a' || c == 'h') && (n == 1 || n == 8))
    cout << 3;
  else if (n == 1 || n == 8 || c == 'a' || c == 'h')
    cout << 5;
  else
    cout << 8;
  return 0;
}
