func_code_string: #include <bits/stdc++.h>   using namespace std;   void _fill_int(int* p, int val, int rep) {     int i;     for (i = 0; i < rep; i++) p[i] = val;   }   int GETi() {     int i;     scanf( %d , &i);     return i;   }   template <class T>   T sqr(T val) {     return val * val;   }   int W, H;   int TX[2][100001];   int TY[2][100001];   int CT = 0;   void solve() {     int f, r, i, j, k, l, x, y, cur, tar, dx, dy, sx, sy;     char st[4];     H = GETi();     W = GETi();     sy = GETi() - 1;     sx = GETi() - 1;     scanf( %s , st);     ;     dx = (st[1] ==  R ) ? 1 : -1;     dy = (st[0] ==  U ) ? -1 : 1;     for (x = 0; x < W; x++) {       if (((sx + sy) % 2) == (x % 2)) {         TX[0][x]++;         CT++;       }       if (((sx + sy) % 2) == ((x + H - 1) % 2)) {         TX[1][x]++;         CT++;       }     }     for (y = 0; y < H; y++) {       if (((sx + sy) % 2) == (y % 2)) {         TY[0][y]++;         CT++;       }       if (((sx + sy) % 2) == ((y + W - 1) % 2)) {         TY[1][y]++;         CT++;       }     }     signed long long res = 1;     for (i = 0; i < 1000000; i++) {       if (sx == 0 && TY[0][sy]) {         TY[0][sy] = 0;         CT--;       }       if (sx == W - 1 && TY[1][sy]) {         TY[1][sy] = 0;         CT--;       }       if (sy == 0 && TX[0][sx]) {         TX[0][sx] = 0;         CT--;       }       if (sy == H - 1 && TX[1][sx]) {         TX[1][sx] = 0;         CT--;       }       if (CT == 0) {         cout << res << endl;         return;       }       if (sx == 0) dx = 1;       if (sx == W - 1) dx = -1;       if (sy == 0) dy = 1;       if (sy == H - 1) dy = -1;       int ml = 1000000;       if (dx > 0) ml = min(ml, W - 1 - sx);       if (dx < 0) ml = min(ml, sx);       if (dy > 0) ml = min(ml, H - 1 - sy);       if (dy < 0) ml = min(ml, sy);       res += ml;       sx += ml * dx;       sy += ml * dy;     }     printf( -1 n );     return;   }   int main(int argc, char** argv) {     if (argc > 1) freopen(argv[1],  r , stdin);     solve();     return 0;   }   