#include <bits/stdc++.h>
using namespace std;
const long long inf = 2147383647;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
inline long long gcd(long long a, long long b) {
  a = ((a) < 0 ? -(a) : (a));
  b = ((b) < 0 ? -(b) : (b));
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
long long ext_gcd(long long A, long long B, long long* X, long long* Y) {
  long long x2, y2, x1, y1, x, y, r2, r1, q, r;
  x2 = 1;
  y2 = 0;
  x1 = 0;
  y1 = 1;
  for (r2 = A, r1 = B; r1 != 0;
       r2 = r1, r1 = r, x2 = x1, y2 = y1, x1 = x, y1 = y) {
    q = r2 / r1;
    r = r2 % r1;
    x = x2 - (q * x1);
    y = y2 - (q * y1);
  }
  *X = x2;
  *Y = y2;
  return r2;
}
inline long long modInv(long long a, long long m) {
  long long x, y;
  ext_gcd(a, m, &x, &y);
  x %= m;
  if (x < 0) x += m;
  return x;
}
inline long long power(long long a, long long p) {
  long long res = 1, x = a;
  while (p) {
    if (p & 1) res = (res * x);
    x = (x * x);
    p >>= 1;
  }
  return res;
}
inline long long bigmod(long long a, long long p, long long m) {
  long long res = 1 % m, x = a % m;
  while (p) {
    if (p & 1) res = (res * x) % m;
    x = (x * x) % m;
    p >>= 1;
  }
  return res;
}
int arr[20010], brr[20010], LNDS[20010], L2[20010];
map<int, int> mp;
int repeat(int n, int r) {
  int total = r * n;
  for (long long i = (n); i <= (total - 1); ++i) {
    arr[i] = arr[i - n];
    LNDS[i] = 1;
  }
  int res = 1;
  for (long long i = (0); i <= (total - 1); ++i) {
    for (long long j = (i + 1); j <= (total - 1); ++j) {
      if (arr[j] >= arr[i] && LNDS[i] + 1 > LNDS[j]) {
        LNDS[j] = LNDS[i] + 1;
        res = ((res) > (LNDS[j]) ? (res) : (LNDS[j]));
      }
    }
  }
  return res;
}
int process(int n, int t) {
  int r = 100;
  int total = r * n;
  for (long long i = (n); i <= (total - 1); ++i) {
    arr[i] = arr[i - n];
    LNDS[i] = 1;
  }
  int res = 1;
  for (long long i = (0); i <= (total - 1); ++i) {
    for (long long j = (i + 1); j <= (total - 1); ++j) {
      if (arr[j] >= arr[i] && LNDS[i] + 1 > LNDS[j]) {
        LNDS[j] = LNDS[i] + 1;
        res = ((res) > (LNDS[j]) ? (res) : (LNDS[j]));
      }
    }
  }
  for (long long i = (0); i <= (total - 1); ++i) {
    brr[i] = arr[total - 1 - i];
    L2[i] = 1;
  }
  for (long long i = (0); i <= (total - 1); ++i) {
    for (long long j = (i + 1); j <= (total - 1); ++j) {
      if (brr[j] <= brr[i] && L2[i] + 1 > L2[j]) {
        L2[j] = L2[i] + 1;
      }
    }
  }
  int rem = t - 200;
  for (long long i = (total - n); i <= (total - 1); ++i) {
    int temp = LNDS[i];
    temp += mp[arr[i]] * rem;
    for (long long j = (total - n); j <= (total - 1); ++j) {
      if (brr[j] >= arr[i]) {
        int tres = temp + L2[j];
        res = ((res) > (tres) ? (res) : (tres));
      }
    }
  }
  return res;
}
int main() {
  int n, t;
  scanf("%d %d", &n, &t);
  for (long long i = (0); i <= (n - 1); ++i) {
    scanf("%d", &arr[i]);
    LNDS[i] = 1;
    mp[arr[i]]++;
  }
  int res;
  if (t <= 200)
    res = repeat(n, t);
  else
    res = process(n, t);
  printf("%d\n", res);
  return 0;
}

### Prompt

Please provide a cpp coded solution to the problem described below:

You are given an array of positive integers a1, a2, ..., an × T of length n × T. We know that for any i > n it is true that ai = ai - n. Find the length of the longest non-decreasing sequence of the given array.

Input

The first line contains two space-separated integers: n, T (1 ≤ n ≤ 100, 1 ≤ T ≤ 107). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 300).

Output

Print a single number — the length of a sought sequence.

Examples

Input

4 3
3 1 4 2


Output

5

Note

The array given in the sample looks like that: 3, 1, 4, 2, 3, 1, 4, 2, 3, 1, 4, 2. The elements in bold form the largest non-decreasing subsequence. 

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long inf = 2147383647;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
inline long long gcd(long long a, long long b) {
  a = ((a) < 0 ? -(a) : (a));
  b = ((b) < 0 ? -(b) : (b));
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
long long ext_gcd(long long A, long long B, long long* X, long long* Y) {
  long long x2, y2, x1, y1, x, y, r2, r1, q, r;
  x2 = 1;
  y2 = 0;
  x1 = 0;
  y1 = 1;
  for (r2 = A, r1 = B; r1 != 0;
       r2 = r1, r1 = r, x2 = x1, y2 = y1, x1 = x, y1 = y) {
    q = r2 / r1;
    r = r2 % r1;
    x = x2 - (q * x1);
    y = y2 - (q * y1);
  }
  *X = x2;
  *Y = y2;
  return r2;
}
inline long long modInv(long long a, long long m) {
  long long x, y;
  ext_gcd(a, m, &x, &y);
  x %= m;
  if (x < 0) x += m;
  return x;
}
inline long long power(long long a, long long p) {
  long long res = 1, x = a;
  while (p) {
    if (p & 1) res = (res * x);
    x = (x * x);
    p >>= 1;
  }
  return res;
}
inline long long bigmod(long long a, long long p, long long m) {
  long long res = 1 % m, x = a % m;
  while (p) {
    if (p & 1) res = (res * x) % m;
    x = (x * x) % m;
    p >>= 1;
  }
  return res;
}
int arr[20010], brr[20010], LNDS[20010], L2[20010];
map<int, int> mp;
int repeat(int n, int r) {
  int total = r * n;
  for (long long i = (n); i <= (total - 1); ++i) {
    arr[i] = arr[i - n];
    LNDS[i] = 1;
  }
  int res = 1;
  for (long long i = (0); i <= (total - 1); ++i) {
    for (long long j = (i + 1); j <= (total - 1); ++j) {
      if (arr[j] >= arr[i] && LNDS[i] + 1 > LNDS[j]) {
        LNDS[j] = LNDS[i] + 1;
        res = ((res) > (LNDS[j]) ? (res) : (LNDS[j]));
      }
    }
  }
  return res;
}
int process(int n, int t) {
  int r = 100;
  int total = r * n;
  for (long long i = (n); i <= (total - 1); ++i) {
    arr[i] = arr[i - n];
    LNDS[i] = 1;
  }
  int res = 1;
  for (long long i = (0); i <= (total - 1); ++i) {
    for (long long j = (i + 1); j <= (total - 1); ++j) {
      if (arr[j] >= arr[i] && LNDS[i] + 1 > LNDS[j]) {
        LNDS[j] = LNDS[i] + 1;
        res = ((res) > (LNDS[j]) ? (res) : (LNDS[j]));
      }
    }
  }
  for (long long i = (0); i <= (total - 1); ++i) {
    brr[i] = arr[total - 1 - i];
    L2[i] = 1;
  }
  for (long long i = (0); i <= (total - 1); ++i) {
    for (long long j = (i + 1); j <= (total - 1); ++j) {
      if (brr[j] <= brr[i] && L2[i] + 1 > L2[j]) {
        L2[j] = L2[i] + 1;
      }
    }
  }
  int rem = t - 200;
  for (long long i = (total - n); i <= (total - 1); ++i) {
    int temp = LNDS[i];
    temp += mp[arr[i]] * rem;
    for (long long j = (total - n); j <= (total - 1); ++j) {
      if (brr[j] >= arr[i]) {
        int tres = temp + L2[j];
        res = ((res) > (tres) ? (res) : (tres));
      }
    }
  }
  return res;
}
int main() {
  int n, t;
  scanf("%d %d", &n, &t);
  for (long long i = (0); i <= (n - 1); ++i) {
    scanf("%d", &arr[i]);
    LNDS[i] = 1;
    mp[arr[i]]++;
  }
  int res;
  if (t <= 200)
    res = repeat(n, t);
  else
    res = process(n, t);
  printf("%d\n", res);
  return 0;
}

```