#include <bits/stdc++.h>
using namespace std;
set<long long> gera_primos(long long n) {
  set<long long> primos;
  vector<bool> crivo(n + 1);
  primos.insert(2);
  for (long long i = 3; i <= n; i += 2) {
    if (crivo[i]) continue;
    primos.insert(i);
    for (long long j = i; j <= n; j += i) {
      crivo[j] = true;
    }
  }
  return primos;
}
struct Link {
  long long from, to, t;
};
struct Node {
  bool visitado = false;
  bool cor = false;
  vector<long long> in, out;
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  string s;
  cin >> n >> s;
  long long total = 0;
  for (long long i = 0; i < (long long)n; i++) {
    for (long long j = i; j < (long long)n; j++) {
      long long x = 0, y = 0;
      for (long long k = i; k < (long long)j + 1; k++) {
        if (s[k] == 'U') x--;
        if (s[k] == 'D') x++;
        if (s[k] == 'L') y--;
        if (s[k] == 'R') y++;
      }
      if (x == 0 and y == 0) total++;
    }
  }
  cout << total << "\n";
}
