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