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