#include <bits/stdc++.h>
const int MX = 1073741735;
const long long MXLL = 9223372036854775807;
const int Sz = 1110111;
using namespace std;
inline void rcin() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
}
string s;
int lx, ly;
int main() {
  rcin();
  int n;
  cin >> n;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'U') lx++;
    if (s[i] == 'D') lx--;
    if (s[i] == 'R') ly++;
    if (s[i] == 'L') ly--;
  }
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    int x = lx, y = ly;
    for (int j = i; j < s.size(); j++) {
      if (s[j] == 'U') x++;
      if (s[j] == 'D') x--;
      if (s[j] == 'R') y++;
      if (s[j] == 'L') y--;
      ans += (lx == x && ly == y);
    }
  }
  cout << ans;
  return 0;
}
