#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
const int N = 101000;
int n, m, x, y, dx, dy, tot;
map<int, int> hs[N];
char dir[10];
bool vis[N * 4];
long long ret = 1;
void add(int px, int py) {
  if ((px + py) % 2 == (x + y) % 2) hs[px][py] = tot++;
}
void ff() {
  if (x == 1 && dx == -1) dx = 1;
  if (x == n && dx == 1) dx = -1;
  if (y == 1 && dy == -1) dy = 1;
  if (y == m && dy == 1) dy = -1;
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d%d%s", &x, &y, dir);
  if (dir[0] == 'D')
    dx = 1;
  else
    dx = -1;
  if (dir[1] == 'R')
    dy = 1;
  else
    dy = -1;
  for (int i = 1; i < m + 1; i++) add(1, i), add(n, i);
  for (int i = 2; i < n; i++) add(i, 1), add(i, m);
  ff();
  for (int rd = 0; rd < 4 * (n + m); rd++) {
    if (!vis[hs[x][y]]) --tot;
    if (!tot) break;
    vis[hs[x][y]] = 1;
    int pv = min((dx == 1) ? n - x : x - 1, (dy == 1) ? m - y : y - 1);
    ret += pv;
    x += dx * pv;
    y += dy * pv;
    ff();
  }
  if (tot == 0)
    printf("%I64d\n", ret);
  else
    puts("-1");
}
