#include <bits/stdc++.h>
int n, up, right, coins = 0;
std::string str;
int main() {
  std::cin >> n >> str;
  for (int i = 0; i < n - 1; ++i) {
    switch (str[i]) {
      case 'U':
        up++;
        break;
      case 'R':
        right++;
        break;
    }
    if (up == right && str[i] == str[i + 1]) {
      coins++;
    }
  }
  std::cout << coins;
  return 0;
}
