#include <bits/stdc++.h>
char a[250];
int b[500][500];
int main() {
  int n, i, x = 0, y = 0, r = 0;
  scanf("%d\n", &n);
  b[210][210] = 1;
  for (i = 0; i < n; i++) {
    scanf("%c", &a[i]);
    if (a[i] == 'U')
      x++;
    else if (a[i] == 'D')
      x--;
    else if (a[i] == 'R')
      y++;
    else if (a[i] == 'L')
      y--;
    b[x + 210][y + 210]++;
  }
  for (i = 0; i < 430; i++)
    for (int j = 0; j < 430; j++) {
      x = b[i][j];
      r += x * (x - 1) / 2;
    }
  printf("%d", r);
  return 0;
}
