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