#include<bits/stdc++.h> using namespace std; int main(){ char a,b; cin>>a>>b; vector<char>A={'N','E','S','W'}; int s=0,g=0; for(int i=0;i<4;i++)if(a==A[i])s=i; for(;g<4;g++)if(A[(s+g)%4]==b)break; cout<<g<<'\n'; }