#include <bits/stdc++.h>
using namespace std;
string str;
bool judge(int a, int b) {
  int cntr = 0, cntl = 0, cntu = 0, cntd = 0;
  for (int i = a; i <= b; i++) {
    cntr += (str[i] == 'R');
    cntl += (str[i] == 'L');
    cntu += (str[i] == 'U');
    cntd += (str[i] == 'D');
  }
  return cntr == cntl && cntu == cntd;
}
int main() {
  int n;
  cin >> n;
  cin >> str;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (judge(i, j)) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
