#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int ud = 0, lr = 0;
    for (int j = i; j < n; j++) {
      if (s[j] == 'U')
        ud++;
      else if (s[j] == 'D')
        ud--;
      else if (s[j] == 'L')
        lr--;
      else if (s[j] == 'R')
        lr++;
      if (ud == 0 && lr == 0) ans++;
    }
  }
  cout << ans << '\n';
}
