#include <bits/stdc++.h>
using namespace std;
const int N = 205;
int n;
char s[N];
bool ck(int l, int r) {
  int a = 0, b = 0, c = 0, d = 0;
  for (int i = l; i <= r; i++) {
    if (s[i] == 'U')
      a++;
    else if (s[i] == 'D')
      b++;
    else if (s[i] == 'L')
      c++;
    else
      d++;
  }
  if (a == b && c == d)
    return 1;
  else
    return 0;
}
int main() {
  scanf("%d", &n);
  scanf("%s", s);
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++) ans += ck(i, j);
  cout << ans << endl;
  return 0;
}
