#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m = 0, sum = 0;
  cin >> n;
  string a;
  cin >> a;
  for (int i = 0; i < n; i++) {
    m = 0;
    for (int j = i; j < n; j++) {
      if (a[j] == 'U')
        m++;
      else if (a[j] == 'D')
        m--;
      else if (a[j] == 'R')
        m += 200;
      else if (a[j] == 'L')
        m -= 200;
      if (m == 0) {
        sum++;
      }
    }
  }
  cout << sum;
}
