#include <bits/stdc++.h>
using namespace std;
char a[222];
int main() {
  int n;
  scanf("%d\n", &n);
  scanf("%s", a + 1);
  int res = 0;
  for (int i = 1; i <= n; ++i) {
    int xx = 0, yy = 0;
    for (int j = i; j <= n; ++j) {
      if (a[j] == 'U') ++yy;
      if (a[j] == 'D') --yy;
      if (a[j] == 'L') ++xx;
      if (a[j] == 'R') --xx;
      if (xx == 0 && yy == 0) ++res;
    }
  }
  printf("%d", res);
  return 0;
}
