n = int(input())
for i in range(1, n + 1):
i = str(i)
dict = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8}
letter = ''
digit = ''
for j in i:
digit = j
else:
letter = j
letter = int(dict[letter])
digit = int(digit)
sum = 0
for k in range(1, 9):
for m in range(1, 9):
if (abs(letter
- k
) == 1 and
abs(digit
- m
) == 2) or
(abs(letter
- k
) == 2 and
abs(digit
- m
) == 1): sum += 1
print(sum)
biA9IGludChpbnB1dCgpKQoKZm9yIGkgaW4gcmFuZ2UoMSwgbiArIDEpOgogICAgaSA9IHN0cihpKQogICAgZGljdCA9IHsnYSc6IDEsICdiJzogMiwgJ2MnOiAzLCAnZCc6IDQsICdlJzogNSwgJ2YnOiA2LCAnZyc6IDcsICdoJzogOH0KICAgIGxldHRlciA9ICcnCiAgICBkaWdpdCA9ICcnCiAgICBmb3IgaiBpbiBpOgogICAgICAgIGlmIGouaXNkaWdpdCgpOgogICAgICAgICAgICBkaWdpdCA9IGoKICAgICAgICBlbHNlOgogICAgICAgICAgICBsZXR0ZXIgPSBqCgogICAgbGV0dGVyID0gaW50KGRpY3RbbGV0dGVyXSkKICAgIGRpZ2l0ID0gaW50KGRpZ2l0KQogICAgc3VtID0gMAoKICAgIGZvciBrIGluIHJhbmdlKDEsIDkpOgogICAgICAgIGZvciBtIGluIHJhbmdlKDEsIDkpOgogICAgICAgICAgICBpZiAoYWJzKGxldHRlciAtIGspID09IDEgYW5kIGFicyhkaWdpdCAtIG0pID09IDIpIG9yIChhYnMobGV0dGVyIC0gaykgPT0gMiBhbmQgYWJzKGRpZ2l0IC0gbSkgPT0gMSk6CiAgICAgICAgICAgICAgICBzdW0gKz0gMQogICAgcHJpbnQoc3VtKQ==