#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, a[201] = {}, b[201] = {};
  cin >> n;
  string str;
  cin >> str;
  for (int i = 1; i <= n; ++i) switch (str[i - 1]) {
      case 'U':
        a[i] = 1;
        break;
      case 'D':
        a[i] = -1;
        break;
      case 'R':
        b[i] = 1;
        break;
      case 'L':
        b[i] = -1;
        break;
    }
  for (int i = 2; i <= n; ++i) a[i] += a[i - 1], b[i] += b[i - 1];
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j)
      if (a[j] - a[i - 1] == 0 && b[j] - b[i - 1] == 0) ++ans;
  cout << ans << '\n';
  return 0;
}
