#include <bits/stdc++.h>
using namespace std;
map<long long, long long> mp[100005];
long long n, m;
string s;
long long x, y;
long long dx, dy;
signed main() {
  scanf("%lld%lld%lld%lld", &n, &m, &x, &y);
  cin >> s;
  if (s[0] == 'U')
    dx = -1;
  else
    dx = 1;
  if (s[1] == 'L')
    dy = -1;
  else
    dy = 1;
  long long tot = n + m - 2;
  long long cnt = 0;
  long long ans = 1;
  if (x == 1 || x == n || y == 1 || y == m) {
    tot--;
    mp[x][y] = 1;
  }
  while (1) {
    cnt++;
    if (cnt >= 5e5) {
      puts("-1");
      return 0;
    }
    long long dis = 1e18;
    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 += dis;
    x += dx * dis;
    y += dy * dis;
    if (x == 1)
      dx = 1;
    else if (x == n)
      dx = -1;
    if (y == 1)
      dy = 1;
    else if (y == m)
      dy = -1;
    if (!mp[x][y]) {
      tot--;
      mp[x][y] = 1;
    }
    if (!tot) {
      printf("%lld", ans);
      return 0;
    }
  }
  return 0;
}
