#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); char a,b; cin >> a >> b; auto f = [](char c) { if(c == 'E') return 0; if(c == 'W') return 2; if(c == 'S') return 1; return 3; }; int x = f(a), y = f(b); if(x <= y) cout << y - x << endl; else cout << 4 + (y - x) << endl; }