#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, dir, dat[4][2] = {{1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
long long ans = 1;
char s[3];
map<int, map<int, map<int, bool> > > vis;
bool atedge() { return x == 1 || x == n || y == 1 || y == m; }
void func() {
  int step = min(dir < 2 ? n - x : x - 1, dir & 1 ? y - 1 : m - y);
  x += step * dat[dir][0], y += step * dat[dir][1];
  ans += step;
  if (x == 1 && y == 1)
    dir = 0;
  else if (x == 1 && y == m)
    dir = 1;
  else if (x == n && y == 1)
    dir = 2;
  else if (x == n && y == m)
    dir = 3;
  else if (x == 1)
    dir -= 2;
  else if (x == n)
    dir += 2;
  else if (y == 1)
    dir -= 1;
  else if (y == m)
    dir += 1;
}
int main() {
  scanf("%d%d%d%d%s", &n, &m, &x, &y, s);
  if (s[0] != 'D') dir += 2;
  if (s[1] != 'R') dir += 1;
  int cnt = n + m - 2;
  if (atedge()) --cnt, vis[x][y][dir] = 1;
  while (cnt) {
    func();
    if (!vis[x].count(y)) {
      vis[x][y][dir] = 1;
      --cnt;
    } else {
      if (vis[x][y].count(dir)) return printf("-1\n"), 0;
      vis[x][y][dir] = 1;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
