PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GD0000076. Bù nhìn giữ đồng (Scarecrow)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Bù nhìn giữ đồng (Scarecrow)

Scarecrow

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

A field consists of nn consecutive cells, each either fertile (.) or infertile (#). A scarecrow placed on any cell (including an infertile cell) protects its own cell and its immediate left and right neighbors, if present. Infertile cells need not be protected. Find the minimum number of scarecrows needed to protect every fertile cell.

Input

The first line contains nn. The second line contains exactly nn characters, each . or #, in left-to-right order.

Output

Print the minimum number of scarecrows.

Subtasks

  • Subtask 1 (20 points): 1≤n≤121\le n\le 12; every character belongs to {., #}.
  • Subtask 2 (30 points): 1≤n≤451\le n\le 45; every character belongs to {., #}.
  • Subtask 3 (50 points): 1≤n≤991\le n\le 99; every character belongs to {., #}.

Examples

Input

11
...##....##

Output

3

Explanation

Place one scarecrow at cell 22 to cover cells 11–33. The fertile block at cells 66–99 needs two more, for example at cells 77 and 99. Thus the minimum is 33.