#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define int long long
#define pb push_back
#define se second
#define fi first
#define endl "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod = 1e9+7;
const int sz = 1e5+5;
const int inf = 1e9+7;
int bin_pow(int x, int b) {
int res = 1;
while (b > 0) {
if (b & 1) {
res = (res * x) % mod;
}
x = (x * x) % mod;
b >>= 1;
}
return res;
}
struct modint {
int x;
modint(int val): x(val) {}
modint operator*(modint other) {
return 1LL*x*other.x%mod;
} modint operator-(modint other) {
return (x-other.x)%mod;
} modint operator+(modint other) {
return (x+other.x)%mod;
}
};
int sq = 500;
void _(){
int n, k;
cin >> n >> k;
int a[n];
for(int i = 0; i < n; i++){
cin >> a[i];
}vector<int> v;
for(int i = 0; i < n; i++){
auto it = lower_bound(v.begin(), v.end(), a[i]);
if(it == v.end()){
v.push_back(a[i]);
}else {
*it = a[i];
}
}cout << v.size();
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
// freopen("main.in", "r", stdin);
// freopen("main.out", "w", stdout);
int t = 1;
// cin >> t;
while (t--){
_();
}
}