#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int n, m, ans = 0;
  cin >> n;
  cin >> s;
  for (int b = 0; b < n; b++) {
    string a = s.substr(b);
    int h = 0, v = 0;
    for (int i = 0; i < a.size(); i++) {
      if (a[i] == 'L') {
        h--;
      }
      if (a[i] == 'R') {
        h++;
      }
      if (a[i] == 'U') {
        v++;
      }
      if (a[i] == 'D') {
        v--;
      }
      if (v == 0 && h == 0) {
        ans++;
      }
    }
  }
  cout << ans;
  return 0;
}
