2020-10-04 08:09:06 +00:00
|
|
|
// R39244100
|
|
|
|
|
2020-09-29 13:49:03 +00:00
|
|
|
#include <bits/stdc++.h>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2021-11-19 09:01:13 +00:00
|
|
|
int x = 0, y = 0, t = 0;
|
2020-10-04 08:09:06 +00:00
|
|
|
string s;
|
|
|
|
|
2020-09-29 13:49:03 +00:00
|
|
|
int main() {
|
|
|
|
cin >> s >> t;
|
2020-10-04 08:09:06 +00:00
|
|
|
for (int i = 0; i < s.size(); i++) {
|
|
|
|
switch (s[i]) {
|
|
|
|
case 'E': x++; break;
|
|
|
|
case 'S': y--; break;
|
|
|
|
case 'W': x--; break;
|
|
|
|
case 'N': y++; break;
|
2020-09-29 13:49:03 +00:00
|
|
|
}
|
2020-10-04 08:09:06 +00:00
|
|
|
}
|
|
|
|
x *= (int)(t / s.size());
|
|
|
|
y *= (int)(t / s.size());
|
|
|
|
for (int i = 0; i < t % s.size(); i++) {
|
2020-09-29 13:49:03 +00:00
|
|
|
switch (s[i]) {
|
|
|
|
case 'E': x++; break;
|
|
|
|
case 'S': y--; break;
|
|
|
|
case 'W': x--; break;
|
|
|
|
case 'N': y++; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cout << x << ' ' << y << endl;
|
|
|
|
return 0;
|
|
|
|
}
|