#!/usr/bin/ python3.8 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(readline()) S = [int(x) % 2 for x in read().rstrip()] def solve(S, N): ret = 0 L = S.index(1) while N > L: N -= 1 ret += 1 S[N] ^= 1 if S[N] == 1: if N == len(S) - 1: return 3 S[N + 1] ^= 1 S[N] = 0 ret += 2 if sum(S) == 0: return ret R = max(n for n, x in enumerate(S) if x == 1) while N < R: N += 1 ret += 1 S[N] ^= 1 if S[N] == 1: if N + 1 == R: return ret + 2 ret += 2 S[N] = 0 S[N + 1] ^= 1 return ret print(min(solve(S[:], N - 1), solve(S[::-1], len(S) - N)))