#include <bits/stdc++.h>
using namespace std;
const int MAXN = 40010;
const int INF = 0x3f3f3f3f;
int n;
int nn, tt;
int A[MAXN], S[MAXN];
int d[MAXN];
int times[400];
void init() {
  for (int i = 1; i <= n; i++) S[i] = INF;
  memset(d, 0, sizeof(d));
}
int BSearch(int x, int y, int v) {
  while (x <= y) {
    int mid = x + (y - x) / 2;
    if (S[mid] <= v)
      x = mid + 1;
    else
      y = mid - 1;
  }
  return x;
}
int dp() {
  init();
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int x = 1, y = i;
    int pos = BSearch(x, y, A[i]);
    d[i] = pos;
    S[d[i]] = min(S[d[i]], A[i]);
    ans = max(ans, d[i]);
  }
  return ans;
}
int main() {
  scanf("%d%d", &nn, &tt);
  if (tt <= nn) {
    n = nn * tt;
    for (int i = 1; i <= nn; i++) scanf("%d", &A[i]);
    for (int i = 2; i <= tt; i++)
      for (int j = 1; j <= nn; j++) A[(i - 1) * nn + j] = A[j];
    cout << dp();
  } else {
    n = nn * nn;
    for (int i = 1; i <= nn; i++) scanf("%d", &A[i]);
    for (int i = 2; i <= nn; i++)
      for (int j = 1; j <= nn; j++) A[(i - 1) * nn + j] = A[j];
    int ans1 = dp();
    memset(times, 0, sizeof(times));
    int max_times = 0;
    for (int i = 1; i <= nn; i++) times[A[i]]++;
    for (int i = 1; i <= 300; i++) max_times = max(max_times, times[i]);
    cout << (long long)ans1 + (long long)max_times * (long long)(tt - nn);
  }
  return 0;
}
