#include <bits/stdc++.h>
using namespace std;
int change(char c) {
  switch (c) {
    case 'U':
      return 0;
    case 'D':
      return 1;
    case 'L':
      return 2;
    case 'R':
      return 3;
  }
  return 4;
}
int v[205];
int dir[4][2] = {{0, 1}, {0, -1}, {-1, 0}, {1, 0}};
int main(void) {
  int n;
  while (cin >> n) {
    for (int i = 0; i < n; i++) {
      char c;
      cin >> c;
      v[i] = change(c);
    }
    int x, y, res = 0;
    for (int i = 0; i < n - 1; i++) {
      x = dir[v[i]][0], y = dir[v[i]][1];
      for (int j = i + 1; j < n; j++) {
        x += dir[v[j]][0], y += dir[v[j]][1];
        if (x == 0 && y == 0) res++;
      }
    }
    cout << res << endl;
  }
  return 0;
}
