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

#TP0000073. Xóa xâu hai bước (String Deletion)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Xóa xâu hai bước (String Deletion)

String Deletion

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given a binary string, each operation must delete one arbitrary character and then, if nonempty, delete its maximum equal-character prefix. Maximize the number of operations before the string becomes empty.

Input

Line 1: nn. Line 2: binary string ss. Exactly one case, without TT.

Output

Print the maximum possible number of operations.

Subtasks

  • Subtask 1 (20 points): Exactly one dataset; 1≤n≤121\le n\le12; the string contains exactly nn binary characters.
  • Subtask 2 (30 points): Exactly one dataset; 1≤n≤20001\le n\le2000; the string contains exactly nn binary characters.
  • Subtask 3 (50 points): Exactly one dataset; 1≤n≤2000001\le n\le200000; the string contains exactly nn binary characters.

Example

Input

6
111010

Output

3

Explanation

Deleting a character then the maximal equal prefix can be repeated three times on 111010.