#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char a[500];
  int ans = 0;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    int x = 0, y = 0;
    for (int j = i; j < n; j++) {
      if (a[j] == 'U') x++;
      if (a[j] == 'R') y++;
      if (a[j] == 'L') y--;
      if (a[j] == 'D') x--;
      if (x == 0 and y == 0) ans++;
    }
  }
  cout << ans << endl;
}
