#include <bits/stdc++.h>
using namespace std;
int n, t;
int a[1000];
int b[30000];
int dp[21000][200];
int p[21000][200];
int was[1000];
int c = 1;
int MX = 110;
int cnt[1000];
int cnt1[1000];
void findAns(int i, int need, vector<int>& ans) {
  if (dp[i][need] == 0) return;
  if (b[i] == need) {
    findAns(i - 1, p[i][need], ans);
    ans.push_back(i);
  } else {
    findAns(i - 1, need, ans);
  }
}
int to[1000];
int main() {
  scanf("%d%d", &n, &t);
  vector<int> tmp;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    tmp.push_back(a[i]);
  }
  sort(tmp.begin(), tmp.end());
  for (int i = 0; i < tmp.size(); ++i) {
    if (!was[tmp[i]]) was[tmp[i]] = c++;
    to[tmp[i]] = was[tmp[i]];
  }
  for (int i = 0; i < n; ++i) {
    a[i] = to[a[i]];
    cnt[a[i]]++;
  }
  int t1 = min(t, 200);
  for (int i = 0; i < t1 * n; ++i) b[i] = a[i % n];
  dp[0][b[0]] = 1;
  for (int i = 1; i < t1 * n; ++i) {
    for (int was = 0; was < MX; ++was) {
      dp[i][was] = dp[i - 1][was];
      p[i][was] = p[i - 1][was];
    }
    for (int was = 0; was <= b[i]; ++was) {
      if (dp[i][b[i]] < dp[i - 1][was] + 1) {
        dp[i][b[i]] = dp[i - 1][was] + 1;
        p[i][b[i]] = was;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < MX; ++i)
    if (dp[t1 * n - 1][ans] < dp[t1 * n - 1][i]) ans = i;
  if (t <= 200) {
    printf("%d\n", dp[t1 * n - 1][ans]);
    return 0;
  }
  vector<int> e;
  findAns(t1 * n - 1, ans, e);
  int total = 0;
  for (int i = 1; i < e.size(); ++i) {
    if (e[i] / n != e[i - 1] / n) ++total;
  }
  total++;
  for (int i = 0; i < e.size(); ++i) {
    cnt1[b[e[i]]]++;
  }
  int mx = 0;
  for (int i = 0; i < MX; ++i)
    if (cnt1[mx] < cnt1[i]) mx = i;
  printf("%d\n", dp[t1 * n - 1][ans] + (t - total) * cnt[mx]);
  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, t;
int a[1000];
int b[30000];
int dp[21000][200];
int p[21000][200];
int was[1000];
int c = 1;
int MX = 110;
int cnt[1000];
int cnt1[1000];
void findAns(int i, int need, vector<int>& ans) {
  if (dp[i][need] == 0) return;
  if (b[i] == need) {
    findAns(i - 1, p[i][need], ans);
    ans.push_back(i);
  } else {
    findAns(i - 1, need, ans);
  }
}
int to[1000];
int main() {
  scanf("%d%d", &n, &t);
  vector<int> tmp;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    tmp.push_back(a[i]);
  }
  sort(tmp.begin(), tmp.end());
  for (int i = 0; i < tmp.size(); ++i) {
    if (!was[tmp[i]]) was[tmp[i]] = c++;
    to[tmp[i]] = was[tmp[i]];
  }
  for (int i = 0; i < n; ++i) {
    a[i] = to[a[i]];
    cnt[a[i]]++;
  }
  int t1 = min(t, 200);
  for (int i = 0; i < t1 * n; ++i) b[i] = a[i % n];
  dp[0][b[0]] = 1;
  for (int i = 1; i < t1 * n; ++i) {
    for (int was = 0; was < MX; ++was) {
      dp[i][was] = dp[i - 1][was];
      p[i][was] = p[i - 1][was];
    }
    for (int was = 0; was <= b[i]; ++was) {
      if (dp[i][b[i]] < dp[i - 1][was] + 1) {
        dp[i][b[i]] = dp[i - 1][was] + 1;
        p[i][b[i]] = was;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < MX; ++i)
    if (dp[t1 * n - 1][ans] < dp[t1 * n - 1][i]) ans = i;
  if (t <= 200) {
    printf("%d\n", dp[t1 * n - 1][ans]);
    return 0;
  }
  vector<int> e;
  findAns(t1 * n - 1, ans, e);
  int total = 0;
  for (int i = 1; i < e.size(); ++i) {
    if (e[i] / n != e[i - 1] / n) ++total;
  }
  total++;
  for (int i = 0; i < e.size(); ++i) {
    cnt1[b[e[i]]]++;
  }
  int mx = 0;
  for (int i = 0; i < MX; ++i)
    if (cnt1[mx] < cnt1[i]) mx = i;
  printf("%d\n", dp[t1 * n - 1][ans] + (t - total) * cnt[mx]);
  return 0;
}

```