#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int res = 0;
  for (int i = 0; i < n; i++) {
    int dx = 0, dy = 0;
    for (int j = i; j < n; j++) {
      if (s[j] == 'U')
        dx++;
      else if (s[j] == 'D')
        dx--;
      else if (s[j] == 'L')
        dy--;
      else
        dy++;
      if (dx == 0 and dy == 0) res++;
    }
  }
  cout << res << endl;
  return 0;
}
