#include <bits/stdc++.h>
using namespace std;
int v[130];
int n;
long long t;
long long ans[130][130];
int at[130];
long long pdE[130][130], pdD[130][130];
int cnt;
void comprimi() {
  map<int, int> mapa;
  set<int> S;
  for (int i = 0; i < n; i++) {
    S.insert(v[i]);
  }
  cnt = 0;
  for (set<int>::iterator it = S.begin(); it != S.end(); it++) {
    mapa[*it] = cnt++;
  }
  for (int i = 0; i < n; i++) v[i] = mapa[v[i]];
}
long long solveE(int pos, int sz) {
  if (sz == 0 || pos == 0) return 0;
  long long& ret = pdE[pos][sz];
  if (ret != -1) return ret;
  ret = solveE(pos - 1, sz);
  for (int i = pos - 1; i >= 0; i--)
    ret = max(ret, ans[i][pos] + solveE(i, sz - 1));
  return ret;
}
long long solveD(int pos, int sz) {
  if (sz == 0 || pos == n - 1) return 0;
  long long& ret = pdD[pos][sz];
  if (ret != -1) return ret;
  ret = solveD(pos + 1, sz);
  for (int i = pos + 1; i < n; i++)
    ret = max(ret, ans[pos][i] + solveD(i, sz - 1));
  return ret;
}
int main() {
  cin >> n >> t;
  for (int i = 0; i < n; i++) cin >> v[i];
  comprimi();
  for (int i = 0; i < n; i++) {
    int sz = 0;
    memset(at, 0, sizeof at);
    at[i] = 1;
    ans[v[i]][v[i]] = max(ans[v[i]][v[i]], 1LL);
    for (int j = i + 1; j < n; j++) {
      for (int k = i; k < j; k++) {
        if (v[j] >= v[k] && at[k]) at[j] = max(at[j], 1 + at[k]);
      }
      ans[v[i]][v[j]] = max(ans[v[i]][v[j]], (long long)at[j]);
    }
  }
  long long r = 0;
  memset(pdE, -1, sizeof pdE);
  memset(pdD, -1, sizeof pdD);
  for (int i = 0; i < n; i++) {
    for (int sz = 0; sz <= n; sz++) {
      for (int sz2 = 0; sz2 <= n; sz2++) {
        if (sz + sz2 > t) continue;
        long long ret = solveE(i, sz) + solveD(i, sz2) +
                        (long long)(t - sz - sz2) * ans[i][i];
        r = max(r, ret);
      }
    }
  }
  cout << r << endl;
  return 0;
}

### Prompt

Please formulate 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 v[130];
int n;
long long t;
long long ans[130][130];
int at[130];
long long pdE[130][130], pdD[130][130];
int cnt;
void comprimi() {
  map<int, int> mapa;
  set<int> S;
  for (int i = 0; i < n; i++) {
    S.insert(v[i]);
  }
  cnt = 0;
  for (set<int>::iterator it = S.begin(); it != S.end(); it++) {
    mapa[*it] = cnt++;
  }
  for (int i = 0; i < n; i++) v[i] = mapa[v[i]];
}
long long solveE(int pos, int sz) {
  if (sz == 0 || pos == 0) return 0;
  long long& ret = pdE[pos][sz];
  if (ret != -1) return ret;
  ret = solveE(pos - 1, sz);
  for (int i = pos - 1; i >= 0; i--)
    ret = max(ret, ans[i][pos] + solveE(i, sz - 1));
  return ret;
}
long long solveD(int pos, int sz) {
  if (sz == 0 || pos == n - 1) return 0;
  long long& ret = pdD[pos][sz];
  if (ret != -1) return ret;
  ret = solveD(pos + 1, sz);
  for (int i = pos + 1; i < n; i++)
    ret = max(ret, ans[pos][i] + solveD(i, sz - 1));
  return ret;
}
int main() {
  cin >> n >> t;
  for (int i = 0; i < n; i++) cin >> v[i];
  comprimi();
  for (int i = 0; i < n; i++) {
    int sz = 0;
    memset(at, 0, sizeof at);
    at[i] = 1;
    ans[v[i]][v[i]] = max(ans[v[i]][v[i]], 1LL);
    for (int j = i + 1; j < n; j++) {
      for (int k = i; k < j; k++) {
        if (v[j] >= v[k] && at[k]) at[j] = max(at[j], 1 + at[k]);
      }
      ans[v[i]][v[j]] = max(ans[v[i]][v[j]], (long long)at[j]);
    }
  }
  long long r = 0;
  memset(pdE, -1, sizeof pdE);
  memset(pdD, -1, sizeof pdD);
  for (int i = 0; i < n; i++) {
    for (int sz = 0; sz <= n; sz++) {
      for (int sz2 = 0; sz2 <= n; sz2++) {
        if (sz + sz2 > t) continue;
        long long ret = solveE(i, sz) + solveD(i, sz2) +
                        (long long)(t - sz - sz2) * ans[i][i];
        r = max(r, ret);
      }
    }
  }
  cout << r << endl;
  return 0;
}

```