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