def f(N, S): score = 0 ops = 0 for c in S: if c == '1': score += 1 else: score -= 1 if score < 0: ops += 1 score += 2 return ops N = int(input()) S = input() print(f(N, S))