#include<bits/stdc++.h>
using namespace std;
#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair<int,int>
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
const int mod=1e9+7;
const int maxn=5e3+10;
const int maxm=5e5+10;
const ll INF=1e18;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){
if(y==0) return x;
return gcd(y,x%y);
}
int n,m,pos[maxn],dp[maxn],ans=0;
double d;
int main(){
ios::sync_with_stdio(false);/*
freopen("d://in.txt","r",stdin);
freopen("d://out.txt","w",stdout);*/
cin>>n>>m;
rep(i,1,n+1){
int x,tmp=0;cin>>x>>d;
rep(j,0,x+1) tmp=max(dp[j],tmp);
dp[x]=max(dp[x],tmp+1);
ans=max(ans,dp[x]);///不降子序列中找到长度最长的那一个
}
cout<<n-ans<<"\n";
return 0;
}