l_count = 0
r_count = sum([1 for c in S if c == "."])
count_if_contain_black = l_count+r_count
count_if_all_white = 0
for c in S:
    if c == "#":
        l_count += 1
        count_if_all_white += 1
    else:
        r_count -= 1
        
    count_if_contain_black = min(count_if_contain_black, l_count+r_count)

print(min(count_if_all_white, count_if_contain_black))