#include <bits/stdc++.h>
using namespace std;
bool isValid(string s) {
  int x = 0;
  int y = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'U') {
      y++;
    } else if (s[i] == 'D') {
      y--;
    } else if (s[i] == 'L') {
      x--;
    } else if (s[i] == 'R') {
      x++;
    }
  }
  if (x == y && y == 0) {
    return true;
  } else {
    return false;
  }
}
int Occurence(string sub, string s) {
  int occurrences = 0;
  string::size_type start = 0;
  while ((start = s.find(sub, start)) != string::npos) {
    ++occurrences;
    start += 1;
  }
  return occurrences;
}
int main() {
  int n;
  string s;
  cin >> n >> s;
  set<string> substrings;
  string substring = "";
  string::iterator iter;
  set<string> vec;
  for (iter = s.begin(); iter != s.end(); ++iter, substring = "") {
    for (string::iterator iter_2 = iter; iter_2 != s.end(); ++iter_2) {
      substring += *iter_2;
      vec.insert(substring);
    }
    vec.insert(substring);
  }
  int count = 0;
  set<string>::iterator it = vec.begin();
  for (int i = 0; i < vec.size(); i++) {
    if (isValid(*it)) {
      count += Occurence(*it, s);
    }
    it++;
  }
  cout << count << endl;
}
