#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n, i, j, l, r, u, d, sum;
  char s[209];
  while (scanf("%d", &n) != EOF) {
    getchar();
    scanf("%s", s);
    sum = 0;
    for (i = 0; i < n; i++) {
      l = r = u = d = 0;
      for (j = i + 1; j < n; j++) {
        int x = 1, y = 1;
        for (int k = i; k <= j; k++) {
          if (s[k] == 'U')
            y++;
          else if (s[k] == 'D')
            y--;
          else if (s[k] == 'L')
            x--;
          else
            x++;
        }
        if (x == 1 && y == 1) sum++;
      }
    }
    printf("%d\n", sum);
  }
  return 0;
}
