#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s = 0, c = 0;
  scanf("%d", &n);
  char a[n + 1];
  scanf("%s", a);
  int arr[n];
  for (int i = 0; i < n; i++) {
    if (a[i] == 'U') arr[i] = -300;
    if (a[i] == 'D') arr[i] = 300;
    if (a[i] == 'R') arr[i] = -1;
    if (a[i] == 'L') arr[i] = 1;
  }
  for (int i = 0; i < n - 1; i++) {
    s = arr[i];
    for (int j = i + 1; j < n; j++) {
      s = s + arr[j];
      if (s == 0) {
        c = c + 1;
      }
    }
  }
  printf("%d\n", c);
}
