#include <bits/stdc++.h>
using namespace std;
struct less_key {
  bool operator()(const pair<int64_t, int64_t>& p1,
                  const pair<int64_t, int64_t>& p2) {
    return p1.first < p2.first ||
           (p1.first == p2.first && p1.second > p2.second);
  }
};
struct pair_hash {
  std::size_t operator()(const pair<int64_t, int64_t>& k) const {
    return static_cast<size_t>(k.first ^ k.second);
  }
};
int64_t n;
char a[202];
int64_t x;
int64_t y;
int64_t cx;
int64_t cy;
void move(char c, int64_t& x, int64_t& y) {
  switch (c) {
    case 'U':
      y++;
      break;
    case 'D':
      y--;
      break;
    case 'L':
      x--;
      break;
    case 'R':
      x++;
      break;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int64_t i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int64_t S = 0;
  for (int64_t i = 0; i <= n; i++) {
    x = cx;
    y = cy;
    for (int64_t j = i + 1; j <= n; j++) {
      move(a[j], x, y);
      if (cx == x && cy == y) {
        S++;
      }
    }
    move(a[i], cx, cy);
  }
  cout << S;
  return 0;
}
