#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s1, s2, sum = 0, i, j, k;
  char s[400];
  cin >> n;
  cin >> s;
  for (i = 0; i < n; i++)
    for (j = i + 1; j < n; j++) {
      s1 = 0;
      s2 = 0;
      for (k = i; k <= j; k++) {
        if (s[k] == 'U') s1 += 1;
        if (s[k] == 'D') s1 -= 1;
        if (s[k] == 'R') s2 += 1;
        if (s[k] == 'L') s2 -= 1;
      }
      if (s1 == 0 && s2 == 0) sum += 1;
    }
  cout << sum << endl;
  return 0;
}
