#include <bits/stdc++.h>
long long min(long long a, long long b) { return a < b ? a : b; }
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long e_gcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long ans = e_gcd(b, a % b, x, y);
  long long temp = x;
  x = y;
  y = temp - a / b * y;
  return ans;
}
long long n, m;
long long x, y;
char str[3];
bool judge(long long a, long long b) {
  if ((a <= 1 || a >= n) || (b <= 1 || b >= m)) return 1;
  return 0;
}
bool jd(long long a, long long b) {
  if ((a <= 1 || a >= n) && (b <= 1 || b >= m)) return 1;
  return 0;
}
long long pw(long long a, long long b, long long mod) {
  long long s = 1;
  while (b) {
    if (b & 1) s = (s * a) % mod;
    a = (a * a) % mod;
    b = b / 2;
  }
  return s;
}
long long duo() {
  int a, b;
  if (str[0] == 'D')
    a = n - x - 1;
  else
    a = x - 2;
  if (str[1] == 'R')
    b = m - y - 1;
  else
    b = y - 2;
  return a > b ? b : a;
}
int main() {
  scanf("%lld%lld", &n, &m);
  scanf("%lld%lld", &x, &y);
  scanf("%s", str);
  if (n == 1 && m == 1) {
    printf("%d\n", 0);
    return 0;
  }
  if (n == 1 || m == 1) {
    if (n <= 3 && m <= 3) {
      printf("1\n");
      return 0;
    }
    printf("%d\n", -1);
    return 0;
  }
  long long u = gcd(n - 1, m - 1);
  if (u > 2) {
    printf("-1\n");
    return 0;
  }
  if (x == 1 && y == 1 || x == n && y == m) {
    if (str[0] == 'L' && str[1] == 'D' || str[0] == 'R' && str[1] == 'U') {
      printf("-1\n");
      return 0;
    }
    if (str[0] == 'R' && str[1] == 'D' || str[0] == 'L' && str[1] == 'U') {
      printf("-1\n");
      return 0;
    }
  }
  if (u == 2) {
    long long bian = n / 2 * 2 + m / 2 * 2;
    long long sum = 1LL * n * m / 2 * 2 - bian;
    if ((x + y) % 2 == 0) {
      printf("-1\n");
      return 0;
    }
    if (judge(x, y)) {
      long long ff;
      if (x == 1 || x == n) {
        ff = n - 2;
        if (str[1] == 'L') {
          ff = min(ff, m - y - 1);
        } else
          ff = min(ff, y - 2);
      }
      if (y == 1 || y == m) {
        ff = m - 2;
        if (str[0] == 'U') {
          ff = min(ff, n - x - 1);
        } else
          ff = min(ff, x - 2);
      }
      printf("%lld\n", sum - ff);
      return 0;
    }
    printf("%lld\n", sum - duo());
    return 0;
  } else {
    long long bian = n + m - 2;
    long long sum = 1LL * n * m / 2 * 2 - bian;
    if (jd(x, y)) {
      printf("%lld\n", sum);
      return 0;
    }
    long long xx, yy;
    long long a, b;
    if (str[0] == 'U')
      a = n - x + 1;
    else
      a = x;
    if (str[1] == 'L')
      b = m - y + 1;
    else
      b = y;
    long long f = b - a;
    e_gcd(1 - n, m - 1, xx, yy);
    long long uuu = xx * (n - 1) - yy * (m - 1);
    if (uuu > 0 && f < 0) {
      xx = xx * -1;
      yy = yy * -1;
    }
    if (uuu < 0 && f > 0) {
      xx = xx * -1;
      yy = yy * -1;
    }
    if (f < 0) f = f * -1;
    while (xx < 0 || yy < 0) {
      xx = xx + m - 1;
      yy = yy + n - 1;
    }
    xx = xx * f;
    yy = yy * f;
    long long ans = -2;
    long long mx = xx % (m - 1);
    long long yux = xx / (m - 1);
    if (yy - yux * (n - 1) >= 0) {
      ans = 2 * sum - (n - 1) * mx - a;
    }
    long long my = yy % (n - 1);
    long long yuy = yy / (n - 1);
    if (xx - yuy * (m - 1) >= 0) {
      if (ans == -2)
        ans = 2 * sum - (m - 1) * my - b;
      else {
        ans = min(ans, 2 * sum - (m - 1) * my - b);
      }
    }
    printf("%lld\n", ans);
    return 0;
  }
}
