#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ans = 0;
  string s;
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    int ver = 0, hon = 0;
    for (int j = i; j < n; j++) {
      if (s[j] == 'U')
        ver++;
      else if (s[j] == 'D')
        ver--;
      else if (s[j] == 'L')
        hon--;
      else
        hon++;
      if (!ver && !hon) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
