#!/usr/bin/env python3 print(sum(ord(x)-87+(ord(x)-ord(a)-1)%3*3 for a,_,x,_ in open("input.txt")))