#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long dx[] = {-1, 0, 1, 0};
long long dy[] = {0, -1, 0, 1};
long long dp[1000007];
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, t;
  cin >> n >> t;
  long long x = min(n, t);
  t -= x;
  long long ans = 0;
  vector<long long> v(n);
  map<long long, long long> mp;
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
    mp[v[i]]++;
  }
  long long mx = 0;
  for (auto i : mp) {
    mx = max(mx, i.second);
  }
  ans += t * mx;
  for (long long i = 0; i < x - 1; i++) {
    for (long long j = 0; j < n; j++) {
      v.push_back(v[j]);
    }
  }
  long long p = v.size();
  fill(dp, dp + p, 1);
  for (long long i = 1; i < v.size(); i++) {
    long long cnt = 0;
    for (long long j = 0; j < i; j++) {
      if (v[j] <= v[i]) cnt = max(cnt, dp[j]);
    }
    dp[i] = max(dp[i], cnt + 1);
  }
  long long val = 0;
  for (long long i = 0; i < p; i++) {
    val = max(val, dp[i]);
  }
  ans += val;
  cout << ans << "\n";
}
