#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <regex>
using namespace std;
void Posation(int& x, int& y, string& str)
{
for (int i = 0; i < str.size(); i++)
{
if (isalpha(str[i])) {
if(str[i + 2] == ';'){
if (str[i] == 'W') y += (int)(str[i + 1] - '0'); //W y+
if (str[i] == 'S') y -= (int)(str[i + 1] - '0'); //S y-
if (str[i] == 'D') x += (int)(str[i + 1] - '0'); //D x+
if (str[i] == 'A') x -= (int)(str[i + 1] - '0'); //A x-
}
if (str[i + 3] == ';'){
if (str[i] == 'W') y += (int)(str[i + 1] - '0') * 10 + (int)(str[i + 2] - '0'); //W y+
if (str[i] == 'S') y -= (int)(str[i + 1] - '0') * 10 + (int)(str[i + 2] - '0'); //S y-
if (str[i] == 'D') x += (int)(str[i + 1] - '0') * 10 + (int)(str[i + 2] - '0'); //D x+
if (str[i] == 'A') x -= (int)(str[i + 1] - '0') * 10 + (int)(str[i + 2] - '0'); //A x-
}
}
}
cout << x << ',' << y;
}
int main()
{
int x, y; x = y = 0;
string str, str1;
smatch result; regex reg("[ASDW]{1}\\d{1,2}");
while (getline(cin, str, ';')) {
if (regex_match(str, result, reg)){ //判断是否符合格式reg表达式
str1.append(str); //符合的压入str1末
str1.push_back(';'); //以;隔开
}
}
//cout << str1;
Posation(x, y, str1);
//for (sregex_iterator itr(str.begin(), str.end(), reg), end_itr; itr != end_itr; ++itr) {
//cout << itr->str() << endl; //迭代器遍历输出
// str1.append(itr->str());
//}
return 0;
}