import java.util.*; import java.util.stream.*; import java.util.regex.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String line = in.nextLine(); String[] arrBefore = line.split(";"); int x = 0, y = 0; Pattern pattern = Pattern.compile("([WASD])(\\d{1,2})"); for (String str : arrBefore) { Matcher matcher = pattern.matcher(str); if (matcher.matches()) { // String w = matcher.group(); String w = matcher.group(1); String n = matcher.group(2); int num = Integer.parseInt(n); switch (w) { case "W": y += num; break; case "A": x -= num; break; case "S": y -= num; break; case "D": x += num; } } } System.out.print(x+","+y); } }