#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1000000000")
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (((a * b) / gcd(a, b))); }
long long phi(long long n) {
  long long result = n;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) n /= i;
      result -= result / i;
    }
  }
  if (n > 1) result -= result / n;
  return result;
}
long long binpow(long long a, long long n, long long c) {
  long long res = 1;
  while (n) {
    if (n & 1) res *= a;
    res %= c;
    a *= a;
    a %= c;
    n >>= 1;
  }
  res = (res + c) % c;
  return res;
}
void nxi(int& n) {
  bool min = 0;
  char c;
  n = 0;
  while ((c = getc(stdin)) && c <= 32)
    ;
  if (c == '-')
    min = 1;
  else
    n = c - 48;
  while ((c = getc(stdin)) && c > 32) n = (n << 3) + (n << 1) + c - 48;
  if (min) n = -n;
}
void prl(int n) {
  if (n == 0) {
    puts("0");
    return;
  }
  if (n < 0) {
    putchar('-');
    n = -n;
  }
  static int s[10];
  int top = 0;
  while (n > 0) s[top++] = n % 10, n /= 10;
  while (top--) putchar(s[top] + 48);
  puts("");
}
using namespace std;
const int nmax = 5100000;
int n;
string s;
map<string, int> m;
int main() {
  srand(time(0));
  cin >> n;
  cin >> s;
  pair<int, int> res = make_pair(0, 0);
  for (int i = 0; i < n; i++) {
    char c = s[i];
    if (c == 'U')
      res.second++;
    else if (c == 'D')
      res.second--;
    else if (c == 'L')
      res.first--;
    else
      res.first++;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    string p = "";
    pair<int, int> pos = make_pair(0, 0);
    for (int j = i; j < n; j++) {
      p += s[j];
      char c = s[j];
      if (c == 'U')
        pos.second++;
      else if (c == 'D')
        pos.second--;
      else if (c == 'L')
        pos.first--;
      else
        pos.first++;
      if (pos == make_pair(0, 0)) {
        m[p]++;
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
