1 var
2 s:ansistring;
3 T,x,y,mo:longint;
4 procedure main;
5 var
6 i,l:longint;
7 begin
8 l:=length(s);
9 x:=0; y:=0;
10 for i:=1 to l do
11 if s[i]='N' then inc(y) else
12 if s[i]='S' then dec(y) else
13 if s[i]='W' then dec(x) else
14 if s[i]='E' then inc(x);
15 mo:=T mod l; T:=T div l;
16 x:=x*T; y:=y*T;
17 for i:=1 to mo do
18 if s[i]='N' then inc(y) else
19 if s[i]='S' then dec(y) else
20 if s[i]='W' then dec(x) else
21 if s[i]='E' then inc(x);
22 end;
23
24 begin
25 readln(s);
26 readln(T);
27 main;
28 writeln(x,' ',y);
29 end.