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