#include <bits/stdc++.h>
int n, i, j, sol, x[500], y[500];
char s[500];
int main() {
  scanf("%d", &n);
  scanf("%s", s);
  if (s[0] == 'U') {
    y[0] = 1;
  }
  if (s[0] == 'D') {
    y[0] = -1;
  }
  if (s[0] == 'L') {
    x[0] = -1;
  }
  if (s[0] == 'R') {
    x[0] = 1;
  }
  for (i = 1; i < n; i++) {
    if (s[i] == 'U') {
      y[i] = y[i - 1] + 1;
      x[i] = x[i - 1];
    }
    if (s[i] == 'D') {
      y[i] = y[i - 1] - 1;
      x[i] = x[i - 1];
    }
    if (s[i] == 'L') {
      x[i] = x[i - 1] - 1;
      y[i] = y[i - 1];
    }
    if (s[i] == 'R') {
      x[i] = x[i - 1] + 1;
      y[i] = y[i - 1];
    }
  }
  for (i = 0; i < n; i++) {
    if ((x[i] == 0) && (y[i] == 0)) sol++;
  }
  for (i = 0; i < n - 1; i++) {
    for (j = i + 1; j < n; j++) {
      if ((x[i] == x[j]) && (y[i] == y[j])) sol++;
    }
  }
  printf("%d", sol);
}
