#include <bits/stdc++.h>
using namespace std;
char x[210];
int y[210][2];
int main() {
  int n;
  cin >> n;
  cin >> x + 1;
  for (int i = (1); i < (n + 1); i++) {
    y[i][0] = y[i - 1][0];
    y[i][1] = y[i - 1][1];
    if (x[i] == 'U')
      y[i][0]++;
    else if (x[i] == 'D')
      y[i][0]--;
    else if (x[i] == 'R')
      y[i][1]++;
    else
      y[i][1]--;
  }
  int v = 0;
  for (int i = (1); i < (n + 1); i++)
    for (int j = (i + 1); j < (n + 1); j++) {
      if (y[j][0] == y[i - 1][0] && y[j][1] == y[i - 1][1]) v++;
    }
  cout << v << "\n";
  return 0;
}
