#include <bits/stdc++.h>
#pragma GCC optimization("O3")
using namespace std;
const long long inf = 1e9;
const long long inf2 = 1e18;
const long long MAX = 1e5 + 5;
const long long MOD = 1e9 + 7;
const double pi = acos(-1.0);
const double EPS = 1e-9;
void init(int precision) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  cout.precision(precision);
}
inline void iofile() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
long long __[] = {-1, -1, -1, 0, 0, 1, 1, 1};
long long ___[] = {-1, 0, 1, -1, 1, -1, 0, 1};
char _____, ______;
long long _______, ________, ____;
int main() {
  init(10);
  cin >> _____ >> ______;
  _______ = _____ - 'a', ________ = ______ - '1';
  for (long long _ = 0; _ <= 7; _++) {
    if (0 <= _______ + ___[_] && _______ + ___[_] <= 7 &&
        0 <= ________ + __[_] && ________ + __[_] <= 7)
      ____++;
  }
  cout << ____ << '\n';
}
