#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int x = 0, y = 0, i, j, count = 0, n;
  cin >> n;
  string s1;
  cin >> s1;
  for (i = 0; i < n - 1; i++) {
    x = 0;
    y = 0;
    for (j = i; j < s1.size(); j++) {
      switch (s1[j]) {
        case 'U':
          ++y;
          break;
        case 'D':
          --y;
          break;
        case 'L':
          --x;
          break;
        case 'R':
          ++x;
          break;
      }
      if (x == 0 && y == 0) ++count;
    }
  }
  cout << count;
}
