#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const int M = 4;
int now[2], dila[2];
int vis[N][4], n, m, cnt, ans_cnt;
char s[4];
long long ans;
int main() {
  int i, j, k, *p;
  bool lose = false;
  scanf("%d%d%d%d%s", &n, &m, &now[0], &now[1], s);
  if (s[0] == 'U')
    dila[0] = -1;
  else
    dila[0] = 1;
  if (s[1] == 'L')
    dila[1] = -1;
  else
    dila[1] = 1;
  if (now[0] == 1) vis[now[1]][0]++, cnt++;
  if (now[0] == n) vis[now[1]][2]++, cnt++;
  if (now[1] == 1) vis[now[0]][1]++, cnt++;
  if (now[1] == m) vis[now[0]][3]++, cnt++;
  ans_cnt += (m - (((now[1] - now[0] + 1) % 2 - 2) % 2 + 2)) / 2 + 1;
  ans_cnt += (n - (((now[0] - now[1] + 1) % 2 - 2) % 2 + 2)) / 2 + 1;
  ans_cnt += (m - (((now[1] + (n - now[0])) % 2 - 2) % 2 + 2)) / 2 + 1;
  ans_cnt += (n - (((now[0] + (m - now[1])) % 2 - 2) % 2 + 2)) / 2 + 1;
  ans++;
  while (cnt < ans_cnt && !lose) {
    k = 0x7fffffff;
    if (dila[0] == 1)
      k = min(k, n - now[0]);
    else
      k = min(k, now[0] - 1);
    if (dila[1] == 1)
      k = min(k, m - now[1]);
    else
      k = min(k, now[1] - 1);
    ans += k;
    now[0] += dila[0] * k;
    now[1] += dila[1] * k;
    if (now[0] == 1) {
      p = &vis[now[1]][0];
      (*p)++;
      if (*p == 1) cnt++;
      if (*p > M) lose = true;
      if (dila[0] == -1) dila[0] = -dila[0];
    }
    if (now[0] == n) {
      p = &vis[now[1]][2];
      (*p)++;
      if (*p == 1) cnt++;
      if (*p > M) lose = true;
      if (dila[0] == 1) dila[0] = -dila[0];
    }
    if (now[1] == 1) {
      p = &vis[now[0]][1];
      (*p)++;
      if (*p == 1) cnt++;
      if (*p > M) lose = true;
      if (dila[1] == -1) dila[1] = -dila[1];
    }
    if (now[1] == m) {
      p = &vis[now[0]][3];
      (*p)++;
      if (*p == 1) cnt++;
      if (*p > M) lose = true;
      if (dila[1] == 1) dila[1] = -dila[1];
    }
  }
  if (lose)
    puts("-1");
  else
    cout << ans << endl;
  return 0;
}
