#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, dx, dy, cnt, stp;
long long ans;
string s;
map<pair<int, int>, int> vis;
inline int abs(int x) { return x < 0 ? -x : x; }
int main() {
  scanf("%d%d%d%d", &n, &m, &x, &y);
  cin >> s, dx = s[0] == 'U' ? -1 : 1, dy = s[1] == 'L' ? -1 : 1;
  if (x == 1 || x == n || y == 1 || y == m) vis[make_pair(x, y)] = 1, cnt++;
  while (cnt != n + m - 2) {
    stp++;
    if (stp > 1000000) {
      puts("-1");
      return 0;
    }
    int ux = dx == 1 ? abs(n - x) : abs(x - 1),
        uy = dy == 1 ? abs(m - y) : abs(y - 1);
    ans += min(ux, uy), x += dx * min(ux, uy), y += dy * min(ux, uy);
    dx = (x == 1 ? 1 : (x == n ? -1 : dx));
    dy = (y == 1 ? 1 : (y == m ? -1 : dy));
    if (vis.count(make_pair(x, y)) == 0) vis[make_pair(x, y)] = 1, cnt++;
  }
  printf("%lld\n", ans + 1);
  return 0;
}
