import java.util.ArrayList; import java.util.Scanner; public class Rotating_Golem_1806 { public static void log(Object obj) { System.out.println(obj.toString()); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); String a = sc.next(); String b = sc.next(); ArrayList dirs = new ArrayList<>(); dirs.add("E"); dirs.add("S"); dirs.add("W"); dirs.add("N"); int p = dirs.indexOf(a); int q = dirs.indexOf(b); if((q-p)>=0) { log(q-p); } else { log(b+(3-p)+1); } } }