#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string ch;
  cin >> ch;
  int a(0), b(0);
  int out(0);
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      a = 0;
      b = 0;
      for (int k = i; k <= j; ++k) {
        if (ch[k] == 'R') a++;
        if (ch[k] == 'L') a--;
        if (ch[k] == 'U') b++;
        if (ch[k] == 'D') b--;
      }
      if (!a && !b) out++;
    }
  }
  cout << out;
  return 0;
}
