#include <bits/stdc++.h>
using namespace std;
int LIS(vector<int> &A) {
  int n = A.size();
  vector<int> tail;
  tail.push_back(A[0]);
  for (int i = 1; i < n; i++) {
    if (A[i] < tail[0]) {
      tail[0] = A[i];
    } else if (A[i] >= tail[tail.size() - 1]) {
      tail.push_back(A[i]);
    } else {
      int l = 0;
      int r = tail.size();
      while (r - l > 1) {
        int c = (l + r) / 2;
        if (tail[c] > A[i]) {
          r = c;
        } else {
          l = c;
        }
      }
      tail[r] = A[i];
    }
  }
  return tail.size();
}
int main() {
  int N, T;
  cin >> N >> T;
  std::vector<int> A;
  for (int i = 0; i < N; i++) {
    int temp;
    cin >> temp;
    A.push_back(temp);
  }
  if (T < 1000) {
    for (int i = 1; i < T; i++) {
      for (int j = 0; j < N; j++) {
        A.push_back(A[j]);
      }
    }
    cout << LIS(A) << endl;
  } else {
    for (int i = 1; i < 1000; i++) {
      for (int j = 0; j < N; j++) {
        A.push_back(A[j]);
      }
    }
    int lis1000 = LIS(A);
    for (int j = 0; j < N; j++) {
      A.push_back(A[j]);
    }
    int d = LIS(A) - lis1000;
    cout << lis1000 + (T - 1000) * d << endl;
  }
  return 0;
}

### Prompt

Your challenge is to write a CPP solution to the following problem:

You are given an array of positive integers a1, a2, ..., an × T of length n × T. We know that for any i > n it is true that ai = ai - n. Find the length of the longest non-decreasing sequence of the given array.

Input

The first line contains two space-separated integers: n, T (1 ≤ n ≤ 100, 1 ≤ T ≤ 107). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 300).

Output

Print a single number — the length of a sought sequence.

Examples

Input

4 3
3 1 4 2


Output

5

Note

The array given in the sample looks like that: 3, 1, 4, 2, 3, 1, 4, 2, 3, 1, 4, 2. The elements in bold form the largest non-decreasing subsequence. 

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int LIS(vector<int> &A) {
  int n = A.size();
  vector<int> tail;
  tail.push_back(A[0]);
  for (int i = 1; i < n; i++) {
    if (A[i] < tail[0]) {
      tail[0] = A[i];
    } else if (A[i] >= tail[tail.size() - 1]) {
      tail.push_back(A[i]);
    } else {
      int l = 0;
      int r = tail.size();
      while (r - l > 1) {
        int c = (l + r) / 2;
        if (tail[c] > A[i]) {
          r = c;
        } else {
          l = c;
        }
      }
      tail[r] = A[i];
    }
  }
  return tail.size();
}
int main() {
  int N, T;
  cin >> N >> T;
  std::vector<int> A;
  for (int i = 0; i < N; i++) {
    int temp;
    cin >> temp;
    A.push_back(temp);
  }
  if (T < 1000) {
    for (int i = 1; i < T; i++) {
      for (int j = 0; j < N; j++) {
        A.push_back(A[j]);
      }
    }
    cout << LIS(A) << endl;
  } else {
    for (int i = 1; i < 1000; i++) {
      for (int j = 0; j < N; j++) {
        A.push_back(A[j]);
      }
    }
    int lis1000 = LIS(A);
    for (int j = 0; j < N; j++) {
      A.push_back(A[j]);
    }
    int d = LIS(A) - lis1000;
    cout << lis1000 + (T - 1000) * d << endl;
  }
  return 0;
}

```