#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int maxn = 1007;
const int inf = 1e9 + 3;
int n;
int x[maxn], y[maxn];
void read() {
  cin >> n;
  x[0] = y[0] = 0;
  for (int i = 1; i <= n; i++) {
    char ch;
    int len;
    cin >> ch >> len;
    x[i] = x[i - 1];
    y[i] = y[i - 1];
    if (ch == 'R')
      y[i] += len;
    else if (ch == 'L')
      y[i] -= len;
    else if (ch == 'U')
      x[i] -= len;
    else if (ch == 'D')
      x[i] += len;
  }
}
bool is[maxn * 2][maxn * 2], used[maxn * 2][maxn * 2];
vector<int> xs, ys;
int get_idx_x(int x) {
  return lower_bound(xs.begin(), xs.end(), x) - xs.begin();
}
int get_idx_y(int y) {
  return lower_bound(ys.begin(), ys.end(), y) - ys.begin();
}
void dfs(int x, int y) {
  if (x < 0 || x >= (int)xs.size() - 1 || y < 0 || y >= (int)ys.size() - 1)
    return;
  if (used[x][y] || is[x][y]) return;
  used[x][y] = true;
  dfs(x + 1, y);
  dfs(x - 1, y);
  dfs(x, y + 1);
  dfs(x, y - 1);
}
void solve() {
  xs.push_back(-inf);
  xs.push_back(inf);
  ys.push_back(-inf);
  ys.push_back(inf);
  for (int i = 0; i <= n; i++) {
    xs.push_back(x[i]);
    xs.push_back(x[i] + 1);
    ys.push_back(y[i]);
    ys.push_back(y[i] + 1);
  }
  sort(xs.begin(), xs.end());
  sort(ys.begin(), ys.end());
  xs.erase(unique(xs.begin(), xs.end()), xs.end());
  ys.erase(unique(ys.begin(), ys.end()), ys.end());
  for (int i = 0; i <= n - 1; i++) {
    if (y[i] == y[i + 1]) {
      int idx_y = get_idx_y(y[i]);
      int lx = min(x[i], x[i + 1]), rx = max(x[i], x[i + 1]);
      for (int j = get_idx_x(lx); xs[j] <= rx; j++) is[j][idx_y] = true;
    } else {
      int idx_x = get_idx_x(x[i]);
      int ly = min(y[i], y[i + 1]), ry = max(y[i], y[i + 1]);
      for (int j = get_idx_y(ly); ys[j] <= ry; j++) is[idx_x][j] = true;
    }
  }
  for (int i = 0; i < (int)xs.size() - 1; i++)
    for (int j = 0; j < (int)ys.size() - 1; j++)
      if (xs[i] == -inf || ys[j] == -inf || xs[i + 1] == inf ||
          ys[j + 1] == inf)
        dfs(i, j);
  long long ans = 4ll * inf * inf;
  for (int i = 0; i < (int)xs.size() - 1; i++)
    for (int j = 0; j < (int)ys.size() - 1; j++)
      if (used[i][j]) ans -= 1ll * (xs[i + 1] - xs[i]) * (ys[j + 1] - ys[j]);
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  read();
  solve();
}
