#include <bits/stdc++.h>
int main() {
  int n;
  std::cin >> n;
  std::string commands;
  std::cin >> commands;
  long long result = 0;
  for (int len = 2; len <= n; ++len) {
    for (int i = 0; i <= n - len; ++i) {
      int x = 0;
      int y = 0;
      for (int j = i; j <= i + len - 1; ++j) {
        if (commands[j] == 'U')
          --y;
        else if (commands[j] == 'D')
          ++y;
        else if (commands[j] == 'R')
          --x;
        else
          ++x;
      }
      if (x == 0 && y == 0) ++result;
    }
  }
  std::cout << result;
  return 0;
}
