#include <bits/stdc++.h>
using namespace std;
int n, m, T;
int dp1[1234567];
int dp2[1234567];
int a[1234567];
int Rmax[555];
int d[555];
int Td[555];
void update(int x, int val) {
  while (x <= 300) {
    Td[x] = max(Td[x], val);
    x = x + (x & (x ^ (x - 1)));
  }
}
int get(int x) {
  int ans = 0;
  while (x > 0) {
    ans = max(ans, Td[x]);
    x = x - (x & (x ^ (x - 1)));
  }
  return ans;
}
void update2(int x, int val) {
  while (x > 0) {
    Td[x] = max(Td[x], val);
    x = x - (x & (x ^ (x - 1)));
  }
}
int get2(int x) {
  int ans = 0;
  while (x <= 300) {
    ans = max(ans, Td[x]);
    x = x + (x & (x ^ (x - 1)));
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> T;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    d[a[i]]++;
  }
  if (T <= 20000) {
    int ans = 0;
    m = T * n;
    for (int i = n + 1; i <= m; i++) a[i] = a[i - n];
    for (int i = 1; i <= m; i++) {
      dp1[i] = get(a[i]) + 1;
      update(a[i], dp1[i]);
      ans = max(ans, dp1[i]);
    }
    cout << ans << "\n";
  } else {
    int ans = 0;
    m = n * 10000;
    for (int i = n + 1; i <= m; i++) a[i] = a[i - n];
    for (int i = m; i >= 1; i--) {
      dp2[i] = get2(a[i]) + 1;
      update2(a[i], dp2[i]);
      Rmax[a[i]] = max(Rmax[a[i]], dp2[i]);
    }
    memset(Td, 0, sizeof(Td));
    for (int i = 1; i <= m; i++) {
      dp1[i] = get(a[i]) + 1;
      ans = max(ans, dp1[i] + (T - 20000) * d[a[i]] + Rmax[a[i]]);
      update(a[i], dp1[i]);
    }
    cout << ans;
  }
  return 0;
}

### Prompt

In cpp, your task is to solve 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 n, m, T;
int dp1[1234567];
int dp2[1234567];
int a[1234567];
int Rmax[555];
int d[555];
int Td[555];
void update(int x, int val) {
  while (x <= 300) {
    Td[x] = max(Td[x], val);
    x = x + (x & (x ^ (x - 1)));
  }
}
int get(int x) {
  int ans = 0;
  while (x > 0) {
    ans = max(ans, Td[x]);
    x = x - (x & (x ^ (x - 1)));
  }
  return ans;
}
void update2(int x, int val) {
  while (x > 0) {
    Td[x] = max(Td[x], val);
    x = x - (x & (x ^ (x - 1)));
  }
}
int get2(int x) {
  int ans = 0;
  while (x <= 300) {
    ans = max(ans, Td[x]);
    x = x + (x & (x ^ (x - 1)));
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> T;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    d[a[i]]++;
  }
  if (T <= 20000) {
    int ans = 0;
    m = T * n;
    for (int i = n + 1; i <= m; i++) a[i] = a[i - n];
    for (int i = 1; i <= m; i++) {
      dp1[i] = get(a[i]) + 1;
      update(a[i], dp1[i]);
      ans = max(ans, dp1[i]);
    }
    cout << ans << "\n";
  } else {
    int ans = 0;
    m = n * 10000;
    for (int i = n + 1; i <= m; i++) a[i] = a[i - n];
    for (int i = m; i >= 1; i--) {
      dp2[i] = get2(a[i]) + 1;
      update2(a[i], dp2[i]);
      Rmax[a[i]] = max(Rmax[a[i]], dp2[i]);
    }
    memset(Td, 0, sizeof(Td));
    for (int i = 1; i <= m; i++) {
      dp1[i] = get(a[i]) + 1;
      ans = max(ans, dp1[i] + (T - 20000) * d[a[i]] + Rmax[a[i]]);
      update(a[i], dp1[i]);
    }
    cout << ans;
  }
  return 0;
}

```