#include <bits/stdc++.h>
using namespace std;
int cnt1, cnt2;
map<int, bool> M[100001];
int main() {
  int n, m, x, y, d, dx, dy;
  char dir[4];
  scanf("%d%d%d%d", &n, &m, &x, &y);
  scanf("%s", dir);
  if (dir[0] == 'U')
    dx = -1;
  else
    dx = 1;
  if (dir[1] == 'R')
    dy = 1;
  else
    dy = -1;
  int cnt = m + n - 2, time = 0;
  if (x == 1 || x == n || y == 1 || y == m) M[x][y] = 1, cnt--;
  long long ans = 1;
  while (time <= 1000100) {
    time++;
    int dis = 2e9;
    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);
    ans += (long long)dis;
    x += dx * dis;
    y += dy * dis;
    if (x == 1) dx = 1;
    if (x == n) dx = -1;
    if (y == 1) dy = 1;
    if (y == m) dy = -1;
    if (!M[x][y]) M[x][y] = 1, cnt--;
    if (!cnt) {
      cout << ans << endl;
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}
