#include <bits/stdc++.h>
using namespace std;
int n, m, x, y;
char ch[4];
int dx, dy;
map<pair<int, int>, bool> Map;
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d%d", &x, &y);
  scanf("%s", ch);
  if (ch[0] == 'D')
    dx = 1;
  else
    dx = -1;
  if (ch[1] == 'R')
    dy = 1;
  else
    dy = -1;
  long long ans = 1;
  for (int i = 1; i <= 2 * (n + m); i++) {
    Map[make_pair(x, y)] = 1;
    if (Map.size() == n + m - 2) {
      cout << ans << endl;
      return 0;
    }
    int delx, dely;
    if (dx == -1)
      delx = x - 1;
    else
      delx = n - x;
    if (dy == -1)
      dely = y - 1;
    else
      dely = m - y;
    int mw = min(delx, dely);
    x += mw * dx;
    y += mw * dy;
    if (delx == mw) dx = -dx;
    if (dely == mw) dy = -dy;
    ans += mw;
  }
  printf("-1\n");
  return 0;
}
