// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define endl '\n';
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define py cout << "YES" << endl;
#define pn cout << "NO" << endl;
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define int long long
typedef long long ll;
typedef unsigned long long ull;
const ll inf = 1e18;
const ll mod = 1e9+7;
//#define LOCAL // Comment this line before submitting
#ifdef LOCAL
#include "algo/Standard_Stuff/debug.cpp"
#else
#define debug(...) 42
#endif
void judge(){
srand(time(NULL));
#ifdef LOCAL
freopen("1.txt", "r", stdin);
freopen("2.txt", "w", stdout);
#endif
}
signed main(){
fastio; judge();
int n,m; cin >> n >> m;
vector<pair<int,int>>p(m);
for(int i = 0;i<m;i++){
cin >> p[i].second;
}
for(int i = 0;i<m;i++){
cin >> p[i].first;
}
sort(all(p));
debug(p);
int cnt = 1;
set<pair<int,int>>s = {{-inf,0},{inf,n+1}};
s.insert({p[0].second,p[0].first});
auto can_insert = [&](pair<int,int>a){
auto it = s.lower_bound(a);
if(abs((*it).first-a.first)<abs((*it).second - a.second)){
return false;
}
it--;
if(abs((*it).first-a.first)<abs((*it).second - a.second)){
return false;
}
return true;
};
for(int i = 1;i<m;i++){
if(p[i]==p[i-1]){
continue;
}
swap(p[i].first,p[i].second);
if(!can_insert(p[i])){
cnt++;
s = {{-inf,0},{inf,n+1}};
}
s.insert(p[i]);
}
cout << cnt;
}