#include using namespace std; string s[2]; int a[2]; int main() { cin >> s[0] >> s[1]; for (int i = 0; i < 2; i++) { if (s[i] == "N") a[i] = 0; else if (s[i] == "E") a[i] = 1; else if (s[i] == "S") a[i] = 2; else a[i] = 3; } cout << (a[1] - a[0] + 4) % 4 << endl; }