#include <bits/stdc++.h>
using namespace std;
const int step[2] = {-1, 1}, mn = 101000;
int n, m, xs, ys, kx, ky, x, y, fx, fy, cnt;
long long ans;
string st;
set<int> T[mn];
void fix(int x, int y, int& fx, int& fy) {
  if (x == 1)
    fx = 1;
  else if (x == n)
    fx = 0;
  if (y == 1)
    fy = 1;
  else if (y == m)
    fy = 0;
}
int run(int& x, int& y, int& fx, int& fy) {
  int l = n;
  if (fx == 0)
    l = min(l, x - 1);
  else
    l = min(l, n - x);
  if (fy == 0)
    l = min(l, y - 1);
  else
    l = min(l, m - y);
  x += l * step[fx], y += l * step[fy];
  fix(x, y, fx, fy);
  return l;
}
int main() {
  cin >> n >> m >> xs >> ys >> st;
  kx = st[0] == 'D', ky = st[1] == 'R';
  fix(xs, ys, kx, ky);
  x = xs, y = ys, fx = kx, fy = ky;
  ans = cnt = 1;
  T[x].insert(y);
  for (;;) {
    ans += run(x, y, fx, fy);
    if (!T[x].count(y)) {
      ++cnt;
      T[x].insert(y);
    }
    if (cnt == n + m - 2) break;
    if (x == xs && y == ys && fx == kx && fy == ky) break;
  }
  if (cnt == n + m - 2)
    cout << ans << endl;
  else
    cout << -1 << endl;
  return 0;
}
