#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9 + 7;
int main() {
  int h, w;
  cin >> h >> w;
  int ci, cj;
  cin >> ci >> cj, ci--, cj--;
  string dir;
  cin >> dir;
  int di = dir[0] == 'D' ? 1 : -1;
  int dj = dir[1] == 'R' ? 1 : -1;
  int cnt = 0, pari = (ci + cj) & 1;
  vector<vector<bool>> edge_h(2, vector<bool>(h));
  for (int i = 0; i < h; i++) {
    if (((0 + i) & 1) == pari) cnt += edge_h[0][i] = true;
    if (((w - 1 + i) & 1) == pari) cnt += edge_h[1][i] = true;
  }
  vector<vector<bool>> edge_w(2, vector<bool>(w));
  for (int j = 0; j < w; j++) {
    if (((0 + j) & 1) == pari) cnt += edge_w[0][j] = true;
    if (((h - 1 + j) & 1) == pari) cnt += edge_w[1][j] = true;
  }
  long long ans = 1;
  for (int _ = 0; _ <= (h + w) * 2 * 2; _++) {
    if (ci == 0 && edge_w[0][cj]) edge_w[0][cj] = false, cnt--;
    if (ci == h - 1 && edge_w[1][cj]) edge_w[1][cj] = false, cnt--;
    if (cj == 0 && edge_h[0][ci]) edge_h[0][ci] = false, cnt--;
    if (cj == w - 1 && edge_h[1][ci]) edge_h[1][ci] = false, cnt--;
    if (cnt == 0) return !(cout << ans << endl);
    if (ci == 0) di = 1;
    if (ci == h - 1) di = -1;
    if (cj == 0) dj = 1;
    if (cj == w - 1) dj = -1;
    int mi = INF;
    if (di > 0) mi = min(mi, h - 1 - ci);
    if (di < 0) mi = min(mi, ci);
    if (dj > 0) mi = min(mi, w - 1 - cj);
    if (dj < 0) mi = min(mi, cj);
    ans += mi;
    ci += mi * di;
    cj += mi * dj;
  }
  cout << -1 << endl;
  return 0;
}
