#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t;
  cin >> n >> t;
  vector<int> a(100 * n);
  map<int, int> c;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    c[a[i]]++;
  }
  for (int i = 0; i < 99 * n; i++) a[i + n] = a[i];
  int d[100 * n], dd[100 * n];
  for (int i = 0; i < 100 * n; i++) {
    d[i] = 0;
    dd[i] = 0;
  }
  for (int i = 0; i < 100 * n; i++) {
    int m = 0;
    for (int j = 0; j < i; j++)
      if (a[j] <= a[i]) m = max(m, d[j] + 1);
    d[i] = max(1, m);
  }
  for (int i = 100 * n - 1; i >= 0; i--) {
    int m = 0;
    for (int j = 100 * n - 1; j > i; j--)
      if (a[j] >= a[i]) m = max(m, dd[j] + 1);
    dd[i] = max(1, m);
  }
  if (t < 100) {
    int ans = 0;
    for (int i = 0; i < t * n; i++) ans = max(ans, d[i]);
    cout << ans << endl;
    return 0;
  }
  int ans = 0;
  for (int i = 0; i < 100 * n; i++) {
    int anstmp = 0;
    anstmp += c[a[i]] * (t - 100);
    anstmp += dd[i] + d[i] - 1;
    ans = max(ans, anstmp);
  }
  cout << ans << endl;
  return 0;
}
