#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int up = 0, le = 0;
    for (int j = i; j < n; j++) {
      if (s[j] == 'U') up++;
      if (s[j] == 'D') up--;
      if (s[j] == 'L') le++;
      if (s[j] == 'R') le--;
      if (up == 0 && le == 0) cnt++;
    }
  }
  cout << cnt << endl;
}
