#include <bits/stdc++.h>
using namespace std;
int top[100010], bottom[100010], le[100010], ri[100010];
int dx[4] = {1, 1, -1, -1};
int dy[4] = {1, -1, -1, 1};
int correctit(int y, int x, int n, int m, int d) {
  switch (d) {
    case 0:
      if (y == n - 1) return (x == m - 1) ? 2 : 1;
      if (x == m - 1) return 3;
      break;
    case 1:
      if (!y) return (x == m - 1) ? 3 : 0;
      if (x == m - 1) return 2;
      break;
    case 2:
      if (!y) return !x ? 0 : 3;
      if (!x) return 1;
      break;
    case 3:
      if (y == n - 1) return !x ? 1 : 2;
      if (!x) return 0;
      break;
  }
  return d;
}
int main() {
  int n, i, m, y, x, j, d;
  char buf[16];
  scanf("%d %d", &n, &m);
  scanf("%d %d %s", &y, &x, buf);
  y--;
  x--;
  string dir(buf);
  if (dir == "UL")
    d = 2;
  else if (dir == "UR")
    d = 1;
  else if (dir == "DL")
    d = 3;
  else
    d = 0;
  int mustbe = (m + 1) / 2 + (n - (m & 1)) / 2 + (m - ((n + m) % 2 == 0)) / 2 +
               (n - 2) / 2;
  long long total = 0;
  int xo = x;
  int yo = y;
  while (true) {
    d = correctit(y, x, n, m, d);
    if (!y) {
      if (!top[x]) {
        mustbe--;
        if (!mustbe) break;
      }
      if (top[x] & (1 << d)) break;
      top[x] |= 1 << d;
    } else if (y == n - 1) {
      if (!bottom[x]) {
        mustbe--;
        if (!mustbe) break;
      }
      if (bottom[x] & (1 << d)) break;
      bottom[x] |= 1 << d;
    } else if (!x) {
      if (!le[y]) {
        mustbe--;
        if (!mustbe) break;
      }
      if (le[y] & (1 << d)) break;
      le[y] |= 1 << d;
    } else {
      if (!ri[y]) {
        mustbe--;
        if (!mustbe) break;
      }
      if (ri[y] & (1 << d)) break;
      ri[y] |= 1 << d;
    }
    int k = 1000000;
    if (-x / dx[d] > 0) k = -x / dx[d];
    if ((m - 1 - x) / dx[d] > 0) k = min(k, (m - 1 - x) / dx[d]);
    if (-y / dy[d] > 0) k = min(k, -y / dy[d]);
    if ((n - 1 - y) / dy[d] > 0) k = min(k, (n - 1 - y) / dy[d]);
    x += k * dx[d];
    y += k * dy[d];
    total += k;
  }
  total += (xo != x || yo != y);
  printf("%I64d", !mustbe ? total : -1LL);
  return 0;
}
