#include <bits/stdc++.h>
using namespace std;
int64_t n, m;
void upd(string& str, int64_t& x, int64_t& y) {
  if (str[0] == 'D')
    ++x;
  else
    --x;
  if (str[1] == 'R')
    ++y;
  else
    --y;
}
int64_t upd_xy(string& str, int64_t& x, int64_t& y) {
  int64_t mx_x = 0, mx_y = 0;
  if (str[0] == 'D')
    mx_x = n - x;
  else if (str[0] == 'U')
    mx_x = x - 1;
  if (str[1] == 'R')
    mx_y = m - y;
  else if (str[1] == 'L')
    mx_y = y - 1;
  int64_t diff = min(mx_x, mx_y);
  if (str[0] == 'D')
    x += diff;
  else
    x -= diff;
  if (str[1] == 'R')
    y += diff;
  else
    y -= diff;
  return diff;
}
void upd_str(string& str, int64_t x, int64_t y, int64_t qx, int64_t qy) {
  if ((qx < 1 || qx > n) && (qy < 1 || qy > m)) {
    if (str[1] == 'L')
      str[1] = 'R';
    else if (str[1] == 'R')
      str[1] = 'L';
    if (str[0] == 'D')
      str[0] = 'U';
    else if (str[0] == 'U')
      str[0] = 'D';
    return;
  }
  if (y == 1 || y == m) {
    if (str[1] == 'L')
      str[1] = 'R';
    else if (str[1] == 'R')
      str[1] = 'L';
  } else if (x == 1 || x == n) {
    if (str[0] == 'D')
      str[0] = 'U';
    else if (str[0] == 'U')
      str[0] = 'D';
  }
}
int main(void) {
  cin >> n >> m;
  int64_t x, y;
  cin >> x >> y;
  string str;
  cin >> str;
  set<pair<int64_t, int64_t> > q;
  q.insert({x, y});
  int64_t ans = 1;
  int64_t mx = (n * m / 2) - ((n - 2) * (m - 2) / 2);
  for (int i = 0; i < 1000 * 1000; ++i) {
    if (q.size() == mx) break;
    int64_t qx = x, qy = y;
    upd(str, qx, qy);
    if (qx < 1 || qx > n || qy < 1 || qy > m) {
      upd_str(str, x, y, qx, qy);
    }
    int64_t diff = upd_xy(str, x, y);
    ans += diff;
    q.insert({x, y});
  }
  if (q.size() == mx)
    cout << ans << endl;
  else
    cout << -1 << endl;
  return 0;
}
