#include <bits/stdc++.h>
using namespace std;
int f[4];
int n;
char a[205];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int ans = 0;
  for (int i = 1; i < n; i++)
    for (int j = i + 1; j <= n; j++) {
      memset(f, 0, sizeof(f));
      for (int k = i; k <= j; k++) {
        if (a[k] == 'U') f[0]++;
        if (a[k] == 'D') f[1]++;
        if (a[k] == 'L') f[2]++;
        if (a[k] == 'R') f[3]++;
      }
      if (f[0] == f[1] && f[2] == f[3]) ans++;
    }
  cout << ans;
  return 0;
}
