#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> vst;
int tot, n, m, i, j, k, dx = 1, dy = 1;
void go(int x, int y) {
  if (!vst[pair<int, int>(x, y)]) {
    vst[pair<int, int>(x, y)] = 1;
    tot++;
  }
  if (x == 1) dx = 1;
  if (x == n) dx = -1;
  if (y == 1) dy = 1;
  if (y == m) dy = -1;
}
int main() {
  cin >> n >> m;
  int x, y, t, step = 2 * (n + m);
  char dr[10];
  cin >> x >> y;
  scanf("%s", dr);
  if (dr[1] == 'L') dy = -1;
  if (dr[0] == 'U') dx = -1;
  long long ans = 1;
  go(x, y);
  while (step--) {
    if (tot == (n + m - 2)) {
      cout << ans << endl;
      return 0;
    }
    int t = min((dx == 1) ? n - x : x - 1, (dy == 1) ? m - y : y - 1);
    ans += t;
    x += t * dx, y += t * dy;
    go(x, y);
  }
  puts("-1");
  return 0;
}
