#include <bits/stdc++.h>
using namespace std;
const int maxn = 3100;
vector<int> sx, sy;
int n, x, y, xx, yy;
long long ans = 0;
bool vis[maxn][maxn];
vector<pair<int, pair<int, int> > > h, v;
queue<pair<int, int> > q;
const int go[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
void init() {
  string st;
  int len, tt;
  cin >> n;
  x = y = 1e9 + 10000000;
  sx.push_back(0);
  sy.push_back(0);
  sx.push_back(2 * x);
  sy.push_back(2 * y);
  for (int i = 1; i <= n; i++) {
    cin >> st >> len;
    if (st == "R")
      tt = 0;
    else if (st == "L")
      tt = 1;
    else if (st == "U")
      tt = 2;
    else
      tt = 3;
    if (go[tt][0] != 0) {
      xx = x + go[tt][0] * len;
      int sta = min(xx, x), end = max(xx, x) + 1;
      sx.push_back(sta);
      sx.push_back(end);
      sy.push_back(y);
      sy.push_back(y + 1);
      h.push_back(make_pair(y, make_pair(sta, end)));
      x = xx;
    } else {
      yy = y + go[tt][1] * len;
      int sta = min(y, yy), end = max(y, yy) + 1;
      sx.push_back(x);
      sx.push_back(x + 1);
      sy.push_back(sta);
      sy.push_back(end);
      v.push_back(make_pair(x, make_pair(sta, end)));
      y = yy;
    }
  }
  sort(sx.begin(), sx.end());
  sort(sy.begin(), sy.end());
  sx.erase(unique(sx.begin(), sx.end()), sx.end());
  sy.erase(unique(sy.begin(), sy.end()), sy.end());
}
void run1() {
  vis[0][0] = true;
  for (int i = 0; i < h.size(); i++) {
    int y = h[i].first;
    pair<int, int> X = h[i].second;
    int xi = lower_bound(sx.begin(), sx.end(), X.first) - sx.begin();
    int yi = lower_bound(sy.begin(), sy.end(), y) - sy.begin();
    for (; sx[xi] < X.second; xi++)
      if (!vis[xi][yi]) {
        vis[xi][yi] = true;
        ans += sx[xi + 1] - sx[xi];
      }
  }
  for (int i = 0; i < v.size(); i++) {
    int x = v[i].first;
    pair<int, int> Y = v[i].second;
    int yi = lower_bound(sy.begin(), sy.end(), Y.first) - sy.begin();
    int xi = lower_bound(sx.begin(), sx.end(), x) - sx.begin();
    for (; sy[yi] < Y.second; yi++)
      if (!vis[xi][yi]) {
        vis[xi][yi] = true;
        ans += sy[yi + 1] - sy[yi];
      }
  }
}
void run2() {
  q.push(make_pair(0, 0));
  while (!q.empty()) {
    int x = q.front().first, y = q.front().second;
    q.pop();
    for (int i = 0; i < 4; i++) {
      int xx = x + go[i][0], yy = y + go[i][1];
      if (xx >= 0 && xx <= sx.size() && yy >= 0 && yy <= sy.size()) {
      } else
        continue;
      if (!vis[xx][yy]) {
        vis[xx][yy] = true;
        q.push(make_pair(xx, yy));
      }
    }
  }
  for (int i = 0; i < sx.size(); i++)
    for (int j = 0; j < sy.size(); j++)
      if (!vis[i][j])
        ans += (long long)(sx[i + 1] - sx[i]) * (sy[j + 1] - sy[j]);
}
int main() {
  init();
  run1();
  run2();
  cout << ans << endl;
}
