#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  string s;
  cin >> s;
  int x = s[0] - 'a';
  int y = s[1] - '1';
  if ((x == 0 and y == 0) or (x == 0 and y == 7) or (x == 7 and y == 0) or
      (x == 7 and y == 7))
    cout << 3 << endl;
  else if (x == 0 or x == 7 or y == 0 or y == 7)
    cout << 5 << endl;
  else
    cout << 8 << endl;
  return 0;
}
