Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
n = int(raw_input())
s = str(raw_input())

ans=[]
for i in xrange(0,n):
    ans.append(-1)
ans[0]=0

for i in xrange(1,n):
    if s[i] == ".":
        ans[i] = min(s[:i].count("#"), ans[i-1]+1)
    else:
        ans[i] = min(ans[i-1], s[:i].count("#")+1)

print ans[n-1]


Fixed submission:
# -*- coding: utf-8 -*-
n = int(raw_input())
s = str(raw_input())

ans=[]
black=[]
for i in range(0,n):
    ans.append(-1)
    black.append(-1)
ans[0]=0
if s[0]==".":
    black[0]=0
else:
    black[0]=1

for i in range(1,n):
    if s[i] == ".":
        black[i] = black[i-1]
        ans[i] = min(black[i-1], ans[i-1]+1)
    else:
        black[i] = black[i-1] + 1
        ans[i] = min(ans[i-1], black[i-1]+1)

print ans[n-1]

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
n = int(raw_input())
s = str(raw_input())

ans=[]
for i in range(0,n):
    ans.append(-1)
ans[0]=0

for i in range(1,n):
    if s[i] == ".":
        ans[i] = min(s[:i].count("#"), ans[i-1]+1)
    else:
        ans[i] = min(ans[i-1], s[:i].count("#")+1)

print ans[n-1]


Fixed submission:
# -*- coding: utf-8 -*-
n = int(raw_input())
s = str(raw_input())

ans=[]
black=[]
for i in range(0,n):
    ans.append(-1)
    black.append(-1)
ans[0]=0
if s[0]==".":
    black[0]=0
else:
    black[0]=1

for i in range(1,n):
    if s[i] == ".":
        black[i] = black[i-1]
        ans[i] = min(black[i-1], ans[i-1]+1)
    else:
        black[i] = black[i-1] + 1
        ans[i] = min(ans[i-1], black[i-1]+1)

print ans[n-1]

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
n = int(raw_input())
s = str(raw_input())

l = s.strip()
memo=[]
for i in range(0,n):
    memo.append(-1)
memo[0]=0

for i in range(1,n):
    if s[i] == ".":
        memo[i] = min(s[:i].count("#"), memo[i-1]+1)
    else:
        memo[i] = min(memo[i-1], s[:i].count(".")+1)

print memo[n-1]


Fixed submission:
# -*- coding: utf-8 -*-
n = int(raw_input())
s = str(raw_input())

ans=[]
black=[]
for i in range(0,n):
    ans.append(-1)
    black.append(-1)
ans[0]=0
if s[0]==".":
    black[0]=0
else:
    black[0]=1

for i in range(1,n):
    if s[i] == ".":
        black[i] = black[i-1]
        ans[i] = min(black[i-1], ans[i-1]+1)
    else:
        black[i] = black[i-1] + 1
        ans[i] = min(ans[i-1], black[i-1]+1)

print ans[n-1]

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(raw_input())
s = str(raw_input())

l = s.strip()
memo=[]
for i in range(0,n):
    memo.append(-1)
memo[0]=0

def dfs(i):
    if i < 1:
        return 0

    global memo
    if memo[i] != -1:
        return memo[i]
    if s[i] == ".":
        memo[i] = min(s[:i].count("#"), dfs(i-1)+1)
    else:
        memo[i] = min(dfs(i-1), s[:i].count(".")+1)
    return memo[i]

print dfs(n-1)

Fixed submission:
# -*- coding: utf-8 -*-
n = int(raw_input())
s = str(raw_input())

ans=[]
black=[]
for i in range(0,n):
    ans.append(-1)
    black.append(-1)
ans[0]=0
if s[0]==".":
    black[0]=0
else:
    black[0]=1

for i in range(1,n):
    if s[i] == ".":
        black[i] = black[i-1]
        ans[i] = min(black[i-1], ans[i-1]+1)
    else:
        black[i] = black[i-1] + 1
        ans[i] = min(ans[i-1], black[i-1]+1)

print ans[n-1]

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(raw_input())
s = str(raw_input())

l = s.strip()
memo=[]
for i in range(0,n):
    memo.append(-1)
memo[0]=0

def dfs(i):
    global memo
    if memo[i] != -1:
        return memo[i]
    if s[i] == ".":
        memo[i] = min(s[:i].count("#"), dfs(i-1)+1)
    else:
        memo[i] = min(dfs(i-1), s[:i].count(".")+1)
    return memo[i]

print dfs(n-1)

Fixed submission:
# -*- coding: utf-8 -*-
n = int(raw_input())
s = str(raw_input())

ans=[]
black=[]
for i in range(0,n):
    ans.append(-1)
    black.append(-1)
ans[0]=0
if s[0]==".":
    black[0]=0
else:
    black[0]=1

for i in range(1,n):
    if s[i] == ".":
        black[i] = black[i-1]
        ans[i] = min(black[i-1], ans[i-1]+1)
    else:
        black[i] = black[i-1] + 1
        ans[i] = min(ans[i-1], black[i-1]+1)

print ans[n-1]