#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, c = 0, sumx = 0, sumy = 0, u = 0, d = 0, r = 0, l = 0;
  cin >> n;
  char a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      if (a[j] == 'U')
        sumy++;
      else if (a[j] == 'R')
        sumx++;
      else if (a[j] == 'L')
        sumx--;
      else if (a[j] == 'D')
        sumy--;
      if (sumx == 0 && sumy == 0) c++;
    }
    sumx = 0;
    sumy = 0;
  }
  cout << c;
  return 0;
}
