#include <bits/stdc++.h>
using namespace std;
int n;
char c[205];
int sum;
int main() {
  scanf("%d", &n);
  getchar();
  scanf("%s", c);
  sum = 0;
  for (int i = 0; i < n; i++) {
    int a = 0, b = 0, e = 0, d = 0;
    for (int j = i; j < n; j++) {
      if (c[j] == 'U') {
        a++;
      }
      if (c[j] == 'D') {
        b++;
      }
      if (c[j] == 'L') {
        e++;
      }
      if (c[j] == 'R') {
        d++;
      }
      if (a == b && e == d) {
        sum++;
      }
    }
  }
  printf("%d\n", sum);
  return 0;
}
