#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int op[1111];
int olen[1111];
int allx[1111];
int axcnt = 0;
int ally[1111];
int aycnt = 0;
int seqx[1111];
int seqy[1111];
int sizex[2222];
int sizey[2222];
int mapx[2222];
int mapy[2222];
bool killed[2222][2222];
bool fucked[2222][2222];
int main(void) {
  int n = 0;
  scanf("%d", &n);
  int cx = 0;
  int cy = 0;
  allx[axcnt++] = cx;
  ally[aycnt++] = cy;
  for (int i = 0; i < n; i++) {
    char ttop[33] = {0};
    scanf("%s %d", ttop, &olen[i]);
    if (ttop[0] == 'D')
      op[i] = 0;
    else if (ttop[0] == 'U')
      op[i] = 1;
    else if (ttop[0] == 'R')
      op[i] = 2;
    else if (ttop[0] == 'L')
      op[i] = 3;
    cx += dx[op[i]] * olen[i];
    cy += dy[op[i]] * olen[i];
    seqx[i] = cx;
    seqy[i] = cy;
    allx[axcnt++] = cx;
    ally[aycnt++] = cy;
  }
  sort(allx, allx + axcnt);
  sort(ally, ally + aycnt);
  axcnt = unique(allx, allx + axcnt) - allx;
  aycnt = unique(ally, ally + aycnt) - ally;
  int alp = 1;
  for (int i = 0; i < axcnt; i++) {
    if (i && allx[i] - allx[i - 1] > 1)
      sizex[alp++] = allx[i] - allx[i - 1] - 1;
    sizex[alp] = 1;
    mapx[i] = alp++;
  }
  alp = 1;
  for (int i = 0; i < aycnt; i++) {
    if (i && ally[i] - ally[i - 1] > 1)
      sizey[alp++] = ally[i] - ally[i - 1] - 1;
    sizey[alp] = 1;
    mapy[i] = alp++;
  }
  for (int i = 0; i < n; i++) {
    seqx[i] = mapx[lower_bound(allx, allx + axcnt, seqx[i]) - allx];
    seqy[i] = mapy[lower_bound(ally, ally + aycnt, seqy[i]) - ally];
  }
  int zxpos = mapx[(lower_bound(allx, allx + axcnt, 0) - allx)];
  int zypos = mapy[(lower_bound(ally, ally + aycnt, 0) - ally)];
  cx = zxpos;
  cy = zypos;
  killed[cx][cy] = true;
  for (int i = 0; i < n; i++) {
    int nx = seqx[i];
    int ny = seqy[i];
    while (cx != nx || cy != ny) {
      cx += dx[op[i]];
      cy += dy[op[i]];
      killed[cx][cy] = true;
    }
  }
  queue<pair<int, int> > q;
  for (int i = 0; i < 2111; i++) {
    fucked[0][i] = true;
    fucked[i][0] = true;
    fucked[axcnt * 2][i] = true;
    fucked[i][aycnt * 2] = true;
    q.push(pair<int, int>(0, i));
    q.push(pair<int, int>(i, 0));
    q.push(pair<int, int>(axcnt * 2, i));
    q.push(pair<int, int>(i, aycnt * 2));
  }
  while (!q.empty()) {
    int tx = q.front().first;
    int ty = q.front().second;
    q.pop();
    for (int i = 0; i < 4; i++) {
      int nx = tx + dx[i];
      int ny = ty + dy[i];
      if (nx < 0 || nx > 2111 || ny < 0 || ny > 2111) continue;
      if (!killed[nx][ny] && !fucked[nx][ny]) {
        fucked[nx][ny] = true;
        q.push(pair<int, int>(nx, ny));
      }
    }
  }
  unsigned long long ans = 0;
  for (int i = 0; i < 2112; i++) {
    for (int j = 0; j < 2112; j++) {
      if (!fucked[i][j]) {
        ans += (unsigned long long)sizex[i] * sizey[j];
      }
    }
  }
  printf("%I64u\n", ans);
  while (getchar() != EOF)
    ;
  return 0;
}
