#include <bits/stdc++.h>
using namespace std;
const int dx[4] = {1, 1, -1, -1};
const int dy[4] = {1, -1, -1, 1};
int sx, sy, n, m, sd;
string sd_str;
set<pair<pair<int, int>, int> > s;
set<pair<int, int> > ps;
long long ans = 0;
inline bool on_edge(int x, int y) {
  return x == 1 || x == n || y == 1 || y == m;
}
inline pair<int, int> move(const pair<int, int> &pt, int dir) {
  int delta_x, delta_y;
  if (dir == 0 || dir == 1)
    delta_x = n - pt.first;
  else
    delta_x = pt.first - 1;
  if (dir == 0 || dir == 3)
    delta_y = m - pt.second;
  else
    delta_y = pt.second - 1;
  int delta = min(delta_x, delta_y);
  ans += delta;
  return make_pair(pt.first + dx[dir] * delta, pt.second + dy[dir] * delta);
}
int main() {
  cin >> n >> m >> sx >> sy >> sd_str;
  pair<int, int> now = make_pair(sx, sy);
  if (sd_str == "DR")
    sd = 0;
  else if (sd_str == "DL")
    sd = 1;
  else if (sd_str == "UL")
    sd = 2;
  else
    sd = 3;
  s.insert(make_pair(now, sd));
  ps.insert(now);
  ans = 1;
  while (1) {
    now = move(now, sd);
    if (now.first == 1 || now.first == n) {
      if (sd == 0 && now.first == n)
        sd = 3;
      else if (sd == 3 && now.first == 1)
        sd = 0;
      else if (sd == 1 && now.first == n)
        sd = 2;
      else if (sd == 2 && now.first == 1)
        sd = 1;
    }
    if (now.second == 1 || now.second == m) {
      if (sd == 0 && now.second == m)
        sd = 1;
      else if (sd == 1 && now.second == 1)
        sd = 0;
      else if (sd == 3 && now.second == m)
        sd = 2;
      else if (sd == 2 && now.second == 1)
        sd = 3;
    }
    if (!ps.count(now)) {
      ps.insert(now);
    }
    if (ps.size() == m + n - 2) break;
    if (s.count(make_pair(now, sd))) {
      ans = -1;
      break;
    }
    s.insert(make_pair(now, sd));
  }
  cout << ans << endl;
  return 0;
}
