#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, tot, a, b, f[4][10000000], dx, dy;
char ch[5];
long long ans;
int solve(int x, int y) {
  if (x == 1)
    a = 0, b = y;
  else if (x == n)
    a = 1, b = y;
  else if (y == 1)
    a = 2, b = x;
  else if (y == m)
    a = 3, b = x;
  if (!f[a][b]) f[a][b] = 1, ++tot;
  if (x == 1) dx = 1;
  if (x == n) dx = -1;
  if (y == 1) dy = 1;
  if (y == m) dy = -1;
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d%d", &x, &y);
  scanf("%s", &ch);
  ch[0] == 'D' ? dx = 1 : dx = -1;
  ch[1] == 'R' ? dy = 1 : dy = -1;
  int t;
  ans = 1;
  for (int i = 1; i <= 2 * (n + m - 2); i++) {
    solve(x, y);
    if (tot >= n + m - 2) {
      printf("%I64d", ans);
      return 0;
    }
    t = min(dy > 0 ? m - y : y - 1, dx > 0 ? n - x : x - 1);
    ans += t;
    x += dx * t;
    y += dy * t;
  }
  puts("-1");
  return 0;
}
