#include <bits/stdc++.h>
using namespace std;
const unsigned long int N = 100001, DIRECTIONS = 5, SIDE_VISITED_INDEX = 0;
unsigned long int n, m, d, x, y;
bool _up[N][DIRECTIONS], _down[N][DIRECTIONS], _left[N][DIRECTIONS],
    _right[N][DIRECTIONS];
unsigned long int currentCellsCount, cellsCount;
signed long long int answer;
void init() {
  string direction;
  unsigned long int p;
  cin >> n >> m;
  cin >> y >> x >> direction;
  if (direction == "DR") {
    d = 1;
  } else if (direction == "DL") {
    d = 2;
  } else if (direction == "UR") {
    d = 3;
  } else if (direction == "UL") {
    d = 4;
  }
  cellsCount = 2 * (n / 2 + m / 2);
  p = (x + y) % 2;
  if (n % 2 == 1) {
    if (p == 0) {
      cellsCount++;
    }
    if (p != m % 2) {
      cellsCount++;
    }
  }
  if (m % 2 == 1) {
    if (p == 0) {
      cellsCount++;
    }
    if (p != n % 2) {
      cellsCount++;
    }
  }
  x--;
  y--;
  n--;
  m--;
}
void solve() {
  unsigned long int oldX, oldY;
  oldX = 10000000;
  oldY = 10000000;
  answer = 1;
  currentCellsCount = 0;
  while (true) {
    if (x == 0) {
      if (_left[y][d] && (oldX != x || oldY != y)) {
        answer = -1;
        break;
      }
      if (!_left[y][SIDE_VISITED_INDEX]) {
        _left[y][SIDE_VISITED_INDEX] = true;
        currentCellsCount++;
      }
      _left[y][d] = true;
    } else if (x == m) {
      if (_right[y][d] && (oldX != x || oldY != y)) {
        answer = -1;
        break;
      }
      if (!_right[y][SIDE_VISITED_INDEX]) {
        _right[y][SIDE_VISITED_INDEX] = true;
        currentCellsCount++;
      }
      _right[y][d] = true;
    }
    if (y == 0) {
      if (_up[x][d] && (oldX != x || oldY != y)) {
        answer = -1;
        break;
      }
      if (!_up[x][SIDE_VISITED_INDEX]) {
        _up[x][SIDE_VISITED_INDEX] = true;
        currentCellsCount++;
      }
      _up[x][d] = true;
    } else if (y == n) {
      if (_down[x][d] && (oldX != x || oldY != y)) {
        answer = -1;
        break;
      }
      if (!_down[x][SIDE_VISITED_INDEX]) {
        _down[x][SIDE_VISITED_INDEX] = true;
        currentCellsCount++;
      }
      _down[x][d] = true;
    }
    oldX = x;
    oldY = y;
    if (currentCellsCount == cellsCount) {
      break;
    }
    if (d == 1) {
      if (m - x < n - y) {
        answer += m - x;
        y += m - x;
        x = m;
        d = 2;
      } else if (m - x > n - y) {
        answer += n - y;
        x += n - y;
        y = n;
        d = 3;
      } else {
        answer += m - x;
        x = m;
        y = n;
        d = 4;
      }
      continue;
    }
    if (d == 2) {
      if (x < n - y) {
        answer += x;
        y += x;
        x = 0;
        d = 1;
      } else if (x > n - y) {
        answer += n - y;
        x -= n - y;
        y = n;
        d = 4;
      } else {
        answer += x;
        x = 0;
        y = n;
        d = 3;
      }
      continue;
    }
    if (d == 3) {
      if (m - x < y) {
        answer += m - x;
        y -= m - x;
        x = m;
        d = 4;
      } else if (m - x > y) {
        answer += y;
        x += y;
        y = 0;
        d = 1;
      } else {
        answer += y;
        x = m;
        y = 0;
        d = 2;
      }
      continue;
    }
    if (d == 4) {
      if (x < y) {
        answer += x;
        y -= x;
        x = 0;
        d = 3;
      } else if (x > y) {
        answer += y;
        x -= y;
        y = 0;
        d = 2;
      } else {
        answer += x;
        x = 0;
        y = 0;
        d = 1;
      }
      continue;
    }
  }
}
void output() { cout << answer; }
int main() {
  init();
  solve();
  output();
  return 0;
}
