#include <bits/stdc++.h>
using namespace std;
int n, T;
int s1[10101];
int dp[1010101];
int dp2[1101014];
int dp3[1000110];
int main() {
  scanf("%d%d", &n, &T);
  for (register int i = 1; i <= n; i++) scanf("%d", &s1[i]), dp[s1[i]]++;
  for (register int i = 1; i <= n * n; i++) s1[i] = s1[(i - 1) % n + 1];
  int l = n * min(n, T);
  for (register int i = 1; i <= l; i++) {
    int flag = 0;
    for (register int j = 0; j < i; j++)
      if (s1[j] <= s1[i]) flag = max(flag, dp3[j]);
    dp3[i] = flag + 1;
  }
  for (register int i = l; i >= 1; i--) {
    int flag = 0;
    for (register int j = l + 1; j > i; j--)
      if (s1[j] >= s1[i]) flag = max(flag, dp2[j]);
    dp2[i] = flag + 1;
  }
  int ans = 0;
  if (T <= n)
    for (register int i = 1; i <= l; i++) ans = max(ans, dp3[i] + dp2[i] - 1);
  else
    for (register int i = 1; i <= l; i++)
      ans = max(ans, dp3[i] + dp2[i] - 1 + dp[s1[i]] * (T - n));
  printf("%d", ans);
  return 0;
}
