#include <bits/stdc++.h>
using namespace std;
int grid[3024][3024];
int Xmax, Ymax;
void dfs(int x, int y) {
  if (x < 0 || y < 0 || x >= Xmax || y >= Ymax || grid[x][y] == 1 ||
      grid[x][y] == -1)
    return;
  grid[x][y] = -1;
  dfs(x - 1, y);
  dfs(x + 1, y);
  dfs(x, y + 1);
  dfs(x, y - 1);
}
int main() {
  int N;
  cin >> N;
  set<long long int> X, Y;
  vector<pair<long long int, long long int> > loc(N + 1);
  long long int x = 0, y = 0;
  X.insert(x);
  Y.insert(y);
  X.insert(-1);
  Y.insert(-1);
  X.insert(1);
  Y.insert(1);
  loc[0] = make_pair(x, y);
  for (int i = 0; i < N; i++) {
    string s;
    long long int val;
    cin >> s >> val;
    if (s == "U")
      x += val;
    else if (s == "D")
      x -= val;
    else if (s == "R")
      y += val;
    else if (s == "L")
      y -= val;
    loc[i + 1] = make_pair(x, y);
    X.insert(x);
    Y.insert(y);
    X.insert(x - 1);
    Y.insert(y - 1);
    X.insert(x + 1);
    Y.insert(y + 1);
  }
  vector<long long int> Xc, Yc;
  for (long long int x : X) Xc.push_back(x);
  for (long long int y : Y) Yc.push_back(y);
  Xmax = Xc.size() + 1;
  Ymax = Yc.size() + 1;
  for (int i = 1; i < loc.size(); i++) {
    int sx = lower_bound(Xc.begin(), Xc.end(), loc[i - 1].first) - Xc.begin();
    int sy = lower_bound(Yc.begin(), Yc.end(), loc[i - 1].second) - Yc.begin();
    int ex = lower_bound(Xc.begin(), Xc.end(), loc[i].first) - Xc.begin();
    int ey = lower_bound(Yc.begin(), Yc.end(), loc[i].second) - Yc.begin();
    if (sx > ex) swap(sx, ex);
    if (sy > ey) swap(sy, ey);
    if (sx != ex)
      while (sx <= ex) grid[sx++][sy] = 1;
    if (sy != ey)
      while (sy <= ey) grid[sx][sy++] = 1;
  }
  dfs(0, 0);
  long long int total = 0;
  for (int i = 1; i < Xc.size(); i++)
    for (int j = 1; j < Yc.size(); j++)
      if (grid[i][j] != -1) {
        total += (Xc[i] - Xc[i - 1]) * (Yc[j] - Yc[j - 1]);
      }
  cout << total << endl;
  return 0;
}
