// 先过滤、后提取
let arr = readline().split(";").filter(f => {
    if (!f) return false
    const wasd = f.substr(0, 1)
    const num = f.substr(1)
    if (!num && num !== '0') return false
    if (isNaN(+num))return false
    return true
})
let point = [0, 0]
arr.forEach(el => {
    const T = el.substr(0, 1);
    const n = Number(el.substr(1));
    switch(T.toLocaleUpperCase()) {
       case 'A':
         point[0] -= n;
       break;
       case 'D':
         point[0] += n;
       break;
       case 'W':
         point[1] += n;
       break;
       case 'S':
         point[1] -= n;
       break;
    }
})
print(point.join())