#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int c[n + 1][2];
  string s;
  cin >> s;
  memset(c, 0, sizeof(c));
  for (int i = 0; i < n; i++) {
    c[i + 1][0] = c[i][0];
    c[i + 1][1] = c[i][1];
    if (s[i] == 'R') {
      c[i + 1][0]++;
    } else if (s[i] == 'L') {
      c[i + 1][0]--;
    } else if (s[i] == 'U') {
      c[i + 1][1]++;
    } else {
      c[i + 1][1]--;
    }
  }
  int ans = 0;
  for (int i = n; i > 0; i--) {
    for (int j = i - 1; j >= 0; j--) {
      ans += (c[i][0] == c[j][0] && c[i][1] == c[j][1]);
    }
  }
  cout << ans;
  return 0;
}
