#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  string inst;
  cin >> inst;
  int total = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int ct_u = 0;
      int ct_l = 0;
      for (int k = i; k <= j; k++) {
        if (inst[k] == 'U') {
          ct_u++;
        } else if (inst[k] == 'D') {
          ct_u--;
        } else if (inst[k] == 'L') {
          ct_l--;
        } else if (inst[k] == 'R') {
          ct_l++;
        }
      }
      if (ct_u == 0 && ct_l == 0) total++;
    }
  }
  cout << total << endl;
  return 0;
}
