#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0, r = 0, b = 0;
  for (int a1 = 0; a1 < n; ++a1) {
    if (s[a1] == '0')
      ++r;
    else
      ++b;
    if (r != 0 && b != 0) {
      ++ans;
      --r, --b;
    }
  }
  cout << ans;
  return 0;
}
