#include <bits/stdc++.h>
using namespace std;
int n, cnt = 0;
string str;
int main(void) {
  cin >> n;
  cin >> str;
  for (int i = 0; i < n; i++) {
    int resV = 0, resH = 0;
    for (int j = i; j < n; j++) {
      if (str[j] == 'U')
        resV++;
      else if (str[j] == 'D')
        resV--;
      else if (str[j] == 'L')
        resH--;
      else if (str[j] == 'R')
        resH++;
      if (resV == 0 && resH == 0) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
