#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:16777216")
const double EPS = 1e-5;
const int INF = INT_MAX;
const long long MOD = 1e18;
const long double PI = atan2((long double)0, (long double)-1);
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
void solveС() {
  int n;
  cin >> n;
  vector<int> a(n * n);
  map<int, int> m;
  for (int i = 0; i < n * n; ++i) {
    cin >> a[i];
    m[a[i]]++;
  }
  set<int> s;
  for (int i = 0; i < n * n; ++i) {
    if (s.find(a[i]) == s.end())
      s.insert(a[i]);
    else
      s.erase(a[i]);
  }
  vector<int> b(s.begin(), s.end());
  for (int i = 0; i < b.size(); ++i)
    for (int j = 0; j < b.size(); ++j) m[gcd(b[i], b[j])]--;
  for (map<int, int>::iterator iter = m.begin(); iter != m.end(); ++iter)
    if (iter->second > 0) {
      int k = 1;
      while (k * k < iter->second) k++;
      for (int j = 0; j < k; ++j) b.push_back(iter->first);
    }
  for (int i = 0; i < b.size(); ++i) cout << b[i] << ' ';
}
void solveD() {
  int n, t;
  cin >> n >> t;
  int nn = n * n;
  vector<int> a(2 * nn);
  map<int, int> m;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    for (int j = i + n; j < 2 * nn; j += n) a[j] = a[i];
    m[a[i]]++;
  }
  vector<int> d(2 * nn);
  d[0] = 1;
  int bestRes = 0;
  for (int i = 1; i < 2 * nn; ++i) {
    d[i] = 1;
    ;
    for (int j = max(i - n, 0); j < i; ++j)
      if (a[j] <= a[i]) d[i] = max(d[i], d[j] + 1);
  }
  vector<int> rd(nn);
  rd[nn - 1] = 1;
  for (int i = nn - 1; i >= 0; --i) {
    rd[i] = 1;
    for (int j = min(nn - 1, i + n); j > i; --j)
      if (a[j] >= a[i]) rd[i] = max(rd[i], rd[j] + 1);
  }
  if (t <= 2 * n) {
    for (int i = 0; i < t * n; ++i) bestRes = max(bestRes, d[i]);
  } else {
    for (int i = 0; i < n; ++i) {
      int curRes = d[nn - n + i] + rd[i] + m[a[i]] * (t - 2 * n + 1) - 1;
      bestRes = max(bestRes, curRes);
    }
  }
  cout << bestRes << endl;
}
int main() {
  solveD();
  return 0;
}
