#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  cin >> a;
  int h = 2, v = 2;
  if (a[0] > 'a' && a[0] < 'h') {
    h = 3;
  }
  if (a[1] > '1' && a[1] < '8') {
    v = 3;
  }
  cout << h * v - 1;
}
