from sys import stdin

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

l = []
now = '.'
count = 0
for i in range(n):
  if ( s[i] != now ):
    l.append(count)
    now = s[i]
    count = 0
  count += 1

if ( count > 0 ):
  l.append(count)

l.append(0)

#print(l)

ans = 99999999999
left = 0
right = 0

for j in range(int((len(l)-1)/2)):
  right += l[(j+1)*2]

for ii in range(int(len(l)/2)):
  i = ii*2

  if( i!=0):
    right -= l[i]

  count = 0
  if ( i!=0):
    left += l[i-1]
  
  count = left + right
  #print(i, count, left, right)
  
  if (ans>count):
    ans = count

if (ans == 99999):
  ans = 0

print(ans)
