#include <bits/stdc++.h>
using namespace std;
const int maxn = 503;
char s[maxn];
int x[maxn], y[maxn];
int main() {
  int n;
  scanf("%d", &n);
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++) {
    x[i] = x[i - 1];
    y[i] = y[i - 1];
    if (s[i] == 'U') x[i]++;
    if (s[i] == 'D') x[i]--;
    if (s[i] == 'L') y[i]++;
    if (s[i] == 'R') y[i]--;
  }
  int ans = 0;
  for (int i = 0; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      if (x[i] - x[j] == 0 && y[i] - y[j] == 0) ans++;
  cout << ans << endl;
}
