#include<bits/stdc++.h>
using namespace std;

bool check(string s, int x) {
    if (s[x] != 'A' && s[x] != 'D' && s[x] != 'W' && s[x] != 'S') return false;
    if (s[x + 1] < '0' || s[x + 1] > '9') return false;
    int i = x + 1;
    while (s[i] != ';') {
        if (s[i] < '0' || s[i] > '9') return false;
        i++;
    }
    return true;
}

int main() {
    int x = 0, y = 0;
    string s;
    cin >> s;
    int n = s.size();
    int j = 0;
    while (j < n) {
        if (check(s, j)) {
            int val = 0;
            char dir = s[j];  // 保存初始方向
            j++;
            while (s[j] != ';') {
                val = val * 10 + s[j] - '0';
                j++;
            }
            j++;  // 跳过分号
            if (dir == 'A') x -= val;
            else if (dir == 'D') x += val;
            else if (dir == 'W') y += val;
            else if (dir == 'S') y -= val;
        } else {
            while (s[j] != ';') j++;
            j++;  // 跳过分号
        }
    }
    cout << x << "," << y << endl;
    return 0;
}

#牛客春招刷题训练营#https://gw-c.nowcoder.com/api/sparta/jump/link?link=https%3A%2F%2Fwww.nowcoder.com%2Fdiscuss%2F726480854079250432

//这题是一个有点点折磨人的模拟吧,首先是最关键的检查是否合法,先看这个字符是不是ADWS中的一个,

//再看下一个字符是不是数字,是的话检查下一个分号之前是不是全是数字

//下一个坑就是在主函数中记得跳过分号这个操作