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