var
s:array[1..6000]of char;
a,b,c,m,n,i:longint;
begin
assign(input,'android.in');
assign(output,'android.out');
reset(input);
rewrite(output);
repeat
inc(c);
read(s[c]);
until (s[c]<>'W')and(s[c]<>'E')and(s[c]<>'S')and(s[c]<>'N');
readln;
readln(n);
m:=1;
c:=c-1;
if (n div c)<2 then
while n<>0 do
begin
case s[m] of
'E':inc(b);
'S':dec(a);
'W':dec(b);
'N':inc(a);
end;
inc(m);
dec(n);
if m=c+1 then m:=1;
end else
begin
for i:=1 to c do
case s[i] of
'E':inc(b);
'S':dec(a);
'W':dec(b);
'N':inc(a);
end;
a:=a*(n div c);
b:=b*(n div c);
for i:=1 to n mod c do
case s[i] of
'E':inc(b);
'S':dec(a);
'W':dec(b);
'N':inc(a);
end;
end;
writeln(b,' ',a);
close(input);
close(output);
end.