#include <bits/stdc++.h>
using namespace std;
char s[234];
pair<int, int> evaluate(int l, int r) {
  pair<int, int> ret = {0, 0};
  for (int i = l; i < r; ++i) {
    if (s[i] == 'U') ++ret.first;
    if (s[i] == 'D') --ret.first;
    if (s[i] == 'L') ++ret.second;
    if (s[i] == 'R') --ret.second;
  }
  return ret;
}
int main(void) {
  int n;
  scanf("%d%s", &n, s);
  int ans = 0;
  pair<int, int> target = evaluate(0, n);
  for (int i = 0; i < n; ++i)
    for (int j = i; j < n; ++j) {
      pair<int, int> e = evaluate(i, j + 1);
      if (e.first == 0 && e.second == 0) ++ans;
    }
  printf("%d\n", ans);
  return 0;
}
