#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
void solve() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    long long x = 0, y = 0;
    if (s[i] == 'U') y++;
    if (s[i] == 'D') y--;
    if (s[i] == 'R') x++;
    if (s[i] == 'L') x--;
    for (long long j = i + 1; j < n; j++) {
      if (s[j] == 'U') y++;
      if (s[j] == 'D') y--;
      if (s[j] == 'R') x++;
      if (s[j] == 'L') x--;
      if (x == 0 && y == 0) ans++;
    }
  }
  cout << ans;
  cout << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long tc = 1;
  while (tc--) solve();
  return 0;
}
