#include <bits/stdc++.h>
using namespace std;
long long xl[1005], xr[1005], yl[1005], yr[1005], pre[3005][3005];
int dx[4] = {0, 1, -1, 0}, dy[4] = {1, 0, 0, -1}, p[3005][3005];
int main() {
  long long n, now = 1;
  cin >> n;
  long long x = 0, y = 0, ans = 0;
  for (long long i = 1; i <= n; i++) {
    char c;
    long long d;
    cin >> c >> d;
    if (c == 'R') {
      xl[now] = x;
      xr[now] = x;
      yl[now] = y;
      yr[now] = y + d;
      y += d;
      now++;
    }
    if (c == 'L') {
      xl[now] = x;
      xr[now] = x;
      yl[now] = y - d;
      yr[now] = y;
      y -= d;
      now++;
    }
    if (c == 'U') {
      xl[now] = x;
      xr[now] = x + d;
      yl[now] = y;
      yr[now] = y;
      x += d;
      now++;
    }
    if (c == 'D') {
      xl[now] = x - d;
      xr[now] = x;
      yl[now] = y;
      yr[now] = y;
      x -= d;
      now++;
    }
  }
  vector<long long> xs, ys;
  for (long long i = 1; i < now; i++) {
    for (long long j = -1; j <= 1; j++) {
      xs.push_back(xl[i] + j);
      xs.push_back(xr[i] + j);
      ys.push_back(yr[i] + j);
      ys.push_back(yl[i] + j);
    }
  }
  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 (long long i = 1; i < now; i++) {
    xl[i] = lower_bound(xs.begin(), xs.end(), xl[i]) - xs.begin();
    xr[i] = lower_bound(xs.begin(), xs.end(), xr[i]) - xs.begin();
    yl[i] = lower_bound(ys.begin(), ys.end(), yl[i]) - ys.begin();
    yr[i] = lower_bound(ys.begin(), ys.end(), yr[i]) - ys.begin();
  }
  for (long long i = 1; i < now; i++) {
    for (long long j = xl[i]; j <= xr[i]; j++) {
      for (long long k = yl[i]; k <= yr[i]; k++) {
        p[j][k] = 1;
      }
    }
  }
  long long h = xs.size(), w = ys.size(), tag = 1, t = 1;
  for (long long i = 0; i < h; i++) {
    for (long long j = 0; j < w; j++) {
      pre[i][j] = 1;
    }
  }
  queue<pair<int, int> > q;
  for (long long i = 0; i < h; i++) {
    for (long long j = 0; j < w; j++) {
      if (p[i][j] == 2 || p[i][j] == 0) continue;
      q.push({i, j});
      while (q.size()) {
        long long x = q.front().first, y = q.front().second;
        q.pop();
        ans += pre[x][y];
        for (long long i = 0; i < 2; i++) {
          long long nx = x + dx[i], ny = y + dy[i];
          if (nx >= h || nx < 0 || ny >= w || ny < 0 || !p[nx][ny]) continue;
          if (i == 1) pre[nx][ny] *= (xs[nx] - xs[x]);
          if (i == 0) pre[nx][ny] *= (ys[ny] - ys[y]);
          if (p[nx][ny] == 2) continue;
          p[nx][ny] = 2;
          q.push({nx, ny});
        }
      }
    }
  }
  for (long long i = 0; i < h; i++) {
    for (long long j = 0; j < w; j++) {
      if (p[i][j])
        continue;
      else if (tag == 1) {
        q.push({i, j});
        while (q.size()) {
          long long x = q.front().first, y = q.front().second;
          q.pop();
          for (long long i = 0; i < 4; i++) {
            long long nx = x + dx[i], ny = y + dy[i];
            if (nx >= h || nx < 0 || ny >= w || ny < 0 || p[nx][ny]) continue;
            p[nx][ny] = 1;
            q.push({nx, ny});
          }
        }
        tag = 0;
      } else {
        q.push({i, j});
        while (q.size()) {
          long long x = q.front().first, y = q.front().second;
          q.pop();
          ans += pre[x][y];
          for (long long i = 0; i < 2; i++) {
            long long nx = x + dx[i], ny = y + dy[i];
            if (nx >= h || nx < 0 || ny >= w || ny < 0) continue;
            if (i == 1) pre[nx][ny] *= (xs[nx] - xs[x]);
            if (i == 0) pre[nx][ny] *= (ys[ny] - ys[y]);
            if (p[nx][ny]) continue;
            p[nx][ny] = 1;
            q.push({nx, ny});
          }
        }
      }
    }
  }
  cout << ans << endl;
}
