#include <bits/stdc++.h>
using namespace std;
int a[20000], num[20000];
int dp[400];
int n, m, t, k, ans, maxm;
int main() {
  scanf("%d%d", &n, &m);
  maxm = 0;
  ans = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    num[a[i]]++;
    maxm = max(maxm, num[a[i]]);
  }
  t = min(n, m);
  k = t;
  int temp = 0;
  while (--k) {
    temp += n;
    for (int i = 1; i <= n; i++) a[temp + i] = a[i];
  }
  for (int i = 1; i <= n * t; i++) {
    dp[a[i]]++;
    for (int j = a[i] - 1; j >= 0; j--) dp[a[i]] = max(dp[a[i]], dp[j] + 1);
    ans = max(dp[a[i]], ans);
  }
  ans += maxm * (m - t);
  printf("%d\n", ans);
  return 0;
}
