#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int n, i, j, k, c1, c2, c3, c4, ans;
  cin >> n;
  cin >> s;
  ans = 0;
  for (i = 0; i < n; i++) {
    for (j = i; j < n; j++) {
      c1 = c2 = c3 = c4 = 0;
      for (k = i; k <= j; k++) {
        if (s[k] == 'U') c1++;
        if (s[k] == 'D') c2++;
        if (s[k] == 'R') c3++;
        if (s[k] == 'L') c4++;
      }
      if ((c1 == c2) && (c3 == c4)) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
