#include <bits/stdc++.h> using namespace std; bool isLegal(string& str){ if(!(str[0]=='A'||str[0]=='D'||str[0]=='S'||str[0]=='W'))return false; for(int i=1;i<str.size();i++){ if(!isdigit(str[i]))return false; } return true; } int main(){ string s; cin>>s; string str; int x=0,y=0; ...