#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int main(void) {
  int n;
  cin >> n;
  getchar();
  char seq[n];
  for (int i = 0; i < n; i++) scanf("%c", &seq[i]);
  int kingdom = 0;
  int x = 0, y = 0;
  if (seq[0] == 'U') {
    y = 1;
    kingdom = 1;
  } else if (seq[0] = 'R') {
    x = 1;
    kingdom = 0;
  }
  int answer = 0;
  for (int i = 1; i < n; i++) {
    switch (seq[i]) {
      case 'U': {
        y++;
        break;
      };
      case 'L': {
        x--;
        break;
      };
      case 'R': {
        x++;
        break;
      };
      case 'D': {
        y--;
        break;
      };
    }
    if (x != y) {
      if (x > y && kingdom == 1) {
        answer++;
        kingdom = 0;
      } else if (x < y && kingdom == 0) {
        answer++;
        kingdom = 1;
      }
    }
  }
  cout << answer;
  return 0;
}
