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