#include <bits/stdc++.h>
using namespace std;
int main() {
  char str[1000];
  long long int n, i, j, sumx = 0, sumy = 0, count = 0;
  cin >> n;
  scanf("%s", str);
  for (i = 0; i < n; i++) {
    for (j = i; j < n; j++) {
      if (str[j] == 'U') sumy = sumy + 1;
      if (str[j] == 'D') sumy = sumy - 1;
      if (str[j] == 'L') sumx = sumx - 1;
      if (str[j] == 'R') sumx = sumx + 1;
      if (sumx == 0 && sumy == 0) count++;
    }
    sumx = 0;
    sumy = 0;
  }
  cout << count << endl;
  return 0;
}
