#include <bits/stdc++.h>
using namespace std;
int Read() {
  char c;
  while (c = getchar(), (c != '-') && (c < '0' || c > '9'))
    ;
  bool neg = (c == '-');
  int ret = (neg ? 0 : c - 48);
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + c - 48;
  return neg ? -ret : ret;
}
map<pair<int, int>, int> t;
char s[5];
int N, M, dx, dy, x, y;
long long ans = 1;
int main() {
  scanf("%d%d%d%d%s", &N, &M, &x, &y, s);
  dx = (s[0] == 'U' ? -1 : 1), dy = (s[1] == 'L' ? -1 : 1);
  for (int cb = 1; cb <= 2 * (N + M - 2); cb++) {
    t[make_pair(x, y)] = 1;
    if (t.size() == N + M - 2) return cout << ans << endl, 0.0;
    dx = (x > 1 ? (x < N ? dx : -1) : 1), dy = (y > 1 ? (y < M ? dy : -1) : 1);
    int d = min(dx > 0 ? N - x : x - 1, dy > 0 ? M - y : y - 1);
    ans += d, x += d * dx, y += d * dy;
  }
  return puts("-1"), 0.0;
}
