#include <bits/stdc++.h>
using namespace std;
const int N = 2100;
int vis[N][N], g[N][N];
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
map<long long, int> mR, mC;
vector<long long> vR, vC, sR, sC;
struct line {
  long long a, b, c, d;
};
vector<line> q;
int qq;
int n, m;
void compress(vector<long long> &v, vector<long long> &sz,
              map<long long, int> &mp) {
  sort((v).begin(), (v).end());
  v.resize(unique((v).begin(), (v).end()) - v.begin());
  int n = (int)v.size();
  map<long long, long long> spec;
  for (int i = 0; i + 1 < n; i++) {
    if (v[i] + 1 != v[i + 1]) {
      v.push_back(v[i] + 1);
      mp[v[i] + 1];
      spec[v[i] + 1] = v[i + 1] - v[i] - 1;
    }
  }
  sort((v).begin(), (v).end());
  int rnk = 0;
  for (auto &x : mp) {
    x.second = rnk++;
  }
  sz.resize(v.size());
  n = (int)v.size();
  for (int i = 0; i < n; i++) {
    if (spec.count(v[i]) == 0) {
      sz[i] = 1;
    } else {
      sz[i] = spec[v[i]];
    }
  }
}
inline bool in(int i, int j) { return (i >= 0 && i < n && j >= 0 && j < m); }
void dfs(int x, int y) {
  if (vis[x][y] || g[x][y]) {
    return;
  }
  vis[x][y] = 1;
  for (int i = 0; i < 4; i++) {
    int xx = x + dx[i], yy = y + dy[i];
    if (!in(xx, yy)) {
      continue;
    }
    dfs(xx, yy);
  }
}
void draw() {
  for (auto &line : q) {
    int a = mR[line.a], b = mC[line.b], c = mR[line.c], d = mC[line.d];
    if (a > c) {
      swap(a, c);
    }
    if (b > d) {
      swap(b, d);
    }
    for (int i = a; i <= c; i++) {
      for (int j = b; j <= d; j++) {
        g[i][j] = 1;
      }
    }
  }
}
inline void move(char &t, int &x, long long &a, long long &b, long long &c,
                 long long &d) {
  if (t == 'R') {
    d = b + x;
  }
  if (t == 'L') {
    d = b - x;
  }
  if (t == 'U') {
    c = a - x;
  }
  if (t == 'D') {
    c = a + x;
  }
}
int main() {
  long long cr = (1e10 / 2 + 1);
  long long cc = cr;
  mR[1], mC[1], mR[(1e10 / 2 + 1)], mC[(1e10 / 2 + 1)], mR[cr], mC[cc];
  vR.push_back(1), vR.push_back((1e10 / 2 + 1)), vR.push_back(cr);
  vC.push_back(1), vC.push_back((1e10 / 2 + 1)), vC.push_back(cc);
  scanf("%d", &qq);
  for (int i = 0; i < qq; i++) {
    int x;
    char t;
    t = getchar();
    while (t < 'A' || t > 'Z') {
      t = getchar();
    }
    scanf("%d", &x);
    long long a = cr, b = cc, c = cr, d = cc;
    move(t, x, a, b, c, d);
    mR[c], mC[d];
    cr = c, cc = d;
    vR.push_back(c);
    vC.push_back(d);
    q.push_back({a, b, c, d});
  }
  compress(vR, sR, mR);
  compress(vC, sC, mC);
  n = (int)vR.size(), m = (int)vC.size();
  draw();
  for (int i = 0; i < n; i++) {
    dfs(i, 0);
    dfs(i, m - 1);
  }
  for (int i = 0; i < m; i++) {
    dfs(0, i);
    dfs(n - 1, i);
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (vis[i][j] == 0) {
        ans += sR[i] * sC[j];
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
