#include using namespace std; void fast_io() { ios::sync_with_stdio(false); std::cin.tie(nullptr); } int main() { fast_io(); char a, b; cin >> a >> b; string s = {a, b}; sort(s.begin(), s.end()); if (a == b) { cout << 0 << endl; } else if (s == "NS" || s == "EW") { cout << 1 << endl; } else { cout << 2 << endl; } }