#arc150f. [arc150_f]Constant Sum Subsequence

[arc150_f]Constant Sum Subsequence

Problem Statement

We have a sequence of positive integers of length N2N^2, A=(A1,A2,dots,AN2)A=(A_1,\\ A_2,\\ \\dots,\\ A_{N^2}), and a positive integer SS. For this sequence of positive integers, Ai=Ai+NA_i=A_{i+N} holds for positive integers i(1leqileqN2N)i\\ (1\\leq i \\leq N^2-N), and only A1,A2,dots,ANA_1,\\ A_2,\\ \\dots,\\ A_N are given as the input.

Find the minimum integer LL such that every sequence BB of positive integers totaling SS is a (not necessarily contiguous) subsequence of the sequence (A1,A2,dots,AL)(A_1,\\ A_2,\\ \\dots,\\ A_L) of positive integers.

It can be shown that at least one such LL exists under the Constraints of this problem.

Constraints

  • 1leqNleq1.5times1061 \\leq N \\leq 1.5 \\times 10^6
  • 1leqSleqmin(N,2times105)1 \\leq S \\leq \\min(N,2 \\times 10^5)
  • 1leqAileqS1 \\leq A_i \\leq S
  • For every positive integer x(1leqxleqS)x\\ (1\\leq x \\leq S), (A1,A2,dots,AN)(A_1,\\ A_2,\\ \\dots,\\ A_N) contains at least one occurrence of xx.
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

NN SS A1A_1 A2A_2 dots\\dots ANA_N

Output

Print the answer.


Sample Input 1

6 4
1 1 2 1 4 3

Sample Output 1

9

There are eight sequences BB to consider: $B=(1,\\ 1,\\ 1,\\ 1),\\ (1,\\ 1,\\ 2),\\ (1,\\ 2,\\ 1),\\ (1,\\ 3),\\ (2,\\ 1,\\ 1),\\ (2,\\ 2),\\ (3,\\ 1),\\ (4)$.

For L=8L=8, for instance, B=(2,2)B=(2,\\ 2) is not a subsequence of $(A_1,A_2,\\ \\dots,\\ A_8)=(1,\\ 1,\\ 2,\\ 1,\\ 4,\\ 3,\\ 1,\\ 1)$.

For L=9L=9, on the other hand, every BB is a subsequence of $(A_1,A_2,\\ \\dots,\\ A_9)=(1,\\ 1,\\ 2,\\ 1,\\ 4,\\ 3,\\ 1,\\ 1,\\ 2)$.


Sample Input 2

14 5
1 1 1 2 3 1 2 4 5 1 1 2 3 1

Sample Output 2

11

Sample Input 3

19 10
1 6 2 7 4 8 5 9 1 10 4 1 3 1 3 2 2 2 1

Sample Output 3

39