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

#SP0000163. Chia dãy thành ít đoạn không có tích chính phương (Square-Free Division (easy version))

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Chia dãy thành ít đoạn không có tích chính phương (Square-Free Division (easy version))

Square-Free Division (easy version)

Source: Codeforces 1497E1
Version: Phuoc Hung OJ Extended — one dataset per judge run.

Problem Statement

Partition the array into as few contiguous segments as possible so that no two distinct positions in a segment have a product that is a perfect square. This is the easy version: k=0k=0, so no value may be changed.

Input

The first line contains nn and k=0k=0. The second line contains nn integers aia_i.

Output

Print the minimum number of segments.

Subtasks

  • Subtask 1 (20 points): 1≤n≤301\le n\le 30, k=0k=0, 1≤ai≤1071\le a_i\le10^7.
  • Subtask 2 (30 points): 1≤n≤20001\le n\le 2000, k=0k=0, 1≤ai≤1071\le a_i\le10^7.
  • Subtask 3 (50 points): 1≤n≤2000001\le n\le 200000, k=0k=0, 1≤ai≤1071\le a_i\le10^7.

Example

Input

5 0
18 6 2 4 1

Output

3

Explanation

An optimal partition is [18,6][18,6], [2,4][2,4], [1][1]: no segment contains two equal square-free kernels.