#include <bits/stdc++.h>
using namespace std;
int acc[210][2];
int len;
string str;
int main(void) {
  cin >> len >> str;
  for (int i = 1; i <= len; i++) {
    switch (str[i - 1]) {
      case 'U':
        acc[i][0] = acc[i - 1][0];
        acc[i][1] = acc[i - 1][1] + 1;
        break;
      case 'D':
        acc[i][0] = acc[i - 1][0];
        acc[i][1] = acc[i - 1][1] - 1;
        break;
      case 'L':
        acc[i][0] = acc[i - 1][0] - 1;
        acc[i][1] = acc[i - 1][1];
        break;
      case 'R':
        acc[i][0] = acc[i - 1][0] + 1;
        acc[i][1] = acc[i - 1][1];
        break;
    }
  }
  int ans = 0;
  for (int s = 0; s < len; s++) {
    for (int e = s + 1; e <= len; e++) {
      if (acc[s][0] == acc[e][0] && acc[s][1] == acc[e][1]) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
