#QHD0000030. Oẳn tù tì (Hoof, Paper, Scissors)

Oẳn tù tì (Hoof, Paper, Scissors)

Hoof, Paper, Scissors

Source: USACO

Version: Phuoc Hung OJ Extended

Problem Statement

This package preserves the original task mechanism. Bessie chơi NN ván Hoof-Paper-Scissors và biết trước nước của đối thủ. Bessie được đổi cử chỉ nhiều nhất KK lần. Hãy tối đa hóa số ván thắng.

Input

Dòng đầu chứa N,KN,K. Dòng hai chứa NN số mã hóa đối thủ: 0=Hoof, 1=Scissors, 2=Paper.

Output

In số ván thắng lớn nhất.

Subtasks

  • Subtask 1 — 20 points: small data.
  • Subtask 2 — 30 points: medium data.
  • Subtask 3 — 50 points: full PHOJ package limits.

Examples

Input

5 1
0 1 2 0 1

Output

3

Explanation

The output follows directly from the rules above.