#include <bits/stdc++.h>
using namespace std;
const int INF = 1075555555;
map<int, int> A[100010];
int n, m, now, dx, dy, x, y;
char ch[10];
void work(void) {
  scanf("%d%d", &n, &m);
  scanf("%d%d", &x, &y);
  scanf("%s", ch + 1);
  if (ch[1] == 'U')
    dx = -1;
  else
    dx = 1;
  if (ch[2] == 'L')
    dy = -1;
  else
    dy = 1;
  int rem = n + m - 2;
  if (x == 1 || x == n || y == 1 || y == m) {
    A[x][y] = 1;
    rem--;
  }
  int timer = 0;
  long long ans = 1;
  while (true) {
    timer++;
    if (timer >= 500000) {
      cout << -1 << endl;
      return;
    }
    int dis = INF;
    if (dx == 1)
      dis = min(dis, n - x);
    else
      dis = min(dis, x - 1);
    if (dy == 1)
      dis = min(dis, m - y);
    else
      dis = min(dis, y - 1);
    x += dx * dis, y += dy * dis;
    ans += dis;
    if (x == 1)
      dx = 1;
    else if (x == n)
      dx = -1;
    if (y == 1)
      dy = 1;
    else if (y == m)
      dy = -1;
    if (A[x][y] == 0) {
      rem--;
      A[x][y] = 1;
    }
    if (!rem) {
      cout << ans << endl;
      return;
    }
  }
}
int main() {
  work();
  return 0;
}
