#include <bits/stdc++.h>
using namespace std;
int main() {
  int space;
  scanf("%d", &space);
  vector<pair<int, int> > vii(space + 1);
  pair<int, int> ii = {0, 0};
  vii[0] = ii;
  for (int i = 0; i < space; ++i) {
    char c;
    cin >> c;
    if (c == 'U')
      ++ii.first;
    else if (c == 'D')
      --ii.first;
    else if (c == 'R')
      ++ii.second;
    else
      --ii.second;
    vii[i + 1] = ii;
  }
  long long ans = 0;
  for (int i = 0; i < space + 1; ++i) {
    for (int j = i + 1; j < space + 1; ++j) {
      if (vii[i] == vii[j]) {
        ++ans;
      }
    }
  }
  cout << ans << '\n';
}
