#P1360. Balanced Ability Increase Period

    ID: 14647 Type: Default 1000ms 256MiB

Balanced Ability Increase Period

Balanced Ability Increase Period

The mystical EntropyIncreaser possesses m abilities numbered from 1 to m. Each day, some abilities are incremented. The increment of a day is represented by an integer. When this integer is converted to binary, reading from right to left the position of 1 bits indicates which abilities are increased. For example, the number \(13\) in decimal becomes \(1101_2\) in binary; reading from right to left means that abilities \(1\), \(3\), and \(4\) are incremented by one.

A balanced period is defined as a consecutive sequence of days during which every ability is increased the same number of times. For instance, if over a span of 5 consecutive days each ability is incremented 4 times, this interval is considered a balanced period of length 5.

You are given the increment numbers for n days. Your task is to determine the maximum length of a balanced period.

Note: Only the lowest m bits of the day's number are considered. If a number's binary representation has fewer than m bits, the missing higher bits are taken as 0.

inputFormat

The first line contains two integers \(n\) and \(m\), where \(n\) is the number of days and \(m\) is the total number of abilities.

The second line contains \(n\) space-separated non-negative integers representing the daily ability increase numbers.

outputFormat

Output a single integer representing the maximum length of a balanced period.

sample

5 3
7 1 2 4 3
4