#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> M;
int main() {
  int n, m, x, y;
  char dir[5];
  scanf("%d%d%d%d%s", &n, &m, &x, &y, dir);
  int dx = (dir[0] == 'U' ? -1 : 1);
  int dy = (dir[1] == 'L' ? -1 : 1);
  int res = n + m - 2;
  if (x == 1 || x == n || y == 1 || y == m) res--, M[make_pair(x, y)] = 1;
  long long ans = 1;
  for (int i = (0); i < (1000001); i++) {
    int step = 2 * max(n, m);
    step = min(dx == 1 ? n - x : x - 1, step);
    step = min(dy == 1 ? m - y : y - 1, step);
    ans += step;
    x = x + step * dx;
    y = y + step * dy;
    if (x == 1 && dx == -1 || x == n && dx == 1) dx = -dx;
    if (y == 1 && dy == -1 || y == m && dy == 1) dy = -dy;
    if (!M[make_pair(x, y)]) res--, M[make_pair(x, y)] = 1;
    if (!res) {
      printf("%lld\n", ans);
      return 0;
    }
  }
  puts("-1");
  return 0;
}
