#include <bits/stdc++.h>
using namespace std;
int n, T, ck[301], fi[20010], se[20010];
vector<int> v, tmp;
int getLIS(int idx, int arr[]) {
  vector<int> L(tmp.size() + 1, 500);
  L[0] = -2e9;
  int len = -1;
  for (int i = 0; i <= idx; i++) {
    int pi = upper_bound(L.begin(), L.end(), tmp[i]) - L.begin();
    L[pi] = tmp[i];
    len = max(len, pi);
    arr[i] = pi;
  }
  return len;
}
int main() {
  scanf("%d%d", &n, &T);
  v = vector<int>(n);
  for (int i = 0; i < n; i++) scanf("%d", &v[i]), ck[v[i]]++;
  if (T <= 2 * n) {
    for (int ite = 1; ite <= T; ite++) {
      tmp.insert(tmp.end(), v.begin(), v.end());
    }
    printf("%d\n", getLIS(tmp.size() - 1, fi));
  } else {
    for (int ite = 1; ite <= n; ite++) {
      tmp.insert(tmp.end(), v.begin(), v.end());
    }
    int maxi = -1;
    getLIS(tmp.size() - 1, fi);
    for (int i = 0; i < tmp.size(); i++) tmp[i] = -tmp[i];
    reverse(tmp.begin(), tmp.end());
    getLIS(tmp.size() - 1, se);
    reverse(se, se + tmp.size());
    for (int i = 0; i < v.size(); i++) {
      for (int j = 0; j < v.size(); j++) {
        if (v[i] <= v[j]) {
          maxi =
              max(maxi, fi[(n - 1) * n + i] + ck[v[i]] * (T - 2 * n) + se[j]);
        }
      }
    }
    printf("%d\n", maxi);
  }
}
