#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e12;
const long long MOD = 1e9 + 7;
double sq(double num) { return num * num; }
long long mod_pow(long long x, long long n) {
  if (n == 0) return 1;
  if (n == 1) return x % MOD;
  long long res = sq(mod_pow(x, n / 2));
  res %= MOD;
  if (n % 2 == 1) {
    res *= x;
    res %= MOD;
  }
  return res;
}
long long mod_add(long long a, long long b) { return (a + b) % MOD; }
long long mod_sub(long long a, long long b) { return (a - b + MOD) % MOD; }
long long mod_mul(long long a, long long b) { return a * b % MOD; }
int n;
string s;
int main() {
  cin >> n >> s;
  int pre = -1;
  int now = 0;
  int yy = 0, xx = 0;
  int ans = 0;
  for (int i = 0; i < (n); i++) {
    if (s[i] == 'R') {
      if (now == 0 && pre == 1) ans++;
      xx++;
    } else {
      if (now == 0 && pre == 2) ans++;
      yy++;
    }
    pre = now;
    if (xx == yy)
      now = 0;
    else if (yy > xx)
      now = 1;
    else
      now = 2;
  }
  cout << ans << endl;
}
