#include using namespace std; // N-E-S-W int main(void) { string a, b; int an, bn, rot; cin >> a >> b; if (a == "N") an = 1; if (a == "E") an = 2; if (a == "S") an = 3; if (a == "W") an = 4; if (b == "N") bn = 1; if (b == "E") bn = 2; if (b == "S") bn = 3; if (b == "W") bn = 4; rot = bn - an; if (rot < 0) rot += 4; cout << rot << endl; return 0; }