d='SWNE' s=input() t=input() print((d.find(t)-d.find(s))%4)