#include <bits/stdc++.h>
template <class T>
inline T gcd(T a, T b) {
  a = abs(a);
  b = abs(b);
  if (!b) return a;
  return __gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  a = abs(a);
  b = abs(b);
  return (a / __gcd(a, b)) * b;
}
template <class T>
inline T ncr(T n, T r) {
  return n * (n - 1) / r;
}
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  string str;
  cin >> str;
  n = str.length();
  int u = 0, r = 0, l = 0, d = 0;
  int count = 0;
  for (int i = 0; i < n; i++) {
    u = 0, r = 0, l = 0, d = 0;
    for (int j = i; j < n; j++) {
      if (str[j] == 'U')
        u++;
      else if (str[j] == 'D')
        d++;
      else if (str[j] == 'R')
        r++;
      else if (str[j] == 'L')
        l++;
      if (u == d && r == l) count++;
    }
  }
  cout << count << endl;
  return 0;
}
