#include <bits/stdc++.h>
using namespace std;
inline long long int inp() {
  int n = 0;
  register int c = getchar();
  while (c == ' ' || c == '\n') c = getchar();
  while (c >= '0' && c <= '9') {
    n = (n << 3) + (n << 1) + c - 48;
    c = getchar();
  }
  return n;
}
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int x = 0, y = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'U')
      y++;
    else if (s[i] == 'D')
      y--;
    else if (s[i] == 'R')
      x++;
    else if (s[i] == 'L')
      x--;
  }
  int cnt = 0, xf, yf;
  for (int i = 0; i < n; i++) {
    xf = x, yf = y;
    for (int j = i; j < n; j++) {
      if (s[j] == 'U')
        yf++;
      else if (s[j] == 'D')
        yf--;
      else if (s[j] == 'R')
        xf++;
      else if (s[j] == 'L')
        xf--;
      if (xf == x && yf == y) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
