#include <bits/stdc++.h>
using namespace std;
map<char, int> M;
int dr[] = {0, 0, -1, 1};
int dc[] = {-1, 1, 0, 0};
vector<vector<char>> was;
int main() {
  M['L'] = 0;
  M['R'] = 1;
  M['D'] = 2;
  M['U'] = 3;
  pair<int, int> cur = make_pair(0, 0);
  vector<int> rs, cs;
  vector<pair<char, pair<int, int>>> v;
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    char c;
    int l;
    cin >> c >> l;
    int dir = M[c];
    pair<int, int> nxt =
        make_pair(cur.first + l * dr[dir], cur.second + l * dc[dir]);
    v.push_back(make_pair((char)dir, nxt));
    cur = nxt;
    rs.push_back(nxt.first);
    rs.push_back(nxt.first + 1);
    rs.push_back(nxt.first - 1);
    cs.push_back(nxt.second);
    cs.push_back(nxt.second + 1);
    cs.push_back(nxt.second - 1);
  }
  rs.push_back(-2e9);
  rs.push_back(2e9);
  cs.push_back(-2e9);
  cs.push_back(2e9);
  rs.push_back(0);
  rs.push_back(1);
  rs.push_back(-1);
  cs.push_back(0);
  cs.push_back(1);
  cs.push_back(-1);
  sort(rs.begin(), rs.end());
  sort(cs.begin(), cs.end());
  rs.erase(unique(rs.begin(), rs.end()), rs.end());
  cs.erase(unique(cs.begin(), cs.end()), cs.end());
  was.resize(rs.size());
  for (int i = 0; i < was.size(); i++) was[i].resize(cs.size());
  for (int i = 0; i < was.size(); i++)
    for (int j = 0; j < cs.size(); j++) was[i][j] = 0;
  pair<int, int> ind = make_pair(0, 0);
  while (rs[ind.first] < 0) ind.first++;
  while (cs[ind.second] < 0) ind.second++;
  for (int i = 0; i < n; i++) {
    was[ind.first][ind.second] = 2;
    while (make_pair(rs[ind.first], cs[ind.second]) != v[i].second) {
      ind.first += dr[v[i].first];
      ind.second += dc[v[i].first];
      was[ind.first][ind.second] = 2;
    }
  }
  queue<pair<int, int>> q;
  q.push(make_pair(0, 0));
  while (!q.empty()) {
    pair<int, int> g = q.front();
    q.pop();
    for (int k = 0; k < 4; k++) {
      pair<int, int> nxt = make_pair(dr[k] + g.first, g.second + dc[k]);
      if (nxt.first < 0 || nxt.second < 0 || nxt.first >= rs.size() ||
          nxt.second >= cs.size())
        continue;
      if (was[nxt.first][nxt.second] != 0) continue;
      was[nxt.first][nxt.second] = 1;
      q.push(nxt);
    }
  }
  long long ans = 0;
  for (int i = 0; i < rs.size(); i++) {
    for (int j = 0; j < cs.size(); j++) {
      if (was[i][j] & 1) continue;
      ans += (long long)(rs[i + 1] - rs[i]) * (cs[j + 1] - cs[j]);
    }
  }
  cout << ans;
  return 0;
}
