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