#include <bits/stdc++.h>
using namespace std;
template <typename T>
using Mat = vector<vector<T>>;
using ll = long long;
using VI = vector<int>;
using VVI = Mat<int>;
using P = pair<int, int>;
int lis(const VI& v) {
  VI res;
  for (int i : v) {
    auto it = upper_bound(res.begin(), res.end(), i);
    if (it == res.end())
      res.push_back(i);
    else
      *it = i;
  }
  return res.size();
}
VI copy(const VI& v, int t) {
  int n = v.size();
  VI w(t * n);
  for (int i = 0; i < t; ++i) {
    for (int j = 0; j < n; ++j) w[i * n + j] = v[j];
  }
  return std::move(w);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, t;
  cin >> n >> t;
  VI v(n);
  for (int& i : v) cin >> i;
  if (t <= 1000) {
    VI w = copy(v, t);
    cout << lis(w) << endl;
    return 0;
  }
  int sol = t;
  VI w = copy(v, 100);
  for (int i : v) {
    int count = 0;
    VI less, more;
    int p = n - 1;
    while (v[p] != i) --p;
    for (int j = p + 1; j < n; ++j) {
      if (v[j] >= i) more.push_back(v[j]);
    }
    for (int k : w) {
      if (k <= i) less.push_back(k);
      if (k >= i) more.push_back(k);
    }
    for (int k : v)
      if (k == i) ++count;
    for (int k : v) {
      if (k == i) break;
      if (k <= i) less.push_back(k);
    }
    sol = max(sol, lis(less) + (t - 200) * count + lis(more));
  }
  cout << sol << endl;
}
