#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, u, d, l, r, ans = 0;
  cin >> n;
  string s;
  cin >> s;
  int i, j;
  int k = s.length();
  for (i = 0; i < k; i++) {
    u = 0, d = 0, l = 0, r = 0;
    for (j = i; j < k; j++) {
      if (s[j] == 'U')
        u++;
      else if (s[j] == 'D')
        d++;
      else if (s[j] == 'L')
        l++;
      else if (s[j] == 'R')
        r++;
      if (u == d && l == r) ans++;
    }
  }
  cout << ans;
}
