#include <bits/stdc++.h>
using namespace std;
inline long long IN() {
  long long x = 0;
  int ch = getchar(), f = 1;
  while (!isdigit(ch) && (ch != '-') && (ch != EOF)) ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void OUT(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10)
    OUT(x / 10), putchar(x % 10 + '0');
  else
    putchar(x + '0');
}
map<pair<int, int>, int> poi;
int n, len, Ans, X, Y;
char s[205];
int main() {
  n = IN();
  scanf("%s", s);
  len = strlen(s);
  poi[make_pair(0, 0)]++;
  for (int i = 0; i <= len - 1; i++) {
    if (s[i] == 'U') X++;
    if (s[i] == 'D') X--;
    if (s[i] == 'L') Y--;
    if (s[i] == 'R') Y++;
    Ans += poi[make_pair(X, Y)];
    poi[make_pair(X, Y)]++;
  }
  OUT(Ans);
}
