#include <bits/stdc++.h>
using namespace std;
int i, j, maxi, mini = 1000000000, d, n, m, k, rasp, ok, a, b, ul, ad[501][501];
char c[1000];
int f[1000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (i = 1; i <= n; i++) cin >> c[i];
  for (i = 1; i <= n; i++, a = 0, b = 0)
    for (j = i; j <= n; j++) {
      if (c[j] == 'U') a++;
      if (c[j] == 'D') a--;
      if (c[j] == 'L') b++;
      if (c[j] == 'R') b--;
      if (a == 0 && b == 0) rasp++;
    }
  cout << rasp;
  return 0;
}
