#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int col = s[0] - 'a' + 1;
  int row = s[1] - '0';
  int result;
  if ((row == 1 && col == 1) || (row == 8 && col == 8) ||
      (row == 1 && col == 8) || (row == 8 && col == 1)) {
    result = 3;
  } else if (row == 1 || col == 1) {
    result = 5;
  } else if (row == 8 || col == 8) {
    result = 5;
  } else {
    result = 8;
  }
  cout << result;
}
