#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int x = 0, y = 0;
  long long moves = 0;
  string s;
  cin >> n;
  cin >> s;
  for (int i = 0; i < n; i++) {
    x = 0;
    y = 0;
    if (s[i] == 'U')
      y++;
    else if (s[i] == 'D')
      y--;
    else if (s[i] == 'R')
      x++;
    else if (s[i] == 'L')
      x--;
    if (x == 0 && y == 0) moves++;
    for (int j = i + 1; j < n; j++) {
      if (s[j] == 'U')
        y++;
      else if (s[j] == 'D')
        y--;
      else if (s[j] == 'R')
        x++;
      else if (s[j] == 'L')
        x--;
      if (x == 0 && y == 0) moves++;
    }
  }
  cout << moves;
  return 0;
}
