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