#include <bits/stdc++.h>
using namespace std;
void read_file(bool outToFile = true) {}
int n, T;
vector<int> A;
vector<int> build(int b) {
  vector<int> ret(b * n);
  for (int i = 0; i < b; i++)
    for (int j = 0; j < n; j++) ret[i * n + j] = A[j];
  return ret;
}
vector<int> LIS(vector<int> B) {
  vector<int> ret(B.size());
  ret[0] = 1;
  int sz = B.size();
  for (int i = 1; i < sz; i++) {
    ret[i] = 1;
    for (int j = 0; j < i; j++)
      if (B[j] <= B[i]) ret[i] = max(ret[i], 1 + ret[j]);
  }
  return ret;
}
vector<int> LDS(vector<int> B) {
  int sz = B.size();
  vector<int> dp(sz);
  dp[sz - 1] = 1;
  for (int i = sz - 2; i >= 0; i--) {
    dp[i] = 1;
    for (int j = sz - 1; j > i; j--)
      if (B[i] <= B[j]) dp[i] = max(dp[i], 1 + dp[j]);
  }
  return dp;
}
void debug(vector<int> A) {
  int sz = A.size();
  for (int i = 0; i < sz; i++) cout << A[i] << " \n"[i == sz - 1];
}
int main() {
  read_file();
  while (scanf("%d%d", &n, &T) != EOF) {
    A.resize(n);
    for (int i = 0; i < n; i++) scanf("%d", &A[i]);
    if (T <= 2 * n) {
      A = build(T);
      A = LIS(A);
      int ans = *max_element(((A).begin()), ((A).end()));
      printf("%d\n", ans);
    } else {
      A = build(n);
      vector<int> L = LIS(A);
      vector<int> R = LDS(A);
      int ans = 0;
      for (int i = 0; i < n; i++) {
        int cnt = 0;
        for (int j = 0; j < n; j++) cnt += A[i] == A[j];
        for (int j = 0; j < n; j++) {
          if (A[i] > A[j]) continue;
          ans = max(ans, L[n * (n - 1) + i] + cnt * (T - 2 * n) + R[j]);
        }
      }
      printf("%d\n", ans);
    }
  }
}
