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