#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <queue>

using namespace std;

#define fastInp ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef long double ld;

const ll SIZE = 1e6 * 2, MOD = 1e9 + 7;
vector<ll> vec;
ll q, cnt[26];

ll gcd(ll a, ll b) {
	if (b == 0)
		return a;
	else
		return gcd(b, a % b);
}

int main() {
	fastInp;

	ll n, k;
	cin >> n >> k;
	string line;
	cin >> line;

	for (int i = 0; i < line.size(); i++) {
		cnt[line[i] - 'A']++;
	}

	ll ans = INT64_MAX;
	for (int i = 0; i < k; i++) {
		ans = min(ans, cnt[i]);
	}

	cout << ans;

	return 0;
}


#include<bits/stdc++.h>
#define pi 3.1415
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 200009
#define MOD 1000000007
#define INF (ll)3000009
using namespace std;
ll vet[maxn];
int main(){
    ios::sync_with_stdio(false);
    int q;
    cin>>q;
    while(q--){
        ll h,n;
        cin>>h>>n;
        for(int i=0;i<n;i++){
            cin>>vet[i];
        }
        sort(vet,vet+n);
        reverse(vet,vet+n);
        ll pos=vet[0];
        ll ans=0;
        for(int i=0;i<n-2;i++){
            if(pos-1==vet[i+1] && pos-2==vet[i+2]){
                pos=vet[i+2];
                i++;
            }
            else if(vet[i+1]==pos-1 && pos-2!=vet[i+2]){
                ans++;
                pos=vet[i+1];
            }
            else if(vet[i+1]!=pos-1 && pos-2!=vet[i+2]){
                pos=vet[i+1]+1;
                i--;
            }
        }
        if(vet[n-1]==pos-1)ans++;
        cout<<ans<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define pi 3.1415
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 200009
#define MOD 1000000007
#define INF (ll)3000009
using namespace std;
ll vet[maxn];
int main(){
    ios::sync_with_stdio(false);
    int q;
    cin>>q;
    while(q--){
        ll h,n;
        cin>>h>>n;
        for(int i=0;i<n;i++){
            cin>>vet[i];
        }
        sort(vet,vet+n);
        reverse(vet,vet+n);
        ll pos=vet[0];
        ll ans=0;
        for(int i=0;i<n-2;i++){
            if(pos-1==vet[i+1] && pos-2==vet[i+2]){
                pos=vet[i+2];
                i++;
            }
            else if(vet[i+1]==pos-1 && pos-2!=vet[i+2]){
                ans++;
                pos=vet[i+1]-1;
            }
            else if(vet[i+1]!=pos-1 && pos-2!=vet[i+2]){
                pos=vet[i+1]+1;
                i--;
            }
        }

        cout<<ans<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define pi 3.1415
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 200009
#define MOD 1000000007
#define INF (ll)3000009
using namespace std;
ll vet[maxn];
int main(){
    ios::sync_with_stdio(false);
    int q;
    cin>>q;
    while(q--){
        ll h,n;
        cin>>h>>n;
        for(int i=0;i<n;i++){
            cin>>vet[i];
        }
        sort(vet,vet+n);
        reverse(vet,vet+n);
        ll pos=vet[0];
        ll ans=0;
        for(int i=0;i<n-2;i++){
            if(pos-1==vet[i+1] && pos-2==vet[i+2]){
                pos=vet[i+2];
                i++;
            }
            else if(vet[i+1]==pos-1 && pos-2!=vet[i+2]){
                ans++;
                pos=vet[i+1]-1;
                if(i==n-3 && vet[n-1]>=2)ans++;
            }
            else if(vet[i+1]!=pos-1 && pos-2!=vet[i+2]){
                pos=vet[i+1]+1;
                i--;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define pi 3.1415
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 200009
#define MOD 1000000007
#define INF (ll)3000009
using namespace std;
ll vet[maxn];
int main(){
    ios::sync_with_stdio(false);
    int q;
    cin>>q;
    while(q--){
        ll h,n;
        cin>>h>>n;
        for(int i=0;i<n;i++){
            cin>>vet[i];
        }
        vet[n]=0;
        sort(vet,vet+n+1);
        reverse(vet,vet+n+1);
        ll pos=vet[0];
        ll ans=0;
        for(int i=0;i<=n-2;i++){
            if(pos-1==vet[i+1] && pos-2==vet[i+2]){
                pos=vet[i+2];
                i++;
            }
            else if(vet[i+1]==pos-1 && pos-2!=vet[i+2]){
                ans++;
                pos=vet[i+1];
            }
            else if(vet[i+1]!=pos-1 && pos-2!=vet[i+2]){
                pos=vet[i+1]+1;
                i--;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define pi 3.1415
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 200009
#define MOD 1000000007
#define INF (ll)3000009
using namespace std;
ll vet[maxn];
int main(){
    ios::sync_with_stdio(false);
    int q;
    cin>>q;
    while(q--){
        ll h,n;
        cin>>h>>n;
        for(int i=0;i<n;i++){
            cin>>vet[i];
        }
        sort(vet,vet+n);
        reverse(vet,vet+n);
        ll pos=vet[0];
        ll ans=0;
        for(int i=0;i<n-2;i++){
            if(pos-1==vet[i+1] && pos-2==vet[i+2]){
                pos=vet[i+2];
                i++;
            }
            else if(vet[i+1]==pos-1 && pos-2!=vet[i+2]){
                ans++;
                pos=vet[i+1];
            }
            else if(vet[i+1]!=pos-1 && pos-2!=vet[i+2]){
                pos=vet[i+1]+1;
                i--;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define int long long int
#define all(a) a.begin(),a.end()
#define S second
#define F first
#define pii pair<int,int>
#define vct vector<int>
#define pb push_back
#define endl '\n'
using namespace std;
void solve(){
	int n ,h ;
	cin>>h>>n ;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	a.push_back(0);
	int ans = 0 ;
	for(int i=0;i<n-1;i++){
		if(a[i] == a[i+1]+1){
			if(a[i]-a[i+2]>2){
				a[i+2]++;
				ans++;
			}
		//	cout << a[i] << " "  << a[i+2] ;
			i++;
			continue;
		}
		continue;
	}
	cout << ans ;
}
signed main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int t = 1 ;
	cin>>t;
	while(t--){
		solve();
		cout << endl ;
	}
   return  0 ;
}
/* I TOOK a big fat  L 2 times but not for the third time
    AM I WORTH IT ?
    DID I PUT ENOUGH WORK IN ?
*/


#include <bits/stdc++.h>
using namespace std;
void solve() {
	int n ,h ,el;
	cin>>h>>n;
	int cur = h ;
	list<int> a ;
	for(int i=0;i<n;i++){
		cin>>el ;
		if(i)a.insert(a.end(),el);
	}
	if(n == 1){
		cout << 0 ;
		return   ;
	}
	int ans = 0;
	while(a.size()>1){
		int f = *(a.begin());
		if(cur-f>1){
			cur = f+1;
			continue;
		}
		auto it = a.begin();
		it++;
		int s = *it;
		if(f-s>1){
			ans++;
			cur = s+1;
			a.erase(a.begin()) ;
			continue;
		}
		a.erase(a.begin()) ;
		a.erase(a.begin()) ;
		cur =s ;
	}
	int f = *(a.begin());
	if(cur-f==1&&cur!=2) ans++;
	cout << ans ;
}
int main(){
	int t ;
	cin>>t;
	while(t--){
		solve() ;
		cout << endl ;
	}
}


#include <bits/stdc++.h>
#define int long long int
#define all(a) a.begin(),a.end()
#define S second
#define F first
#define pii pair<int,int>
#define vct vector<int>
#define pb push_back
#define endl '\n'
using namespace std;
void solve(){
	int n ,h ;
	cin>>h>>n ;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	a.push_back(0);
	int ans = 0 ;
	bool flg = 0 ;
	for(int i=0;i<n-1;i++){
		if(flg){
			if(a[i]-a[i+1]>2){
				a[i+1]++;
				ans++;
				i++;
				continue;
			}
			flg = 0 ;
			continue;
		}
		if(a[i] == a[i+1]+1){
			if(a[i]-a[i+2]>2){
				a[i+2]++;
				ans++;
				flg = 1 ;
				i++;
				continue;
			}
			flg = 0 ;
			i++;
			continue;
		}
		flg = 1 ;
		a[i+1]++;
		continue;
	}
	cout << ans ;
}
signed main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int t = 1 ;
	cin>>t;
	while(t--){
		solve();
		cout << endl ;
	}
   return  0 ;
}
/* I TOOK a big fat  L 2 times but not for the third time
    AM I WORTH IT ?
    DID I PUT ENOUGH WORK IN ?
*/


#include <bits/stdc++.h>
using namespace std;
void solve() {
	int n ,h ,el;
	cin>>h>>n;
	int cur = h ;
	list<int> a ;
	for(int i=0;i<n;i++){
		cin>>el ;
		if(i)a.insert(a.end(),el);
	}
	if(n == 1){
		cout << 0 ;
		return   ;
	}
	int ans = 0;
	while(a.size()>0){
		int f = *(a.begin());
		if(a.size() == 1){
			if(cur-*(a.begin())==1){
				if(cur>2) ans++;
			}
			else{
				if(*(a.begin())+1>2)ans++;
			}
			a.erase(a.begin()) ;
			break ;
		}
		if(cur-f>1){
			cur = f+1;
			continue;
		}

		auto it = a.begin();
		it++;
		int s = *it;
		if(f-s>1){
			ans++;
			cur = s+1;
			a.erase(a.begin()) ;
			continue;
		}
		a.erase(a.begin()) ;
		a.erase(a.begin()) ;
		cur =s ;
	}
	cout << ans ;
}
int main(){
	int t ;
	cin>>t;
	while(t--){
		solve() ;
		cout << endl ;
	}
}


#include <bits/stdc++.h>
#define int long long int
#define all(a) a.begin(),a.end()
#define S second
#define F first
#define pii pair<int,int>
#define vct vector<int>
#define pb push_back
#define endl '\n'
using namespace std;
void solve(){
	int n ,h ;
	cin>>h>>n ;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	a.push_back(0);
	int ans = 0 ;
	for(int i=0;i<n-1;i++){
		if(a[i] == a[i+1]+1){
			if(a[i]-a[i+2]>2) ans++;
			i++;
			continue;
		}
		continue;
	}
	cout << ans ;
}
signed main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int t = 1 ;
	cin>>t;
	while(t--){
		solve();
		cout << endl ;
	}
   return  0 ;
}
/* I TOOK a big fat  L 2 times but not for the third time
    AM I WORTH IT ?
    DID I PUT ENOUGH WORK IN ?
*/


#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define ll long long int
#define P pair
#define pll pair<long long, long long>
#define pii pair<int, int>
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define enl '\n'
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);
void inv(bool arr[] , int hi){
    if(arr[hi]) arr[hi] = 0;
    else arr[hi] = 1;
}
int main(){
    int t;
    cin >> t;
    while(t--){
        int h , n;
        cin >> h >> n;
        bool hi[h+1];
        init(hi,0);
        int hh;
        for(int i  = 0 ; i < n ; i++){
            cin >> hh;
            hi[hh] = 1;
        }
        hi[0]= 1;
        int cl = h;
        int ans = 0 ;
        while(cl > 2){
            if(hi[cl-1] == 0){
                cl--;
                continue;
            }
            if(hi[cl-1] == 1 && hi[cl-2] == 1 ){
                cl = cl-2;
                continue;
            }
            if(hi[cl-1] == 1 && hi[cl-2] == 0){
                ans++;
                cl -= 2;
            }
        }
        cout << ans << enl;
    }
    return 0 ;
}


#include <bits/stdc++.h>
using namespace std;
void solve() {
	int n ,h ,el;
	cin>>h>>n;
	int cur = h ;
	list<int> a ;
	for(int i=0;i<n;i++){
		cin>>el ;
		if(i)a.insert(a.end(),el);
	}
	if(n == 1){
		cout << 0 ;
		return   ;
	}
	int ans = 0;
	while(a.size()>0){
		int f = *(a.begin());
		if(a.size() == 1){
			if(cur-f==1&&cur!=2) ans++;
			a.erase(a.begin()) ;
			continue;
		}
		if(cur-f>1){
			cur = f+1;
			continue;
		}

		auto it = a.begin();
		it++;
		int s = *it;
		if(f-s>1){
			ans++;
			cur = s+1;
			a.erase(a.begin()) ;
			continue;
		}
		a.erase(a.begin()) ;
		a.erase(a.begin()) ;
		cur =s ;
	}
	int f = *(a.begin());
	if(cur-f==1&&cur!=2) ans++;
	cout << ans ;
}
int main(){
	int t ;
	cin>>t;
	while(t--){
		solve() ;
		cout << endl ;
	}
}


#include <bits/stdc++.h>
using namespace std;
void solve() {
	int n ,h ,el;
	cin>>h>>n;
	int cur = h ;
	list<int> a ;
	for(int i=0;i<n;i++){
		cin>>el ;
		if(i)a.insert(a.end(),el);
	}
	if(n == 1){
		cout << 0 ;
		return   ;
	}
	int ans = 0;
	while(a.size()>0){
		int f = *(a.begin());
		if(cur-f>1){
			cur = f+1;
			continue;
		}
		if(a.size() == 1){
			if(cur-f==1) ans++;
			a.erase(a.begin()) ;
			continue;
		}
		auto it = a.begin();
		it++;
		int s = *it;
		if(f-s>1){
			ans++;
			cur = s+1;
			a.erase(a.begin()) ;
			continue;
		}
		a.erase(a.begin()) ;
		a.erase(a.begin()) ;
		cur =s ;
	}
	int f = *(a.begin());
	if(cur-f==1&&cur!=2) ans++;
	cout << ans ;
}
int main(){
	int t ;
	cin>>t;
	while(t--){
		solve() ;
		cout << endl ;
	}
}


#include <bits/stdc++.h>
using namespace std;
void solve() {
	int n ,h ,el;
	cin>>h>>n;
	int cur = h ;
	list<int> a ;
	for(int i=0;i<n;i++){
		cin>>el ;
		if(i)a.insert(a.end(),el);
	}
	if(n == 1){
		cout << 0 ;
		return   ;
	}
	int ans = 0;
	while(a.size()>0){
		int f = *(a.begin());
		if(a.size() == 1){
			if(cur-f==1&&cur!=2) ans++;
			a.erase(a.begin()) ;
			break ;
		}
		if(cur-f>1){
			cur = f+1;
			continue;
		}

		auto it = a.begin();
		it++;
		int s = *it;
		if(f-s>1){
			ans++;
			cur = s+1;
			a.erase(a.begin()) ;
			continue;
		}
		a.erase(a.begin()) ;
		a.erase(a.begin()) ;
		cur =s ;
	}
	cout << ans ;
}
int main(){
	int t ;
	cin>>t;
	while(t--){
		solve() ;
		cout << endl ;
	}
}


#include <bits/stdc++.h>
using namespace std;
void solve() {
	int n ,h ,el;
	cin>>h>>n;
	int cur = h ;
	list<int> a ;
	for(int i=0;i<n;i++){
		cin>>el ;
		if(i)a.insert(a.end(),el);
	}
	if(n == 1){
		cout << 0 ;
		return  0 ;
	}
	int ans = 0;
	while(a.size()>1){
		int f = *(a.begin());
		if(cur-f>1){
			cur = f+1;
			continue;
		}
		auto it = a.begin();
		it++;
		int s = *it;
		if(f-s>1){
			ans++;
			cur = s+1;
			a.erase(a.begin()) ;
			continue;
		}
		a.erase(a.begin()) ;
		a.erase(a.begin()) ;
		cur =s ;
	}
	int f = *(a.begin());
	if(cur-f==1&&cur!=2) ans++;
	cout << ans ;
}
int main(){
	int t ;
	cin>>t;
	while(t--){
		solve() ;
		cout << endl ;
	}
}


#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=1e6+5;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
#define ls (i<<1)
#define rs (i<<1|1)
#define fi first
#define se second
#define mk make_pair
#define mem(a,b) memset(a,b,sizeof(a))
LL read()
{
    LL x=0,t=1;
    char ch;
    while(!isdigit(ch=getchar())) if(ch=='-') t=-1;
    while(isdigit(ch)){ x=10*x+ch-'0'; ch=getchar(); }
    return x*t;
}
int a[N];
int main()
{
    int T=read();
    while(T--)
    {
        int h=read(),n=read();
        for(int i=1;i<=n;i++) a[i]=read();
        a[n+1]=0;
        bool flag=0;

        int ans=0;
        for(int i=2;i<=n+1;i++)
        {
            if(flag)
            {
                if(h-a[i]>2) h=a[i]+1,ans++;
                else h=a[i],flag=0;
            }
            else  if(h-a[i]==1) flag=1;
            else h=a[i]+1;
            //printf("h=%d,flag=%d\n",h,flag);
        }
        //if(flag) ans++;
        printf("%d\n",ans);
    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=1e6+5;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
#define ls (i<<1)
#define rs (i<<1|1)
#define fi first
#define se second
#define mk make_pair
#define mem(a,b) memset(a,b,sizeof(a))
LL read()
{
    LL x=0,t=1;
    char ch;
    while(!isdigit(ch=getchar())) if(ch=='-') t=-1;
    while(isdigit(ch)){ x=10*x+ch-'0'; ch=getchar(); }
    return x*t;
}
int a[N];
int main()
{
    int T=read();
    while(T--)
    {
        int h=read(),n=read();
        for(int i=1;i<=n;i++) a[i]=read();
        if(a[1]-a[2]>1) a[1]--;
        int ans=0;
        int i=1;
        a[n+1]=a[n+2]=0;
        if(n==1)
        {
            printf("0\n");
            continue;
        }
        while(i<=n)
        {
            if(a[i]-a[i+1]==1)
            {
                if(a[i+1]==0) break;
                if(a[i]-a[i+2]==2) i=i+2;
                else
                {
                    //printf("%d %d %d\n",i,a[i],a[i+2]);
                    ans++;
                    a[i+1]=a[i+2]+1;
                    i++;
                }
            }
            else if(a[i]-a[i+1]==2) i++;
            else a[i]=a[i+1]+1;
        }
        printf("%d\n",ans);
    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=1e6+5;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
#define ls (i<<1)
#define rs (i<<1|1)
#define fi first
#define se second
#define mk make_pair
#define mem(a,b) memset(a,b,sizeof(a))
LL read()
{
    LL x=0,t=1;
    char ch;
    while(!isdigit(ch=getchar())) if(ch=='-') t=-1;
    while(isdigit(ch)){ x=10*x+ch-'0'; ch=getchar(); }
    return x*t;
}
int a[N];
int main()
{
    int T=read();
    while(T--)
    {
        int h=read(),n=read();
        for(int i=1;i<=n;i++) a[i]=read();
        if(a[1]-a[2]>1) a[1]--;
        int ans=0;
        int i=1;
        a[n+1]=0;
        if(n==1)
        {
            printf("0\n");
            continue;
        }
        while(i<=n)
        {
            if(a[i]-a[i+1]==1)
            {
                if(a[i]-a[i+2]==2) i=i+2;
                else if(a[i+2]==0) break;
                else
                {
                    ans++;
                    a[i+1]=a[i+2]+1;
                    i++;
                }
            }
            else if(a[i]-a[i+1]==2) i++;
            else a[(++i)]++;
        }
        printf("%d\n",ans);
    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=1e6+5;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
#define ls (i<<1)
#define rs (i<<1|1)
#define fi first
#define se second
#define mk make_pair
#define mem(a,b) memset(a,b,sizeof(a))
LL read()
{
    LL x=0,t=1;
    char ch;
    while(!isdigit(ch=getchar())) if(ch=='-') t=-1;
    while(isdigit(ch)){ x=10*x+ch-'0'; ch=getchar(); }
    return x*t;
}
int a[N];
int main()
{
    int T=read();
    while(T--)
    {
        int h=read(),n=read();
        for(int i=1;i<=n;i++) a[i]=read();
        a[n+1]=0;
        bool flag=0;

        int ans=0;
        for(int i=2;i<=n+1;i++)
        {
            if(flag)
            {
                if(h-a[i]>2) h=a[i]+1,ans++;
                else h=a[i],flag=0;
            }
            else  if(h-a[i]==1) flag=1;
            else h=a[i]+1,flag=1;
            //printf("h=%d,flag=%d\n",h,flag);
        }
        //if(flag) ans++;
        printf("%d\n",ans);
    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=1e6+5;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
#define ls (i<<1)
#define rs (i<<1|1)
#define fi first
#define se second
#define mk make_pair
#define mem(a,b) memset(a,b,sizeof(a))
LL read()
{
    LL x=0,t=1;
    char ch;
    while(!isdigit(ch=getchar())) if(ch=='-') t=-1;
    while(isdigit(ch)){ x=10*x+ch-'0'; ch=getchar(); }
    return x*t;
}
int a[N];
int main()
{
    int T=read();
    while(T--)
    {
        int h=read(),n=read();
        for(int i=1;i<=n;i++) a[i]=read();
        if(a[2]-a[1]>1) a[1]--;
        int ans=0;
        int i=1;
        while(i<=n)
        {
            if(a[i]-a[i+1]==1)
            {
                if(a[i]-a[i+2]==2) i=i+2;
                else
                {
                    ans++;
                    a[i+1]=a[i+2]+1;
                    i++;
                }
            }
            else if(a[i]-a[i+1]==2) i++;
            else a[(++i)]++;
        }
        printf("%d\n",ans);
    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=1e6+5;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
#define ls (i<<1)
#define rs (i<<1|1)
#define fi first
#define se second
#define mk make_pair
#define mem(a,b) memset(a,b,sizeof(a))
LL read()
{
    LL x=0,t=1;
    char ch;
    while(!isdigit(ch=getchar())) if(ch=='-') t=-1;
    while(isdigit(ch)){ x=10*x+ch-'0'; ch=getchar(); }
    return x*t;
}
int a[N],b[N];
int main()
{
    int T=read();
    while(T--)
    {
        int h=read(),n=read();
        for(int i=1;i<=n;i++) a[i]=read();
        int ans=0,cnt=1;
        for(int i=2;i<=n;i++)
        {
            if(a[i]+1==a[i-1]) cnt++;
            else
            {
                if( !(cnt&1) ) ans++;
                cnt=2;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=1e6+5;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
#define ls (i<<1)
#define rs (i<<1|1)
#define fi first
#define se second
#define mk make_pair
#define mem(a,b) memset(a,b,sizeof(a))
LL read()
{
    LL x=0,t=1;
    char ch;
    while(!isdigit(ch=getchar())) if(ch=='-') t=-1;
    while(isdigit(ch)){ x=10*x+ch-'0'; ch=getchar(); }
    return x*t;
}
int a[N],b[N];
int main()
{
    int T=read();
    while(T--)
    {
        int h=read(),n=read();
        a[0]=h+1;
        for(int i=1;i<=n;i++)
        {
            a[i]=read();
            b[i]= a[i]==a[i-1]-1;
        }
        int sum=0,ans=0;
        for(int i=1;i<=n;i++)
        {
            if(b[i]) sum++;
            else
            {
                if(!(sum&1)) ans++;
                sum=0;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=1e6+5;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
#define ls (i<<1)
#define rs (i<<1|1)
#define fi first
#define se second
#define mk make_pair
#define mem(a,b) memset(a,b,sizeof(a))
LL read()
{
    LL x=0,t=1;
    char ch;
    while(!isdigit(ch=getchar())) if(ch=='-') t=-1;
    while(isdigit(ch)){ x=10*x+ch-'0'; ch=getchar(); }
    return x*t;
}
int a[N],b[N];
int main()
{
    int T=read();
    while(T--)
    {
        int h=read(),n=read();
        for(int i=1;i<=n;i++) a[i]=read();
        int ans=0,cnt=1;
        for(int i=2;i<=n;i++)
        {
            if(a[i]+1==a[i-1]) cnt++;
            else
            {
                if( !(cnt&1) ) ans++;
                cnt=2;
            }
        }
        if(!(cnt&1)&&a[n]>1) ans++;
        printf("%d\n",ans);
    }
    return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include<climits>
#include<deque>
#include<unordered_map>
#include<iomanip>
using namespace std;
# define size2 100005

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long q;
    cin>>q;
    while(q--)
    {
        long long h,n;
        cin>>h>>n;
        long long a[n];
        for(long long i=0;i<n;i++)
        {
            cin>>a[i];

        }
        long long ans=0;
        for(long long i=0;i<n;i++)
        {
            if(i+2>=n)
            {
                break;
            }
            if(a[i+1]-a[i+2]!=1)
            {
                ans++;
            }

        }
        if(a[n-1]!=1 && a[n-2]-a[n-1]!=1)
        {
            ans++;
        }
        cout<<ans<<endl;

    }

    return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include<climits>
#include<deque>
#include<unordered_map>
#include<iomanip>
using namespace std;
# define size2 100005

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long q;
    cin>>q;
    while(q--)
    {
        long long h,n;
        cin>>h>>n;
        long long a[n];
        for(long long i=0;i<n;i++)
        {
            cin>>a[i];

        }
        long long ans=0;
        for(long long i=0;i<n;i++)
        {
            if(i+2>=n)
            {
                break;
            }
            if(a[i+1]-a[i+2]!=1)
            {
                ans++;
            }

        }
        if(a[n-2]-a[n-1]!=1)
        {
            if(a[n-1]!=1)
            {
                ans++;
            }
        }

        cout<<ans<<endl;

    }

    return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include<climits>
#include<deque>
#include<unordered_map>
#include<iomanip>
using namespace std;
# define size2 100005

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long q;
    cin>>q;
    while(q--)
    {
        long long h,n;
        cin>>h>>n;
        long long a[n];
        for(long long i=0;i<n;i++)
        {
            cin>>a[i];

        }
        long long ans=0;
        if(n==1)
        {
            cout<<0<<endl;
            continue;
        }
        if(n==2)
        {
            if(a[n-1]>1)
            {
                ans++;
            }
            cout<<ans<<endl;
            continue;
        }
        long long found=0;
        for(long long i=0;i<n;i++)
        {

            if(i+2>=n)
            {
                found=1;
                break;
            }
            if(i+1>=n)
            {
                found=2;
                break;
            }
            if(a[i+1]-a[i+2]!=1)
            {
                ans++;

            }
            else
            {
                i++;

            }

        }
        if(found==2)
        {
            if(a[n-1]>1)
            {
                ans++;
            }
        }

        cout<<ans<<endl;

    }

    return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include<climits>
#include<deque>
#include<unordered_map>
#include<iomanip>
using namespace std;
# define size2 100005

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long q;
    cin>>q;
    while(q--)
    {
        long long h,n;
        cin>>h>>n;
        long long a[n];
        for(long long i=0;i<n;i++)
        {
            cin>>a[i];

        }
        long long ans=0;
        if(n==1)
        {
            cout<<0<<endl;
            continue;
        }
        for(long long i=0;i<n;i++)
        {
            if(i+2>=n)
            {
                break;
            }
            if(a[i+1]-a[i+2]!=1)
            {
                ans++;
            }
            else
            {
                i++;
            }

        }
        if(a[n-2]-a[n-1]!=1)
        {
            if(a[n-1]>1)
            {
                ans++;
            }
        }

        cout<<ans<<endl;

    }

    return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include<climits>
#include<deque>
#include<unordered_map>
#include<iomanip>
using namespace std;
# define size2 100005

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long q;
    cin>>q;
    while(q--)
    {
        long long h,n;
        cin>>h>>n;
        long long a[n];
        for(long long i=0;i<n;i++)
        {
            cin>>a[i];

        }
        long long ans=0;
        if(n==1)
        {
            cout<<0<<endl;
            continue;
        }
        if(n==2)
        {
            if(a[n-1]>1)
            {
                ans++;
            }
            cout<<ans<<endl;
            continue;
        }

        for(long long i=0;i<n;i++)
        {

            if(i+2>=n)
            {

                break;
            }
            if(a[i+1]-a[i+2]!=1)
            {
                ans++;

            }
            else
            {
                i++;

            }

        }
        if(a[n-3]-a[n-2]!=1)
        {
            if(a[n-2]-a[n-1]!=1)
            {
                if(a[n-1]>1)
                {
                    ans++;
                }
            }
        }
        else
        {
            if(a[n-1]>1)
            {
                ans++;
            }
        }

        cout<<ans<<endl;

    }

    return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include<climits>
#include<deque>
#include<unordered_map>
#include<iomanip>
using namespace std;
# define size2 100005

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long q;
    cin>>q;
    while(q--)
    {
        long long h,n;
        cin>>h>>n;
        long long a[n];
        for(long long i=0;i<n;i++)
        {
            cin>>a[i];

        }
        long long ans=0;

        long long found=0;
        long long index=0;
        for(long long i=0;i<n;i++)
        {

            if(i+2>=n)
            {
                index=i;
                break;
            }
            if(a[i+1]-a[i+2]!=1)
            {
                ans++;

            }
            else
            {
                i++;

            }

        }
        if(index==n-1)
        {
            cout<<ans<<endl;
        }
        else
        {
            if(a[n-1]==1)
            {
                cout<<ans<<endl;
            }
            else
            {
                cout<<ans+1<<endl;
            }
        }

    }

    return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include<climits>
#include<deque>
#include<unordered_map>
#include<iomanip>
using namespace std;
# define size2 100005

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long q;
    cin>>q;
    while(q--)
    {
        long long h,n;
        cin>>h>>n;
        long long a[n];
        for(long long i=0;i<n;i++)
        {
            cin>>a[i];

        }
        long long ans=0;
        for(long long i=0;i<n;i++)
        {
            if(i+2>=n)
            {
                break;
            }
            if(a[i+1]-a[i+2]!=1)
            {
                ans++;
            }

        }
        if(a[n-1]>2)
        {
            ans++;
        }
        else if(a[n-1]==2)
        {
            if(a[n-2]-a[n-1]!=1)
            {
                ans++;
            }
        }
        cout<<ans<<endl;

    }

    return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include<climits>
#include<deque>
#include<unordered_map>
#include<iomanip>
using namespace std;
# define size2 100005

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long q;
    cin>>q;
    while(q--)
    {
        long long h,n;
        cin>>h>>n;
        long long a[n];
        for(long long i=0;i<n;i++)
        {
            cin>>a[i];

        }
        long long ans=0;
        for(long long i=0;i<n;i++)
        {
            if(i+2>=n)
            {
                break;
            }
            if(a[i+1]-a[i+2]!=1)
            {
                ans++;
            }

        }
        cout<<ans<<endl;

    }

    return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include<climits>
#include<deque>
#include<unordered_map>
#include<iomanip>
using namespace std;
# define size2 100005

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long q;
    cin>>q;
    while(q--)
    {
        long long h,n;
        cin>>h>>n;
        long long a[n];
        for(long long i=0;i<n;i++)
        {
            cin>>a[i];

        }
        long long ans=0;
        if(n==1)
        {
            cout<<0<<endl;
            continue;
        }
        for(long long i=0;i<n;i++)
        {
            if(i+2>=n)
            {
                break;
            }
            if(a[i+1]-a[i+2]!=1)
            {
                ans++;
            }

        }
        if(a[n-2]-a[n-1]!=1)
        {
            if(a[n-1]>1)
            {
                ans++;
            }
        }

        cout<<ans<<endl;

    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)

typedef long long int lli;
typedef pair <int, int> ii;
typedef vector <int> vi;

int main()
{
    int t;

    cin>>t;
    for(;t>0;--t)
    {
        int n,r;
        cin>>n>>r;
        int aa[n+1];
        int dp[n+1];
        dp[n]=0;
        for(int i=0;i<n+1;++i)
            aa[i]=0;
        for(int i=0;i<r;++i)
        {
            int j;
            cin>>j;
            aa[j]=1;
        }
        if(aa[n-1]==0)
            dp[n-1]=0;
        else
            dp[n-1]=1;
        for(int i=n-2;i>0;--i)
        {
         if(aa[i]==0)
            dp[i]=dp[i+1];
        else
            dp[i]=1+dp[i+1];
        if(aa[i+1]==1&&aa[i]==1)
        {
            dp[i]=min(dp[i],dp[i+2]);
        }
        else if(aa[i+1]==0&&aa[i]==0)
            dp[i]=min(dp[i],dp[i+2]+2);
        else
            dp[i]=min(dp[i],dp[i+2]+1);
        }
        if(aa[1]==1)
            cout<<min(dp[1],dp[2])<<endl;
        else
            cout<<min(dp[1],dp[2]+1)<<endl;
    }
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)

typedef long long int lli;
typedef pair <int, int> ii;
typedef vector <int> vi;

int main()
{
    lli t;

    cin>>t;
    for(;t>0;--t)
    {
        lli n,r;
        cin>>n>>r;
        vector<lli> aa(n+1);
        vector<lli> dp(n+1);
        dp[n]=0;
        if(n==1)
            cout<<0<<endl;
        else
        {
        for(lli i=0;i<n+1;++i)
           {
            aa[i]=0;
                  }
        for(lli i=0;i<r;++i)
        {
            lli j;
            cin>>j;
            aa[j]=1;
        }
        if(aa[n-1]==0)
            dp[n-1]=0;
        else
            dp[n-1]=1;
        for(lli i=n-2;i>0;--i)
        {
         if(aa[i]==0)
            dp[i]=dp[i+1];
        else
            dp[i]=1+dp[i+1];
        if(aa[i+1]==1&&aa[i]==1)
        {
            dp[i]=min(dp[i],dp[i+2]);
        }
        else if(aa[i+1]==0&&aa[i]==0)
            dp[i]=min(dp[i],dp[i+2]+2);
        else
            dp[i]=min(dp[i],dp[i+2]+1);
        }
        if(aa[1]==1)
            cout<<min(dp[1],dp[2])<<endl;
        else
            cout<<min(dp[1],dp[2]+1)<<endl;
    }
}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)

typedef long long int lli;
typedef pair <int, int> ii;
typedef vector <int> vi;

int main()
{
    lli t;

    cin>>t;
    for(;t>0;--t)
    {
        lli n,r;
        cin>>n>>r;
        lli aa[n+1];
        lli dp[n+1];
        dp[n]=0;
        if(n==1)
            cout<<0<<endl;
        else
        {
        for(lli i=0;i<n+1;++i)
           {
            aa[i]=0;
                  }
        for(lli i=0;i<r;++i)
        {
            lli j;
            cin>>j;
            aa[j]=1;
        }
        if(aa[n-1]==0)
            dp[n-1]=0;
        else
            dp[n-1]=1;
        for(lli i=n-2;i>0;--i)
        {
         if(aa[i]==0)
            dp[i]=dp[i+1];
        else
            dp[i]=1+dp[i+1];
        if(aa[i+1]==1&&aa[i]==1)
        {
            dp[i]=min(dp[i],dp[i+2]);
        }
        else if(aa[i+1]==0&&aa[i]==0)
            dp[i]=min(dp[i],dp[i+2]+2);
        else
            dp[i]=min(dp[i],dp[i+2]+1);
        }
        if(aa[1]==1)
            cout<<min(dp[1],dp[2])<<endl;
        else
            cout<<min(dp[1],dp[2]+1)<<endl;
    }
}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)

typedef long long int lli;
typedef pair <int, int> ii;
typedef vector <int> vi;

int main()
{
    lli t;

    cin>>t;
    for(;t>0;--t)
    {
        lli n,r;
        cin>>n>>r;
        vector<lli> aa(n+100000);
        vector<lli> dp(n+100000);
        dp[n]=0;
        if(n==1)
            cout<<0<<endl;
        else
        {
        for(lli i=0;i<n+1;++i)
           {
            aa[i]=0;
                  }
        for(lli i=0;i<r;++i)
        {
            lli j;
            cin>>j;
            aa[j]=1;
        }
        if(aa[n-1]==0)
            dp[n-1]=0;
        else
            dp[n-1]=1;
        for(lli i=n-2;i>0;--i)
        {
         if(aa[i]==0)
            dp[i]=dp[i+1];
        else
            dp[i]=1+dp[i+1];
        if(aa[i+1]==1&&aa[i]==1)
        {
            dp[i]=min(dp[i],dp[i+2]);
        }
        else if(aa[i+1]==0&&aa[i]==0)
            dp[i]=min(dp[i],dp[i+2]+2);
        else
            dp[i]=min(dp[i],dp[i+2]+1);
        }
        if(aa[1]==1)
            cout<<min(dp[1],dp[2])<<endl;
        else
            cout<<min(dp[1],dp[2]+1)<<endl;
    }
}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)

typedef long long int lli;
typedef pair <int, int> ii;
typedef vector <int> vi;

int main()
{
    ios_base::sync_with_stdio(false);
cin.tie(NULL);
    lli t;

    cin>>t;
    for(;t>0;--t)
    {
        int n,r;
        cin>>n>>r;
        map<lli,lli> aa;
        map<lli,lli> dp;
        int po[r+1];
        if(n==1)
            cout<<0<<endl;
        else
        {
        for(lli i=0;i<r;++i)
        {
            lli j;
            cin>>j;
            aa[j]=1;
            po[i]=j;
        }
        dp[n]=0;
        po[r]=0;
        for(lli i=1;i<r+1;++i)
        {
            if(po[i]==po[i-1]-1)
                {
                    int z=1;
                    z=z;
                }
                else if(po[i]==po[i-1]-2)
                    dp[po[i]+1]=dp[po[i-1]];
                else
                {
                    dp[po[i]+1]=dp[po[i-1]];
                    dp[po[i]+2]=dp[po[i-1]];
                }
         if(aa[po[i]]==0)
            dp[po[i]]=dp[po[i]+1];
        else
            dp[po[i]]=1+dp[po[i]+1];
        if(po[i]+2<=n&&aa[po[i]+1]==1&&aa[po[i]]==1)
        {
            dp[po[i]]=min(dp[po[i]],dp[po[i]+2]);
        }
        else if(po[i]+2<=n&&aa[po[i]+1]==0&&aa[po[i]]==0)
            dp[po[i]]=min(dp[po[i]],dp[po[i]+2]+2);
        else if(po[i]+2<=n)
            dp[po[i]]=min(dp[po[i]],dp[po[i]+2]+1);
        if(i==r)
        {
            dp[0]=dp[po[i]+1];
            if(po[i]+2<=n&&aa[po[i]+1]==1)
         dp[0]=min(dp[po[i]],dp[po[i]+2]);
         else if(po[i]+2<=n)
         dp[0]=min(dp[po[i]],dp[po[i]+2]+1);
        }
        //if(t==3)
          //  cout<<dp[po[i]]<<' '<<po[i]<<endl;
        }
        cout<<dp[0]<<endl;
    }
}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)

typedef long long int lli;
typedef pair <int, int> ii;
typedef vector <int> vi;

int main()
{
    int t;

    cin>>t;
    for(;t>0;--t)
    {
        int n,r;
        cin>>n>>r;
        int aa[n+1];
        int dp[n+1];
        dp[n]=0;
        if(n==1)
            cout<<0<<endl;
        else
        {
        for(int i=0;i<n+1;++i)
           {
            aa[i]=0;
            dp[i]=10000000000;
        }
        for(int i=0;i<r;++i)
        {
            int j;
            cin>>j;
            aa[j]=1;
        }
        if(aa[n-1]==0)
            dp[n-1]=0;
        else
            dp[n-1]=1;
        for(int i=n-2;i>0;--i)
        {
         if(aa[i]==0)
            dp[i]=dp[i+1];
        else
            dp[i]=1+dp[i+1];
        if(aa[i+1]==1&&aa[i]==1)
        {
            dp[i]=min(dp[i],dp[i+2]);
        }
        else if(aa[i+1]==0&&aa[i]==0)
            dp[i]=min(dp[i],dp[i+2]+2);
        else
            dp[i]=min(dp[i],dp[i+2]+1);
        }
        if(aa[1]==1)
            cout<<min(dp[1],dp[2])<<endl;
        else
            cout<<min(dp[1],dp[2]+1)<<endl;
    }
}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)

typedef long long int lli;
typedef pair <int, int> ii;
typedef vector <int> vi;

int main()
{
    ios_base::sync_with_stdio(false);
cin.tie(NULL);
    lli t;

    cin>>t;
    for(;t>0;--t)
    {
        int n,r;
        cin>>n>>r;
        map<lli,lli> aa;
        map<lli,lli> dp;
        int po[r+1];
                for(lli i=0;i<r;++i)
        {
            lli j;
            cin>>j;
            aa[j]=1;
            po[i]=j;
         //   if(t==3)
       //         cout<<j<<'h'<<endl;
        }
        if(n==1)
            cout<<0<<endl;
        else
        {
        //cout<<po[1]<<po[0]<<"hey"<<endl;
        dp[n]=0;
        po[r]=0;
        for(lli i=1;i<r+1;++i)
        {
            if(po[i]==po[i-1]-1)
                {
                    int z=1;
                    z=z;
                }
                else if(po[i]==po[i-1]-2)
                    dp[po[i]+1]=dp[po[i-1]];
                else
                {
                    dp[po[i]+1]=dp[po[i-1]];
                    dp[po[i]+2]=dp[po[i-1]];
                }
         if(aa[po[i]]==0)
            dp[po[i]]=dp[po[i]+1];
        else
            dp[po[i]]=1+dp[po[i]+1];
        if(po[i]+2<=n&&aa[po[i]+1]==1&&aa[po[i]]==1)
        {
            dp[po[i]]=min(dp[po[i]],dp[po[i]+2]);
        }
        else if(po[i]+2<=n&&aa[po[i]+1]==0&&aa[po[i]]==0)
            dp[po[i]]=min(dp[po[i]],dp[po[i]+2]+2);
        else if(po[i]+2<=n)
            dp[po[i]]=min(dp[po[i]],dp[po[i]+2]+1);
        if(i==r)
        {
            dp[0]=dp[po[i]+1];
            if(po[i]+2<=n&&aa[po[i]+1]==1)
         dp[0]=min(dp[po[i]],dp[po[i]+2]);
         else if(po[i]+2<=n)
         dp[0]=min(dp[po[i]],dp[po[i]+2]+1);
        }
        //if(t==2)
          // cout<<dp[po[i]]<<' '<<po[i]<<i<<endl;
        }
        cout<<dp[0]<<endl;
    }
}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)

typedef long long int lli;
typedef pair <int, int> ii;
typedef vector <int> vi;

int main()
{
    lli t;

    cin>>t;
    for(;t>0;--t)
    {
        lli n,r;
        cin>>n>>r;
        lli aa[n+1];
        lli dp[n+1];
        dp[n]=0;
        if(n==1)
            cout<<0<<endl;
        else
        {
        for(lli i=0;i<n+1;++i)
           {
            aa[i]=0;
            dp[i]=10000000000;
        }
        for(lli i=0;i<r;++i)
        {
            lli j;
            cin>>j;
            aa[j]=1;
        }
        if(aa[n-1]==0)
            dp[n-1]=0;
        else
            dp[n-1]=1;
        for(lli i=n-2;i>0;--i)
        {
         if(aa[i]==0)
            dp[i]=dp[i+1];
        else
            dp[i]=1+dp[i+1];
        if(aa[i+1]==1&&aa[i]==1)
        {
            dp[i]=min(dp[i],dp[i+2]);
        }
        else if(aa[i+1]==0&&aa[i]==0)
            dp[i]=min(dp[i],dp[i+2]+2);
        else
            dp[i]=min(dp[i],dp[i+2]+1);
        }
        if(aa[1]==1)
            cout<<min(dp[1],dp[2])<<endl;
        else
            cout<<min(dp[1],dp[2]+1)<<endl;
    }
}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)

typedef long long int lli;
typedef pair <int, int> ii;
typedef vector <int> vi;

int main()
{
    lli t;

    cin>>t;
    for(;t>0;--t)
    {
        int n,r;
        cin>>n>>r;
        map<lli,lli> aa;
        map<lli,lli> dp;
        int po[r+1];
        if(n==1)
            cout<<0<<endl;
        else
        {
        for(lli i=0;i<r;++i)
        {
            lli j;
            cin>>j;
            aa[j]=1;
            po[i]=j;
        }
        dp[n]=0;
        if(aa[n-1]==0)
            dp[n-1]=0;
        else
            dp[n-1]=1;
        po[r]=0;
        for(lli i=0;i<r+1;++i)
        {
            if(po[i]==po[i-1]+1)
                {
                    int z=1;
                    z=z;
                }
                else if(po[i]==po[i-1]+2)
                    dp[po[i]-1]=dp[po[i-1]];
                else
                {
                    dp[po[i]-1]=dp[po[i-1]];
                    dp[po[i]-2]=dp[po[i-1]];
                }
         if(aa[po[i]]==0)
            dp[po[i]]=dp[po[i]+1];
        else
            dp[po[i]]=1+dp[po[i]+1];
        if(aa[po[i]+1]==1&&aa[po[i]]==1)
        {
            dp[po[i]]=min(dp[po[i]],dp[po[i]+2]);
        }
        else if(aa[po[i]+1]==0&&aa[po[i]]==0)
            dp[po[i]]=min(dp[po[i]],dp[po[i]+2]+2);
        else
            dp[po[i]]=min(dp[po[i]],dp[po[i]+2]+1);
        }
        cout<<dp[0]<<endl;
    }
}
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ll t;
cin>>t;
while(t--)
{
    ll n,m,i,j,a;
    cin>>n>>m;
map<ll,ll>mp;
    for(i=0;i<m;i++)
{
    cin>>a;
    mp[a]++;
}
    a=n;
    ll c=0;
    while(n>2)
    {

        if(mp[n-1])
        {

         if(!mp[n-2])
         {
             c++;
         }
         n-=2;
        }
        else
        {
            n--;
        }
    }
    cout<<c<<endl;
}
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ll t;
cin>>t;
while(t--)
{
    ll n,m,i,j,a,c=0;
    cin>>n>>m;
vector<ll>v(m);
for(i=0;i<m;i++)
    cin>>v[i];
a=n,i=0;
while(i<m && a>2)
{
    if(i<m-2)
    {

    if(v[i+1]+1==a)
    {
        if(v[i+2]+1==v[i+1])
        {
            i+=2;
            a-=2;
        }
        else
        {
            c++;
            a=v[i+2]+1;
            i++;
        }
    }
    else
    {
        a=v[i+1]+1;

    }
}
else if(m==1)
{
    c=0;
    break;
}
else {
   if(v[i+1]>1)
   {
       c++;
   }
   a=0;
}
}
cout<<c<<endl;

}

}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ll t;
cin>>t;
while(t--)
{
    ll n,m,i,j,a,c=0;
    cin>>n>>m;
vector<ll>v(m);
for(i=0;i<m;i++)
    cin>>v[i];
a=n,i=0;
while(i<m && a>2)
{
    if(i<m-2)
    {

    if(v[i+1]+1==a)
    {
        if(v[i+2]+1==v[i+1])
        {
            i+=2;
            a-=2;
        }
        else
        {
            c++;
            a=v[i+2]+1;
            i++;
        }
    }
    else
    {
        a=v[i+1]+1;

    }
}
else if(i==m-1)
{
    c=0;
    break;
}
else {
        if(a==v[i])
        {
   if(v[i+1]>1)
   {
       c++;
   }
   a=0;
        }
        else
        {

        }
}
}
cout<<c<<endl;

}

}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ll t;
cin>>t;
while(t--)
{
    ll n,m,i,j,a,c=0;
    cin>>n>>m;
vector<ll>v(m);
for(i=0;i<m;i++)
    cin>>v[i];
a=n,i=0;
while(i<m && a>2)
{
    if(i<m-2)
    {

    if(v[i+1]+1==a)
    {
        if(v[i+2]+1==v[i+1])
        {
            i+=2;
            a-=2;
        }
        else
        {
            c++;
            a=v[i+2]+1;
            i++;
        }
    }
    else
    {
        a=v[i+1]+1;

    }
}
else if(i==m-1)
{
    c=0;
    break;
}
else {

   if(v[i+1]>1)
   {
       c++;
   }
   a=0;

}
}
cout<<c<<endl;

}

}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ll t;
cin>>t;
while(t--)
{
    ll n,m,i,j,a,c=0;
    cin>>n>>m;
vector<ll>v(m);
for(i=0;i<m;i++)
    cin>>v[i];
a=n,i=0;
while(i<m && a>2)
{
    if(i<m-2)
    {

    if(v[i+1]+1==a)
    {
        if(v[i+2]+1==v[i+1])
        {
            i+=2;
            a-=2;
        }
        else
        {
            c++;
            a=v[i+2]+1;
            i++;
        }
    }
    else
    {
        a=v[i+1]+1;

    }
}
else if(i==m-1)
{
    break;
}
else {

   if(v[i+1]>1)
   {
       c++;
   }
 break;

}
}
cout<<c<<endl;

}

}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ll t;
cin>>t;
while(t--)
{
    ll n,m,i,j,a,c=0;
    cin>>n>>m;
vector<ll>v(m);
for(i=0;i<m;i++)
    cin>>v[i];
a=n,i=0;
while(i<m && a>2)
{
    if(i<m-2)
    {

    if(v[i+1]+1==a)
    {
        if(v[i+2]+1==v[i+1])
        {
            i+=2;
            a-=2;
        }
        else
        {
            c++;
            a=v[i+2]+1;
            i++;
        }
    }
    else
    {
        a=v[i+1]+1;
        i++;
    }
}
else if(m==1)
{
    c=0;
    break;
}
else {
   if(v[i+1]>1)
   {
       c++;
   }
   a=0;
}
}
cout<<c<<endl;

}

}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ll t;
cin>>t;
while(t--)
{
    ll n,m,i,j,a,c=0;
    cin>>n>>m;
vector<ll>v(m);
for(i=0;i<m;i++)
    cin>>v[i];
a=n,i=0;
while(i<m && a>2)
{
    if(i<m-2)
    {

    if(v[i+1]+1==a)
    {
        if(v[i+2]+1==v[i+1])
        {
            i+=2;
            a-=2;
        }
        else
        {
            c++;
            a=v[i+2]+1;
            i++;
        }
    }
    else
    {
        a=v[i+1]+1;
        i++;
    }
}
else {
   if(v[i+1]>1)
   {
       c++;
   }
   a=0;
}
}
cout<<c<<endl;

}

}


// C++ implementation of the approach
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cmath>

int main(){
    long long int t;
    cin>>t;
    for(int i=0;i<t;i++){
        long long int n,k,tmp,tmp1,tmp2,sum=0,ans=0,count=0,flag=0,x,y,h;
        cin>>h>>n;
        set<long long int > s;
        for(int j=0;j<n;j++){
            cin>>x;
            s.insert(x);
        }
        auto it=s.rbegin();
        tmp=*it;
        it++;
        for(it;it!=s.rend();it++){
            if(tmp-*it==1){
                tmp=*it;
                if(s.find(tmp-1)!=s.end()){
                    tmp=tmp-1;
                }
                else{
                    count++;
                    tmp=tmp-1;
                }
            }
            else if(tmp-*it==2){
                tmp=*it;
            }
            else{
                tmp=*it+1;

            }
        }
        cout<<count<<"\n";

    }

}


// C++ implementation of the approach
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cmath>

int main(){
    long long int t;
    cin>>t;
    for(int i=0;i<t;i++){
        long long int n,k,tmp,tmp1,tmp2,sum=0,ans=0,count=0,flag=0,x,y,h;
        cin>>h>>n;
        set<long long int > s;
        for(int j=0;j<n;j++){
            cin>>x;
            s.insert(x);
        }
        auto it=s.rbegin();
        tmp=*it;
        it++;
        for(it;it!=s.rend();it++){
            if(tmp-*it==1){

                if(tmp<=2){
                    break;
                }
                tmp=*it;
                if(s.find(tmp-1)!=s.end()){
                    tmp=tmp-1;
                    it++;
                }
                else{
                    count++;
                    tmp=tmp-1;
                }
            }
            else{
                tmp=*it+1;
                --it;

            }
        }
        cout<<tmp<<"\n";

    }

}


// C++ implementation of the approach
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cmath>

int main(){
    long long int t;
    cin>>t;
    for(int i=0;i<t;i++){
        long long int n,k,tmp,tmp1,tmp2,sum=0,ans=0,count=0,flag=0,x,y,h;
        cin>>h>>n;
        set<long long int > s;
        for(int j=0;j<n;j++){
            cin>>x;
            s.insert(x);
        }
        auto it=s.rbegin();
        tmp=*it;
        it++;
        for(it;it!=s.rend();it++){
            if(it==s.rend()){
                break;
                }
            if(tmp-*it==1){
                tmp=*it;
                it++;
                if(it==s.rend()){
                    break;
                    }
                if(tmp-*it==1){
                    tmp=*it;
                }
                else{
                    count++;
                    tmp=tmp-2;
                }
            }
            else if(tmp-*it==2){
                tmp=*it;
            }
            else{
                tmp=*it+1;

            }
        }

        cout<<count<<"\n";

    }

}


// C++ implementation of the approach
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cmath>

int main(){
    long long int t;
    cin>>t;
    for(int i=0;i<t;i++){
        long long int n,k,tmp,tmp1,tmp2,sum=0,ans=0,count=0,flag=0,x,y,h;
        cin>>h>>n;
        set<long long int > s;
        for(int j=0;j<n;j++){
            cin>>x;
            s.insert(x);
        }
        auto it=s.rbegin();
        tmp=*it;
        it++;
        for(it;it!=s.rend();it++){
            if(tmp-*it==1){
                tmp=*it;
                //it++;
                if(tmp<=2){
                    break;
                }
                if(s.find(tmp-1)!=s.end()){
                    tmp=tmp-1;
                    it++;
                }
                else{
                    count++;
                    tmp=tmp-1;
                }
            }
            else{
                tmp=*it+1;
                --it;

            }
        }
        cout<<count<<"\n";

    }

}


// C++ implementation of the approach
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cmath>

int main(){
    long long int t;
    cin>>t;
    for(int i=0;i<t;i++){
        long long int n,k,tmp,tmp1,tmp2,sum=0,ans=0,count=0,flag=0,x,y,h;
        cin>>h>>n;
        set<long long int > s;
        for(int j=0;j<n;j++){
            cin>>x;
            s.insert(x);
        }
        auto it=s.end();
        --it;
        tmp=*it;
        while(tmp>2){
            if(s.find(tmp-1)!=s.end()){
                if(s.find(tmp-2)!=s.end()){
                    tmp--;
                    tmp--;
                }
                else{
                    count++;
                    tmp--;
                    tmp--;
                }
            }
            else{
                tmp--;
            }
        }
        cout<<count<<"\n";

    }

}


// C++ implementation of the approach
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cmath>

int main(){
    long long int t;
    cin>>t;
    for(int i=0;i<t;i++){
        long long int n,k,tmp,tmp1,tmp2,sum=0,ans=0,count=0,flag=0,x,y,h;
        cin>>h>>n;
        set<long long int > s;
        for(int j=0;j<n;j++){
            cin>>x;
            s.insert(x);
        }
        auto it=s.rbegin();
        tmp=*it;
        it++;
        for(it;it!=s.rend();it++){
            if(tmp-*it==1){
                tmp=*it;
                if(s.find(tmp-1)!=s.end()){
                    tmp=tmp-1;
                }
                else{
                    count++;
                }
            }
            else if(tmp-*it==2){
                tmp=*it;
            }
            else{
                tmp=*it+1;

            }
        }
        cout<<count<<"\n";

    }

}


// C++ implementation of the approach
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cmath>

int main(){
    long long int t;
    cin>>t;
    for(int i=0;i<t;i++){
        long long int n,k,tmp,tmp1,tmp2,sum=0,ans=0,count=0,flag=0,x,y,h;
        cin>>h>>n;
        set<long long int > s;
        for(int j=0;j<n;j++){
            cin>>x;
            s.insert(x);
        }
        auto it=s.rbegin();
        tmp=*it;
        it++;
        for(it;it!=s.rend();it++){
            if(tmp-*it==1){
                tmp=*it;
                if(tmp<=1){
                    break;
                }
                if(s.find(tmp-1)!=s.end()){
                    tmp=tmp-1;
                    it++;
                }
                else{
                    count++;
                    tmp=tmp-1;
                }
            }
            else{
                tmp=*it+1;
                --it;

            }
        }
        cout<<count<<"\n";

    }

}


// C++ implementation of the approach
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cmath>

int main(){
    long long int t;
    cin>>t;
    for(int i=0;i<t;i++){
        long long int n,k,tmp,tmp1,tmp2,sum=0,ans=0,count=0,flag=0,x,y,h;
        cin>>h>>n;
        set<long long int > s;
        for(int j=0;j<n;j++){
            cin>>x;
            s.insert(x);
        }
        auto it=s.rbegin();
        tmp=*it;
        it++;
        for(it;it!=s.rend();it++){
            if(tmp-*it==1){
                tmp=*it;
                it++;
                if(it==s.rend()){
                    if(tmp!=2){
                        count++;
                    }
                    break;
                }
                if(tmp-*it==1){
                    tmp=*it;
                }
                else{
                    count++;
                    tmp=tmp-2;
                }
            }
            else if(tmp-*it==2){
                tmp=*it;
            }
            else{
                tmp=*it+1;

            }
        }
        cout<<count<<"\n";

    }

}


#include<bits/stdc++.h>
#define ll long long int
#define forn(i,n) for(int i=0;i<n;i++)
const ll MOD= 1000000007;
const ll L= 1e18;
using namespace std;
#define mem(x, y) memset(x, y, sizeof(x));
typedef map<ll, ll> MLL;
typedef pair<ll, ll> PLL;
typedef vector<vector<ll>> VLL;
typedef vector<ll> VL;

int main(){
	ll t;
	cin>>t;
	while(t--){
		ll h, n;
		cin>>h>>n;
		VL v(n);
		forn( i, n) cin>>v[i];
		if(n==1){
			cout<<0<<endl;
			return 0;
		}
		sort(v.begin(), v.end(), greater<ll>());
		ll ans=0;
		for(ll i=0;i<n-2;i++){
			if(v[i+1]-v[i+2]==1){
				i++;
			}
			else ans++;
		}
		if(v[n-1]!= 1 && v[n-2]-v[n-1]!= 1)
		ans++;
		cout<<ans<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define forn(i,n) for(int i=0;i<n;i++)
const ll MOD= 1000000007;
const ll L= 1e18;
using namespace std;
#define mem(x, y) memset(x, y, sizeof(x));
typedef map<ll, ll> MLL;
typedef pair<ll, ll> PLL;
typedef vector<vector<ll>> VLL;
typedef vector<ll> VL;

int main(){
	ll t;
	cin>>t;
	while(t--){
		ll h, n;
		cin>>h>>n;
		VL v(n);
		forn( i, n) cin>>v[i];
		if(n==1){
			cout<<0<<endl;
			continue;
		}
		sort(v.begin(), v.end(), greater<ll>());
		ll ans=0;
		for(ll i=0;i<n-2;i++){
			if(v[i+1]-v[i+2]==1){
				i++;
			}
			else ans++;
		}
		if(v[n-1]!= 1 && v[n-2]-v[n-1]!= 1)
		ans++;
		cout<<ans<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define forn(i,n) for(int i=0;i<n;i++)
const ll MOD= 1000000007;
const ll L= 1e18;
using namespace std;
#define mem(x, y) memset(x, y, sizeof(x));
typedef map<ll, ll> MLL;
typedef pair<ll, ll> PLL;
typedef vector<vector<ll>> VLL;
typedef vector<ll> VL;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	cin>>t;
	while(t--){
		ll h, n;
		cin>>h>>n;
		VL v(n), dp(n, 1);
		dp[0]= 0;
		forn( i, n) cin>>v[i];
		sort(v.begin(), v.end(), greater<ll>());
		ll ans=0;
		for(ll i=1;i<n-1;i++)
		if(v[i]==v[i+1]+1){
			ans++;
			i++;
		}

		cout<<ans<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define forn(i,n) for(int i=0;i<n;i++)
const ll MOD= 1000000007;
const ll L= 1e18;
using namespace std;
#define mem(x, y) memset(x, y, sizeof(x));
typedef map<ll, ll> MLL;
typedef pair<ll, ll> PLL;
typedef vector<vector<ll>> VLL;
typedef vector<ll> VL;

int main(){
	ll t;
	cin>>t;
	while(t--){
		ll h, n;
		cin>>h>>n;
		VL v(n);
		forn( i, n) cin>>v[i];
		if(n==1){
			cout<<0<<endl;
			continue;
		}
		sort(v.begin(), v.end(), greater<ll>());
		ll ans=0, mn= h;
		for(ll i=0;i<n-2;i++){
			if(v[i+1]-v[i+2]==1){
				mn= i+2;
				i++;
			}
			else ans++;
		}
		ans+= (mn== n-2);
		cout<<ans<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define forn(i,n) for(int i=0;i<n;i++)
const ll MOD= 1000000007;
const ll L= 1e18;
using namespace std;
#define mem(x, y) memset(x, y, sizeof(x));
typedef map<ll, ll> MLL;
typedef pair<ll, ll> PLL;
typedef vector<vector<ll>> VLL;
typedef vector<ll> VL;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	cin>>t;
	while(t--){
		ll h, n;
		cin>>h>>n;
		VL v(n), dp(n, 0);
		dp[1]= 1;
		forn( i, n) cin>>v[i];
		if(n==1){
			cout<<0<<endl;
			return 0;
		}
		sort(v.begin(), v.end(), greater<ll>());
		ll ans=0;
		for(ll i=0;i<n-2;i++){
			if(v[i+1]-v[i+2]==1){
				i++;
			}
			else ans++;
		}
		if(v[n-1]!= 1 && v[n-2]-v[n-1]!= 1)
		ans++;
		cout<<ans<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define forn(i,n) for(int i=0;i<n;i++)
const ll MOD= 1000000007;
const ll L= 1e18;
using namespace std;
#define mem(x, y) memset(x, y, sizeof(x));
typedef map<ll, ll> MLL;
typedef pair<ll, ll> PLL;
typedef vector<vector<ll>> VLL;
typedef vector<ll> VL;

int main(){
	ll t;
	cin>>t;
	while(t--){
		ll h, n;
		cin>>h>>n;
		VL v(n);
		forn( i, n) cin>>v[i];
		if(n==1){
			cout<<0<<endl;
			continue;
		}
		sort(v.begin(), v.end(), greater<ll>());
		ll ans=0, mn= 0;
		for(ll i=0;i<n-2;i++){
			if(v[i+1]-v[i+2]==1){
				mn= i+2;
				i++;
			}
			else {
				mn= i+1;
				ans++;
			}
		}
		if(v[n-1]!= 1 && mn==n-2)
		ans++;
		cout<<ans<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define forn(i,n) for(int i=0;i<n;i++)
const ll MOD= 1000000007;
const ll L= 1e18;
using namespace std;
#define mem(x, y) memset(x, y, sizeof(x));
typedef map<ll, ll> MLL;
typedef pair<ll, ll> PLL;
typedef vector<vector<ll>> VLL;
typedef vector<ll> VL;

int main(){
	ll t;
	cin>>t;
	while(t--){
		ll h, n;
		cin>>h>>n;
		VL v(n);
		forn( i, n) cin>>v[i];
		if(n==1){
			cout<<0<<endl;
			continue;
		}
		sort(v.begin(), v.end(), greater<ll>());
		ll ans=0, mn= 0;
		for(ll i=0;i<n-2;i++){
			if(v[i+1]-v[i+2]==1){
				mn= i+2;
				i++;
			}
			else ans++;
		}
		if(v[n-1]!= 1 && mn==n-2)
		ans++;
		cout<<ans<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;

const ll inf = int(1e9);
const ll mod = inf + 7;
const int N = 1e6 + 555;
const double PI = acos(-1.0);

void solve()
{
	int A = 0, B = 0;
	int h, n;
	cin >> h >> n;
	vector<int> p;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		p.pb(x);
	}
	ll sum = 0;
	ll last = 0;
	for(int i = 1; i < n; ++i){
		if(p[i] + 1 == p[i - 1]){
			if(i == n - 1 && p[i] != 1) sum++;
			else{
				if(p[i + 1] + 2 != p[i - 1]){
					sum++;
					i += 2;
				}
			}
		}
	}
	cout << sum << endl;

}

int main()
{
    Red;
 	int T;
 	cin >> T;
 	while(T--)
    solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;

const ll inf = int(1e9);
const ll mod = inf + 7;
const int N = 1e6 + 555;
const double PI = acos(-1.0);

void solve()
{
	int A = 0, B = 0;
	int h, n;
	cin >> h >> n;
	vector<int> p;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		p.pb(x);
	}
	ll sum = 0;
	ll last = 0;
	for(int i = 1; i < n - 1; ++i){
		if(p[i] + 1 == p[i - 1] && p[i - 1] == p[i + 1] + 2){
			i += 2;
		}
		else{
			sum++;
		}
	}
	if(n > 1 && p[n - 2] - p[n - 1] != 2){
		sum++;
	}
	cout << sum << endl;
}

int main()
{
    Red;
 	int T;
 	cin >> T;
 	while(T--)
    solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;

const ll inf = int(1e9);
const ll mod = inf + 7;
const int N = 1e6 + 555;
const double PI = acos(-1.0);

void solve()
{
	int h, n;
	cin >> h >> n;
	int res = 0;
	int a[n];
	for(int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}

	for(int i = 1; i < n; ++i){
		if(i == n - 1){
			if(a[i] != 1)
			res++;
		}
		else{
			if(i + 1 < n && a[i] - a[i + 1] == 1) i++;
			else res++;
		}
	}
	cout << res << '\n';
}

int main()
{
	Red;
	int T;
	cin >> T;
	while(T--)
    solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;

const ll inf = int(1e9);
const ll mod = inf + 7;
const int N = 1e6 + 555;
const double PI = acos(-1.0);

void solve()
{
	int A = 0, B = 0;
	int h, n;
	cin >> h >> n;
	vector<int> p;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		p.pb(x);
	}
	ll sum = 0;
	ll last = 0;
	for(int i = 1; i < n - 1; ++i){
		if(p[i] + 1 == p[i - 1] && p[i - 1] == p[i + 1] + 2){
			sum++;
			i++;
		}
	}
	if(n > 1 && p[n - 2] - p[n - 1] != 2){
		sum++;
	}
	cout << sum << endl;
}

int main()
{
    Red;
 	int T;
 	cin >> T;
 	while(T--)
    solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;

const ll inf = int(1e9);
const ll mod = inf + 7;
const int N = 1e6 + 555;
const double PI = acos(-1.0);

void solve()
{
	int A = 0, B = 0;
	int h, n;
	cin >> h >> n;
	vector<int> p;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		p.pb(x);
	}
	ll sum = 0;
	ll last = 0;
	for(int i = 1; i < n - 1; ++i){
		if(p[i] + 1 == p[i - 1] && p[i - 1] - p[i + 1] != 2){
			sum++;
			i++;
		}
	}
	cout << sum << endl;

}

int main()
{
    Red;
 	int T;
 	cin >> T;
 	while(T--)
    solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;

const ll inf = int(1e9);
const ll mod = inf + 7;
const int N = 1e6 + 555;
const double PI = acos(-1.0);

void solve()
{
	int A = 0, B = 0;
	int h, n;
	cin >> h >> n;
	vector<int> p;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		p.pb(x);
	}
	ll sum = 0;
	ll last = 0;
	for(int i = 1; i < n - 1; ++i){
		if(p[i] + 1 == p[i - 1] && p[i - 1] - p[i + 1] != 2){
			sum++;
		}
	}
	cout << sum << endl;

}

int main()
{
    Red;
 	int T;
 	cin >> T;
 	while(T--)
    solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;

const ll inf = int(1e9);
const ll mod = inf + 7;
const int N = 1e6 + 555;
const double PI = acos(-1.0);

void solve()
{
	int A = 0, B = 0;
	int h, n;
	cin >> h >> n;
	vector<int> p;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		p.pb(x);
	}
	ll sum = 0;
	ll last = 0;
	for(int i = 1; i < n - 1; ++i){
		if(p[i] + 1 == p[i - 1] && p[i - 1] == p[i + 1] + 2){
			i += 2;
		}
		else{
			sum++;
			i++;
		}
	}
	if(n > 1 && p[n - 2] - p[n - 1] != 2){
		sum++;
	}
	cout << sum << endl;
}

int main()
{
    Red;
 	int T;
 	cin >> T;
 	while(T--)
    solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;

const ll inf = int(1e9);
const ll mod = inf + 7;
const int N = 1e6 + 555;
const double PI = acos(-1.0);

void solve()
{
	int A = 0, B = 0;
	int h, n;
	cin >> h >> n;
	vector<int> p;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		p.pb(x);
	}
	ll sum = 0;
	ll last = 0;
	for(int i = 1; i < n - 1; ++i){
		if(p[i] + 1 == p[i - 1] && p[i - 1] - p[i + 1] != 2){
			sum++;
			i += 2;
		}
	}
	cout << sum << endl;

}

int main()
{
    Red;
 	int T;
 	cin >> T;
 	while(T--)
    solve();
    return 0;
}


#include <iostream>
using namespace std;
#define ll long long
#define nl '\n'
#define vale(x) while(x--)
#define benfero freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
int main(){
	//benfero
	int q;
	cin >>q;
	while(q--){
		int n,ans=0,degi;
		cin >>n;
		int m;
		cin >>m;
		cin>>degi;
		if(m==1){
			cout<<0<<nl;
			continue;
		}
		if(m==2){
			cin>>degi;
			if(degi==1){
				cout<<0<<nl;
				continue;
			}
			cout<<1<<nl;
			continue;
		}
		int onc;
		cin >>onc;
		int kac=1;
		int son;
		while(m-->2){
			cin>>son;
			//cout<<onc<<' '<<son<<' '<<kac<<nl;
			if(onc-son==1){
				kac++;
			}
			else{
				if(kac%2)ans++;
				kac=1;
			}
			onc=son;
		}
		cout<<ans<<nl;
	}
}


#include <iostream>
#include <queue>
using namespace std;
#define ll long long
#define nl '\n'
#define vale(x) while(x--)
#define benfero freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
int main(){
	//benfero
	int q;
	cin >>q;
	while(q--){
		queue <int>q;
		int n,ans=0,degi;
		cin >>n;
		int m;
		cin >>m;
		cin>>degi;
		if(m==1){
			cout<<0<<nl;
			continue;
		}
		if(m==2){
			cin>>degi;
			if(degi==1){
				cout<<0<<nl;
				continue;
			}
			cout<<1<<nl;
			continue;
		}
		int kac;
		int son;
		while(m-->1){
			cin>>son;
			q.push(son);
		}
		while(q.size()){
			kac=1;
			int a=q.front();
			q.pop();
			while(q.size() && a-q.front()==1){
				kac++;
				a=q.front();
				q.pop();
			}
			if(a==1)continue;
			ans+=kac%2;
		}
		cout<<ans<<nl;
	}
}


#include <iostream>
using namespace std;
#define ll long long
#define nl '\n'
#define vale(x) while(x--)
#define benfero freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
int main(){
	//benfero
	int q;
	cin >>q;
	while(q--){
		int n,ans=0,degi;
		cin >>n;
		int m;
		cin >>m;
		if(m==1){
			cin>>degi;
			cout<<0<<nl;
			continue;
		}
		if(m==2){
			cin>>degi;
			cin>>degi;
			if(degi==1){
				cout<<0<<nl;
				continue;
			}
			cout<<1<<nl;
			continue;
		}
		int onc;
		cin >>onc;
		cin >>onc;
		int kac=1;
		int son;
		while(m-->2){
			cin>>son;
			//cout<<onc<<' '<<son<<' '<<kac<<nl;
			if(onc-son==1){
				kac++;
			}
			else{
				if(kac%2)ans++;
				kac=1;
			}
			onc=son;
		}
		cout<<ans<<nl;
	}
}


#include <iostream>
using namespace std;
#define ll long long
#define nl '\n'
#define vale(x) while(x--)
#define benfero freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
int main(){
	//benfero
	int q;
	cin >>q;
	while(q--){
		int n,ans=0,degi;
		cin >>n;
		int m;
		cin >>m;
		cin>>degi;
		if(m==1){
			cout<<0<<nl;
			continue;
		}
		if(m==2){
			cin>>degi;
			if(degi==1){
				cout<<0<<nl;
				continue;
			}
			cout<<1<<nl;
			continue;
		}
		int onc;
		cin >>onc;
		int kac=1;
		int son;
		while(m-->2){
			cin>>son;
			//cout<<onc<<' '<<son<<' '<<kac<<nl;
			if(onc-son==1){
				kac++;
			}
			else{
				if(kac%2)ans++;
				kac=1;
			}
			onc=son;
		}
		if(onc!=1 and kac==1)ans++;
		cout<<ans<<nl;
	}
}


#include <iostream>
using namespace std;
#define ll long long
#define nl '\n'
#define vale(x) while(x--)
#define benfero freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
int main(){
	//benfero
	int q;
	cin >>q;
	while(q--){
		int n,ans=0;
		cin >>n;
		bool ar[n+1]={};
		int m;
		cin >>m;
		for(int i=0;i<m;i++){
			int a;
			cin >>a;
			ar[a]=1;
		}
		int kac=0;
		for(int i=n;i>2;i--){
			if(ar[i]){
				ar[i-1]=!ar[i-1];
			}
			else{
				kac++;
			}
			if(kac==2){
				ans++;
				kac=0;
			}
		}
		cout<<ans<<nl;
	}
}


#include <iostream>
using namespace std;
#define ll long long
#define nl '\n'
#define vale(x) while(x--)
#define benfero freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
int main(){
	//benfero
	int q;
	cin >>q;
	while(q--){
		int n,ans=0;
		cin >>n;
		bool ar[n+1]={};
		int m;
		cin >>m;
		for(int i=0;i<m;i++){
			int a;
			cin >>a;
			ar[a]=1;
		}
		int kac=0;
		for(int i=n;i>0;i--){
			if(ar[i]){
				if(i)
					ar[i-1]=!ar[i-1];
			}
			else{
				kac++;
			}
			if(kac==2){
				if(i)
					ar[i-1]=!ar[i-1];
				ans++;
				kac=0;
			}
		}
		cout<<ans<<nl;
	}
}


#include <iostream>
using namespace std;
#define ll long long
#define nl '\n'
#define vale(x) while(x--)
#define benfero freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
int main(){
	//benfero
	int q;
	cin >>q;
	while(q--){
		int n,ans=0;
		cin >>n;
		int m;
		cin >>m;
		int son;
		cin >>son;
		int kac=0;
		int onc=son;
		for(int i=1;i<m;i++){
			cin>>son;
			if(son+1==onc){
				kac++;
			}
			else{
				if(kac%2){
					ans++;
				}
				kac=1;
			}
			onc=son;
		}
		cout<<ans<<nl;
	}
}


#include <iostream>
using namespace std;
#define ll long long
#define nl '\n'
#define vale(x) while(x--)
#define benfero freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
int main(){
	//benfero
	int n,p,wp,dp;
	cin >> n >> p >> wp >> dp;
	if(n<p/wp){
		cout<<-1;
		return 0;
	}
	int w=p/wp;
	bool flag=0;
	int i;
	for(i=0;i<wp;i++){
		if((p-wp*(w-i))%dp==0){
			flag=1;
			break;
		}
	}
	w-=i;
	int d=(p-(w*wp))/dp;
	int l=n-w-d;
	n-=w+d+l;
	if(w>-1 and d>-1 and l>-1 and flag){
		cout<<w<<' '<<d<<' '<<l;
	}
	else{
		cout<<-1;
	}
}


// #define FILE_INPUT
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;
typedef pair<ll, ll> pll;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vll;

#define pb push_back
#define forn(i, n) for(ll i = 0; i < n; ++i)
#define fornm(i, m, n) for(ll i = m; i < n; ++i)
#define rfornm(i, m, n) for(ll i = m; i >= n; --i)
#define fin() for(ll i = 0; i < n; ++i)
#define readvec(vector, n) {ll temp_vec_val;forn(i, n){cin >> temp_vec_val;vector.push_back(temp_vec_val);}}
#define printvec(vector, delimeter) {ll length_of_vector=vector.size();\
                                    forn(i, length_of_vector){cout << vector[i] << delimeter;}}
#define sortvec(vector) sort(vector.begin(), vector.end())

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

unsigned long long bpow(unsigned long long a, int n)
{
    return n ? n & 1 ? bpow(a, n - 1) * a : bpow(a * a, n >> 1) : 1;
}

bool is_upper(char c)
{
    return (c >= 65 && c <= 90); //ascii
}

bool is_lower(char c)
{
    return (c >= 97 && c <= 122); //ascii
}

int get_digit(ll num, int len, int index)
{
    return num / bpow(10, len - index - 1) % 10;
}

ll digit_sum(ll num)
{
    ll dig_sum = 0;
    while(num > 0)
    {
        dig_sum += num % 10;
        num /= 10;
    }
    return dig_sum;
}

const int INF = 1e9 + 7;
const double pi = 2 * acos(0.0);
ll n, m, k, p, q, sum = 0, cnt = 0;
ll mx = INT64_MIN;
ll mn = INT64_MAX;
bool flag = 0;
vll v;
str s = "", s1, s2;

void solve() //n&1 == 0 <=> n % 2 == 0
{
    cin >> m;
    forn(_, m)
    {
        cin >> k >> n;
        vll v;
        readvec(v, n);
        ll i = k;
        ll l = 0;
        while(true)
        {
            if(i <= 2 || l == n) break;
            ll next = v[l];
            if(i - next == 0)
            {
                ++l;
                continue;
            }
            else if(i - next == 1)
            {
                ++l;
                --i;
                if(l != n && i - v[l] != 1)
                {
                    ++cnt;
                    --i;
                }
                else if(l != n && i - v[l] == 1)
                {
                    --i;
                    ++l;
                }
                else ++cnt;
            }
            else
            {
                i = next+1;
            }
        }
        cout << cnt << endl;
        cnt = 0;
    }
}

int main()
{
#ifdef FILE_INPUT
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    // cout.precision(19);
    ios::sync_with_stdio(0);
    cin.tie(0);

    solve();

//  memset(v, INT_MAX, 1000*2000*sizeof(int));

    return 0;
}


// #define FILE_INPUT
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;
typedef pair<ll, ll> pll;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vll;

#define pb push_back
#define forn(i, n) for(ll i = 0; i < n; ++i)
#define fornm(i, m, n) for(ll i = m; i < n; ++i)
#define rfornm(i, m, n) for(ll i = m; i >= n; --i)
#define fin() for(ll i = 0; i < n; ++i)
#define readvec(vector, n) {ll temp_vec_val;forn(i, n){cin >> temp_vec_val;vector.push_back(temp_vec_val);}}
#define printvec(vector, delimeter) {ll length_of_vector=vector.size();\
                                    forn(i, length_of_vector){cout << vector[i] << delimeter;}}
#define sortvec(vector) sort(vector.begin(), vector.end())

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

unsigned long long bpow(unsigned long long a, int n)
{
    return n ? n & 1 ? bpow(a, n - 1) * a : bpow(a * a, n >> 1) : 1;
}

bool is_upper(char c)
{
    return (c >= 65 && c <= 90); //ascii
}

bool is_lower(char c)
{
    return (c >= 97 && c <= 122); //ascii
}

int get_digit(ll num, int len, int index)
{
    return num / bpow(10, len - index - 1) % 10;
}

ll digit_sum(ll num)
{
    ll dig_sum = 0;
    while(num > 0)
    {
        dig_sum += num % 10;
        num /= 10;
    }
    return dig_sum;
}

const int INF = 1e9 + 7;
const double pi = 2 * acos(0.0);
ll n, m, k, p, q, sum = 0, cnt = 0;
ll mx = INT64_MIN;
ll mn = INT64_MAX;
bool flag = 0;
vll v;
str s = "", s1, s2;

void solve() //n&1 == 0 <=> n % 2 == 0
{
    cin >> m;
    forn(_, m)
    {
        cin >> k >> n;
        vll v;
        readvec(v, n);
        ll i = k;
        ll l = 0;
        while(true)
        {
            if(i <= 2 || l == n) break;
            ll next = v[l];
            if(i - next == 0)
            {
                ++l;
                continue;
            }
            else if(i - next == 1)
            {
                ++l;
                --i;
                if(l != n && i - v[l] != 1)
                {
                    ++cnt;
                    --i;
                }
                else if(l != n && i - v[l] == 1)
                {
                    --i;
                    ++l;
                }
            }
            else
            {
                --i;
            }
        }
        cout << cnt << endl;
        cnt = 0;
    }
}

int main()
{
#ifdef FILE_INPUT
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    // cout.precision(19);
    ios::sync_with_stdio(0);
    cin.tie(0);

    solve();

//  memset(v, INT_MAX, 1000*2000*sizeof(int));

    return 0;
}


// #define FILE_INPUT
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;
typedef pair<ll, ll> pll;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vll;

#define pb push_back
#define forn(i, n) for(ll i = 0; i < n; ++i)
#define fornm(i, m, n) for(ll i = m; i < n; ++i)
#define rfornm(i, m, n) for(ll i = m; i >= n; --i)
#define fin() for(ll i = 0; i < n; ++i)
#define readvec(vector, n) {ll temp_vec_val;forn(i, n){cin >> temp_vec_val;vector.push_back(temp_vec_val);}}
#define printvec(vector, delimeter) {ll length_of_vector=vector.size();\
                                    forn(i, length_of_vector){cout << vector[i] << delimeter;}}
#define sortvec(vector) sort(vector.begin(), vector.end())

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

unsigned long long bpow(unsigned long long a, int n)
{
    return n ? n & 1 ? bpow(a, n - 1) * a : bpow(a * a, n >> 1) : 1;
}

bool is_upper(char c)
{
    return (c >= 65 && c <= 90); //ascii
}

bool is_lower(char c)
{
    return (c >= 97 && c <= 122); //ascii
}

int get_digit(ll num, int len, int index)
{
    return num / bpow(10, len - index - 1) % 10;
}

ll digit_sum(ll num)
{
    ll dig_sum = 0;
    while(num > 0)
    {
        dig_sum += num % 10;
        num /= 10;
    }
    return dig_sum;
}

const int INF = 1e9 + 7;
const double pi = 2 * acos(0.0);
ll n, m, k, p, q, sum = 0, cnt = 0;
ll mx = INT64_MIN;
ll mn = INT64_MAX;
bool flag = 0;
vll v;
str s = "", s1, s2;

void solve() //n&1 == 0 <=> n % 2 == 0
{
    cin >> m;
    forn(_, m)
    {
        cin >> k >> n;
        ll i = k;
        ll next;
        while(true)
        {
            if(i <= 2 || !n) break;

            if(!flag)
            {
                cin >> next;
                --n;
            }

            if(abs(i - next) == 0)
            {
                continue;
            }
            else if(abs(i - next) == 2)
            {
                --i;
            }
            else if(abs(i - next) == 1)
            {
                --i;
                cin >> next;
                if(n && i - next != 1)
                {
                    flag = 1;
                    ++cnt;
                    --i;
                }
                else if(n && i - next == 1)
                {
                    --i;
                    flag = 1;
                }
            }
            else
            {
                --i;
            }
        }
        cout << cnt << endl;
        cnt = 0;
    }
}

int main()
{
#ifdef FILE_INPUT
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    // cout.precision(19);
    ios::sync_with_stdio(0);
    cin.tie(0);

    solve();

//  memset(v, INT_MAX, 1000*2000*sizeof(int));

    return 0;
}


// #define FILE_INPUT
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;
typedef pair<ll, ll> pll;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vll;

#define pb push_back
#define forn(i, n) for(ll i = 0; i < n; ++i)
#define fornm(i, m, n) for(ll i = m; i < n; ++i)
#define rfornm(i, m, n) for(ll i = m; i >= n; --i)
#define fin() for(ll i = 0; i < n; ++i)
#define readvec(vector, n) {ll temp_vec_val;forn(i, n){cin >> temp_vec_val;vector.push_back(temp_vec_val);}}
#define printvec(vector, delimeter) {ll length_of_vector=vector.size();\
                                    forn(i, length_of_vector){cout << vector[i] << delimeter;}}
#define sortvec(vector) sort(vector.begin(), vector.end())

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

unsigned long long bpow(unsigned long long a, int n)
{
    return n ? n & 1 ? bpow(a, n - 1) * a : bpow(a * a, n >> 1) : 1;
}

bool is_upper(char c)
{
    return (c >= 65 && c <= 90); //ascii
}

bool is_lower(char c)
{
    return (c >= 97 && c <= 122); //ascii
}

int get_digit(ll num, int len, int index)
{
    return num / bpow(10, len - index - 1) % 10;
}

ll digit_sum(ll num)
{
    ll dig_sum = 0;
    while(num > 0)
    {
        dig_sum += num % 10;
        num /= 10;
    }
    return dig_sum;
}

const int INF = 1e9 + 7;
const double pi = 2 * acos(0.0);
ll n, m, k, p, q, sum = 0, cnt = 0;
ll mx = INT64_MIN;
ll mn = INT64_MAX;
bool flag = 0;
vll v;
str s = "", s1, s2;

void solve() //n&1 == 0 <=> n % 2 == 0
{
    cin >> m;
    forn(_, m)
    {
        cin >> k >> n;
        vll v;
        readvec(v, n);
        ll i = k;
        ll l = 0;
        while(true)
        {
            if(i <= 2 || l == n) break;
            ll next = v[l];
            if(i - next == 0)
            {
                ++l;
                continue;
            }
            else if(i - next == 1)
            {
                ++l;
                --i;
                if(l != n && i - v[l] != 1)
                {
                    ++cnt;
                    --i;
                }
                else if(l != n && i - v[l] == 1)
                {
                    --i;
                    ++l;
                }
                else ++cnt;
            }
            else
            {
                --i;
            }
        }
        cout << cnt << endl;
        cnt = 0;
    }
}

int main()
{
#ifdef FILE_INPUT
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    // cout.precision(19);
    ios::sync_with_stdio(0);
    cin.tie(0);

    solve();

//  memset(v, INT_MAX, 1000*2000*sizeof(int));

    return 0;
}


// #define FILE_INPUT
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;
typedef pair<ll, ll> pll;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vll;

#define pb push_back
#define forn(i, n) for(ll i = 0; i < n; ++i)
#define fornm(i, m, n) for(ll i = m; i < n; ++i)
#define rfornm(i, m, n) for(ll i = m; i >= n; --i)
#define fin() for(ll i = 0; i < n; ++i)
#define readvec(vector, n) {ll temp_vec_val;forn(i, n){cin >> temp_vec_val;vector.push_back(temp_vec_val);}}
#define printvec(vector, delimeter) {ll length_of_vector=vector.size();\
                                    forn(i, length_of_vector){cout << vector[i] << delimeter;}}
#define sortvec(vector) sort(vector.begin(), vector.end())

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

unsigned long long bpow(unsigned long long a, int n)
{
    return n ? n & 1 ? bpow(a, n - 1) * a : bpow(a * a, n >> 1) : 1;
}

bool is_upper(char c)
{
    return (c >= 65 && c <= 90); //ascii
}

bool is_lower(char c)
{
    return (c >= 97 && c <= 122); //ascii
}

int get_digit(ll num, int len, int index)
{
    return num / bpow(10, len - index - 1) % 10;
}

ll digit_sum(ll num)
{
    ll dig_sum = 0;
    while(num > 0)
    {
        dig_sum += num % 10;
        num /= 10;
    }
    return dig_sum;
}

const int INF = 1e9 + 7;
const double pi = 2 * acos(0.0);
ll n, m, k, p, q, sum = 0, cnt = 0;
ll mx = INT64_MIN;
ll mn = INT64_MAX;
bool flag = 0;
vll v;
str s = "", s1, s2;

void solve() //n&1 == 0 <=> n % 2 == 0
{
    cin >> m;
    forn(_, m)
    {
        cin >> k >> n;
        vector<short> v(k, 0);
        fin()
        {
            ll temp;
            cin >> temp;
            v[temp-1] = 1;
        }
        ll i = k-1;
        while(true)
        {
            if(i <= 2) break;
            if(v[i] != v[i-1])
            {
                --i;
                v[i-1] ^= 1;
            }
            else if(v[i] == v[i-2])
            {
                i -= 2;
            }
            else
            {
                ++cnt;
                i -= 2;
                v[i-2] = 1;
            }
        }
        cout << cnt << endl;
        cnt = 0;
    }
}

int main()
{
#ifdef FILE_INPUT
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    // cout.precision(19);
    ios::sync_with_stdio(0);
    cin.tie(0);

    solve();

//  memset(v, INT_MAX, 1000*2000*sizeof(int));

    return 0;
}


// #define FILE_INPUT
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;
typedef pair<ll, ll> pll;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vll;

#define pb push_back
#define forn(i, n) for(ll i = 0; i < n; ++i)
#define fornm(i, m, n) for(ll i = m; i < n; ++i)
#define rfornm(i, m, n) for(ll i = m; i >= n; --i)
#define fin() for(ll i = 0; i < n; ++i)
#define readvec(vector, n) {ll temp_vec_val;forn(i, n){cin >> temp_vec_val;vector.push_back(temp_vec_val);}}
#define printvec(vector, delimeter) {ll length_of_vector=vector.size();\
                                    forn(i, length_of_vector){cout << vector[i] << delimeter;}}
#define sortvec(vector) sort(vector.begin(), vector.end())

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

unsigned long long bpow(unsigned long long a, int n)
{
    return n ? n & 1 ? bpow(a, n - 1) * a : bpow(a * a, n >> 1) : 1;
}

bool is_upper(char c)
{
    return (c >= 65 && c <= 90); //ascii
}

bool is_lower(char c)
{
    return (c >= 97 && c <= 122); //ascii
}

int get_digit(ll num, int len, int index)
{
    return num / bpow(10, len - index - 1) % 10;
}

ll digit_sum(ll num)
{
    ll dig_sum = 0;
    while(num > 0)
    {
        dig_sum += num % 10;
        num /= 10;
    }
    return dig_sum;
}

const int INF = 1e9 + 7;
const double pi = 2 * acos(0.0);
ll n, m, k, p, q, sum = 0, cnt = 0;
ll mx = INT64_MIN;
ll mn = INT64_MAX;
bool flag = 0;
vll v;
str s = "", s1, s2;

void solve() //n&1 == 0 <=> n % 2 == 0
{
    cin >> m;
    forn(_, m)
    {
        cin >> k >> n;
        queue<ll> q;
        forn(i, n)
        {
            ll temp;
            cin >> temp;
            q.push(temp);
        }
        q.push(0);
        ll i = k;
        while(true)
        {
            if(i <= 2 || q.empty()) break;
            ll next = q.front();
            if(abs(i - next) == 0)
            {
                q.pop();
                continue;
            }
            else if(abs(i - next) == 2)
            {
                --i;
            }
            else if(abs(i - next) == 1)
            {
                q.pop();
                --i;
                if(!q.empty() && i - q.front() != 1)
                {
                    ++cnt;
                    --i;
                }
                else if(!q.empty() && i - q.front() == 1)
                {
                    --i;
                    q.pop();
                }
            }
            else
            {
                --i;
            }
        }
        cout << cnt << endl;
        cnt = 0;
    }
}

int main()
{
#ifdef FILE_INPUT
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    // cout.precision(19);
    ios::sync_with_stdio(0);
    cin.tie(0);

    solve();

//  memset(v, INT_MAX, 1000*2000*sizeof(int));

    return 0;
}