#include <bits/stdc++.h>
using namespace std;
const int INF = numeric_limits<int>::max();
int n;
vector<int> d, a;
int get_longest(int l) {
  vector<int> d;
  while (l > a.size())
    for (int i = 0; i < n; ++i) a.push_back(a[i]);
  d.assign(l + 10, INF);
  d[0] = -INF;
  for (int i = 0; i < l; ++i) {
    int j = int(upper_bound(d.begin(), d.end(), a[i]) - d.begin());
    if (d[j - 1] <= a[i] && a[i] < d[j]) d[j] = a[i];
  }
  for (int i = 1; i <= l; ++i)
    if (d[i] == INF) return i - 1;
  return l;
}
int main() {
  int t;
  int longest_same = 1;
  vector<int> b;
  scanf("%d %d", &n, &t);
  a.assign(n, 0);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  b.assign(a.begin(), a.end());
  sort(b.begin(), b.end());
  map<int, int> new_val;
  int longest = 1;
  for (int i = 0; i < n; ++i) {
    if (i > 0 && b[i] == b[i - 1])
      ++longest;
    else {
      if (longest > longest_same) longest_same = longest;
      longest = 1;
    }
    if (i == 0 || b[i] != b[i - 1]) new_val[b[i]] = i;
  }
  if (longest > longest_same) longest_same = longest;
  for (int i = 0; i < n; ++i) {
  }
  longest = get_longest(n);
  int next_longest, prev_longest;
  int d = INF;
  int k = 1;
  while (d > longest_same && k < t) {
    ++k;
    next_longest = get_longest(k * n);
    d = next_longest - longest;
    prev_longest = longest;
    longest = next_longest;
  }
  if (d <= longest_same) {
    longest = prev_longest + (t - k + 1) * longest_same;
  }
  printf("%d\n", longest);
  return 0;
}
