#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char ara[n];
  cin >> ara;
  long long int c = 0;
  for (int i = 1; i <= n - 1; i++) {
    int x = 0, y = 0;
    for (int j = i - 1; j < n; j++) {
      switch (ara[j]) {
        case 'U':
          y++;
          break;
        case 'D':
          y--;
          break;
        case 'R':
          x++;
          break;
        case 'L':
          x--;
          break;
      }
      if (x == 0 && y == 0) c++;
    }
  }
  cout << c << endl;
  return 0;
}
