#include <bits/stdc++.h>
using namespace std;
map<char, pair<int, int> > ins;
void operator+=(pair<int, int> &i, pair<int, int> &j) {
  i.first += j.first, i.second += j.second;
}
int main() {
  ins['U'] = pair<int, int>(0, 1), ins['D'] = pair<int, int>(0, -1),
  ins['L'] = pair<int, int>(-1, 0), ins['R'] = pair<int, int>(1, 0);
  int n, m, w = 0;
  pair<int, int> p;
  char s[205];
  scanf("%d %s", &n, s), m = strlen(s);
  for (int i = 0; i < m - 1; ++i) {
    p = ins[s[i]];
    for (int j = i + 1; j < m; ++j) {
      p += ins[s[j]];
      if (p == pair<int, int>(0, 0)) w++;
    }
  }
  printf("%d\n", w);
}
