d = list('NESWNESW') a = d.index(input()) print((d[a-1:].index(input())-1)%4)