#include <bits/stdc++.h>
using namespace std;
int n, t;
int a[10010];
map<int, int> calc;
int wow;
int LIS() {
  int len = 0;
  int d[10010];
  d[len] = -0x7fffffff;
  for (int i = 1; i <= wow; i++) {
    if (d[len] <= a[i])
      d[++len] = a[i];
    else {
      int mid = upper_bound(d + 1, d + 1 + len, a[i]) - d;
      d[mid] = a[i];
    }
  }
  return len;
}
int main() {
  cin >> n >> t;
  for (int i = 1; i <= n; i++) cin >> a[i];
  if (t < n) {
    for (int i = 1; i < t; i++)
      for (int j = 1; j <= n; j++) a[i * n + j] = a[j];
    wow = n * t;
    cout << LIS();
  } else {
    for (int i = 1; i < n; i++)
      for (int j = 1; j <= n; j++) a[i * n + j] = a[j];
    wow = n * n;
    int sth = LIS();
    int maxi = 0, num;
    for (int i = 1; i <= n; i++) calc[a[i]]++;
    for (map<int, int>::iterator i = calc.begin(); i != calc.end(); i++)
      maxi = max(maxi, i->second);
    cout << sth + maxi * (t - n);
  }
  return 0;
}
