#include <bits/stdc++.h>
using namespace std;
const int N = 130;
int a[N], n, t, f[N][N], g[N][N], tmp[N], get_f[N][N], get_g[N][N];
int main() {
  cin >> n >> t;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  a[0] = 0;
  a[n + 1] = 10000;
  for (int i = 0; i <= n + 1; i++)
    for (int j = 0; j <= n + 1; j++) {
      get_f[i][j] = 0;
      for (int k = 1; k <= n; k++)
        if (a[k] >= a[i] && a[k] <= a[j]) {
          tmp[k] = 1;
          for (int p = 1; p < k; p++)
            if (a[p] >= a[i] && a[p] <= a[k]) tmp[k] = max(tmp[k], tmp[p] + 1);
          get_f[i][j] = max(get_f[i][j], tmp[k]);
        }
    }
  for (int i = 0; i <= n + 1; i++)
    for (int j = 0; j <= n + 1; j++) {
      get_g[i][j] = 0;
      for (int k = n; k >= 1; k--)
        if (a[k] >= a[i] && a[k] <= a[j]) {
          tmp[k] = 1;
          for (int p = k + 1; p <= n; p++)
            if (a[p] >= a[k] && a[p] <= a[j]) tmp[k] = max(tmp[k], tmp[p] + 1);
          get_g[i][j] = max(get_g[i][j], tmp[k]);
        }
    }
  for (int j = 0; j <= n + 1; j++) {
    f[0][j] = 0;
    g[0][j] = 0;
  }
  for (int i = 1; i <= n + 10; i++)
    for (int j = 0; j <= n + 1; j++) {
      f[i][j] = 0;
      for (int k = 0; k <= n + 1; k++)
        if (a[k] <= a[j]) {
          f[i][j] = max(f[i][j], f[i - 1][k] + get_f[k][j]);
        }
      g[i][j] = 0;
      for (int k = 0; k <= n + 1; k++)
        if (a[k] >= a[j]) {
          g[i][j] = max(g[i][j], g[i - 1][k] + get_g[j][k]);
        }
    }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int tmp = 0;
    for (int j = 1; j <= n; j++)
      if (a[j] == a[i]) tmp++;
    for (int j = 0; j <= n + 2; j++)
      for (int k = 0; k <= n + 2; k++)
        if (j + k <= t) {
          ans = max(ans, f[j][i] + g[k][i] + (t - j - k) * tmp);
        }
  }
  cout << ans << endl;
  return 0;
}
