#include <iostream>
#include <string>
using namespace std;

char a[10100]; // 存储输入字符串
int i, idx;    // idx 用于存储解析的数字
int x, y;      // 当前位置

// 解析数字
int find_count() {
    idx = 0; // 每次调用时重置 idx
    while (a[i] >= '0' && a[i] <= '9') {
        idx = idx * 10 + (a[i] - '0');
        i++;
    }
    // 如果数字后面不是分号,说明指令不合法
    if (a[i] != ';') {
        while (a[i] && a[i] != ';') i++; // 跳过非法部分
        return -1;
    }
    // 检查数字范围是否合法
    if (idx < 1 || idx >= 100) return -1;
    return idx;
}

int main() {
    cin >> a; // 读取输入字符串
    i = 0;
    while (a[i]) {while(a[i]==';')i++;
        char flag = a[i++]; // 读取方向字符
        int f = find_count(); // 解析数字
        if (f == -1) { // 如果数字非法,跳过当前指令
            while (a[i] && a[i] != ';') i++; // 跳过非法部分
            if (a[i] == ';') i++; // 跳过分号
            continue;
        }
        // 根据方向字符和距离更新位置
        switch (flag) {
            case 'A': x -= f; break; // 左
            case 'D': x += f; break; // 右
            case 'W': y += f; break; // 上
            case 'S': y -= f; break; // 下
            default: // 非法方向字符
                while (a[i] && a[i] != ';') i++; // 跳过非法部分
                break;
        }
        if (a[i] == ';') i++; // 跳过分号
    }
    cout << x << "," << y << endl; // 输出最终位置
    return 0;
}