#include <bits/stdc++.h>
using namespace std;
const int maxn = 503;
char a[maxn];
int x[maxn], y[maxn];
int main() {
  int n;
  int i, j;
  while (scanf("%d", &n) != EOF) {
    memset(x, 0, sizeof(x));
    memset(y, 0, sizeof(y));
    int sum = 0;
    scanf("%s", a + 1);
    for (i = 1; i <= n; i++) {
      x[i] = x[i - 1];
      y[i] = y[i - 1];
      if (a[i] == 'U') x[i]++;
      if (a[i] == 'D') x[i]--;
      if (a[i] == 'L') y[i]++;
      if (a[i] == 'R') y[i]--;
    }
    for (i = 0; i <= n; i++)
      for (j = i + 1; j <= n; j++) {
        if (x[i] - x[j] == 0 && y[i] - y[j] == 0) sum++;
      }
    printf("%d\n", sum);
  }
  return 0;
}
