// Hash: nJTb/iLMB+KcMg9WA3a4VwUF3thoMlfqD0q4sfb4nt8=

import java.security.*;
import java.util.*;
import java.nio.file.*;
import java.lang.annotation.*;
import java.util.stream.*;
import java.text.*;
import java.util.function.*;
import java.nio.charset.*;
import java.io.*;
import java.util.concurrent.*;
import java.lang.reflect.*;
import java.math.*;

// Solution can be found in Submission.testCase(). psvm method can be found in Main.main(String[] args)
// Please note that the code isn't obfuscated; only compressed

public class Solution {
    public static void main(String[] args) throws Exception {
        Main.main(args);
    }
}

class Main{public static void main(String[]args)throws Exception{new TaskC().runSubmission();}};

@ContestSubmission(ContestType.CODEFORCES)
@CacheVersion(0)
class TaskC extends AbstractSubmission {

	@Override
	public void testCase() {
		int t = sc.nextInt();
		outer: for (int it = 0; it < t; it++) {
			int h = sc.nextInt();
			int n = sc.nextInt();
			TreeSet<Integer> set = new TreeSet<>();
			for (int i = 0; i < n; i++) {
				set.add(sc.nextInt());
			}

			int total = 0;

			while (!set.isEmpty()) {
				int x = set.last();
				if (x == 1) break;
				set.remove(x);
				if (set.contains(x - 1)) {
					set.remove(x - 1);
				} else {
					set.add(x - 1);
				}
				int u = set.isEmpty() ? 1 : set.last();
				if (x - u > 2) {
					total++;
					set.add(x - 2);
				}
			}

			out.println(total);
		}
	}

	@Override
	public void init() {
		// Nothing here! Good for initializing look-up tables

		// Note that there could be multiple Problem instances running on different threads. Writing static variables
		// here (or anywhere else) could lead to race conditions! Use static initialization instead
	}

	// Set to TRUE to override default (which may both be true or false). Setting to FALSE has no effect

	/* DISABLE-CODE-COMPRESSION: TRUE */
	/* GLOBAL-DISABLE-CODE-COMPRESSION: DEFAULT */
	/* JAVA-6-COMPATIBILITY-MODE: DEFAULT */
	/* KEEP-UNUSED-DEPENDENCIES: DEFAULT */

};

abstract class AbstractSubmission{public Scanner sc;public InputStream in;public PrintStream out;public PrintStream debug;public volatile double score=0;public volatile int testCaseCount=-1;public volatile int testCaseIndex;public volatile double progress=0;public void runSubmission(){runSubmission(false);}public void runSubmission(boolean debug){runSubmission(System.in,System.out,debug);}public void runSubmission(InputStream in,PrintStream out){runSubmission(in,out,false);}public void runSubmission(InputStream in,PrintStream out,boolean debug){runSubmission(in,out,debug?out:new VoidPrintStream());}public void runSubmission(InputStream in,OutputStream out,OutputStream debug){this.in=in;this.sc=new Scanner(this.in);this.out=new PrintStream(out);this.debug=debug instanceof VoidOutputStream?new VoidPrintStream():new PrintStream(debug);ContestType type=getType();testCaseCount=type.testCaseCount;init();if(testCaseCount<=0){testCaseCount=sc.nextInt();sc.nextLine();}testCaseIndex=0;for(testCaseIndex=1;testCaseIndex<=testCaseCount;testCaseIndex++){progress=0;this.out.printf(type.caseString,testCaseIndex,testCaseCount);testCase();}}public ContestType getType(){return getType(getClass());}public static ContestType getType(Class<?extends AbstractSubmission>clss){return getAnnotation(clss).value();}private static ContestSubmission getAnnotation(Class<?extends AbstractSubmission>clss){if(!clss.isAnnotationPresent(ContestSubmission.class)){throw new RuntimeException("ContestSubmission annotation not present on class "+clss.getCanonicalName()+"!");}return clss.getAnnotation(ContestSubmission.class);}private static String b64Hash(String s)throws NoSuchAlgorithmException{MessageDigest digest=MessageDigest.getInstance("SHA-256");byte[]encodedhash=Arrays.copyOf(digest.digest(s.getBytes(StandardCharsets.UTF_8)),3);return Base64.getEncoder().encodeToString(encodedhash);}public abstract void testCase();public abstract void init();};

abstract class Algorithm{private Object result;private boolean end;protected Object runCustomAlgorithm(Runnable runnable){end=false;result=null;runnable.run();return result;}protected void end(){end(null);}protected void end(Object result){if(shouldEnd())return;this.result=result;this.end=true;}protected boolean shouldEnd(){return end;}};

@Retention(RetentionPolicy.RUNTIME)@Target(ElementType.TYPE)@interface CacheVersion{int value();};

@Retention(RetentionPolicy.RUNTIME)@Target(ElementType.TYPE)@interface ContestSubmission{ContestType value();};

enum ContestType{PLAIN("",-1),ETH_JUDGE("",-1,null,false,false,6),GOOGLE("Case #%d: ",-1),GOOGLE_JAM("Case #%d: ",-1,"Solution.java",false,false,8),GOOGLE_JAM_INTERACTIVE("",-1,"Solution.java",false,false,8),FACEBOOK("Case #%d: ",-1),BLOOMBERG("",1,"Problem.java",false,false,8),SINGLE_TESTCASE("",1),OPTIMIZER("",1,null,false,false,8,true),HACKERRANK("",1,"Solution.java",false,false,8),CODEFORCES("",1,"Solution.java",false,false,8);public int testCaseCount;public String caseString;public String launcher;public boolean disableCompression;public boolean keepUnusedDependencies;public int javaVersion;public boolean isOptimizer;ContestType(String caseString,int testCaseCount,String launcher,boolean disableCompression,boolean keepUnusedDependencies,int javaVersion,boolean isOptimizer){this.caseString=caseString;this.testCaseCount=testCaseCount;this.launcher=launcher;this.disableCompression=disableCompression;this.javaVersion=javaVersion;this.keepUnusedDependencies=keepUnusedDependencies;this.isOptimizer=isOptimizer;}ContestType(String a1,int a2,String a3,boolean a4,boolean a5,int a6){this(a1,a2,a3,a4,a5,a6,false);}ContestType(String a1,int a2){this(a1,a2,null,false,false,8);}};

@Retention(RetentionPolicy.SOURCE)@Target(ElementType.METHOD)@interface O{String value();};

@Target(ElementType.FIELD)@Retention(RetentionPolicy.RUNTIME)@interface Optimize{long imin()default 0;long imax()default 100;double fmin()default 0;double fmax()default 1;};

class Tree<T>implements Serializable{private TreeNode<T>root;Pair<Double,DoubleBinaryOperator>distanceFolder;public Tree(T rootValue){this(rootValue,null);}public Tree(T rootValue,Pair<Double,DoubleBinaryOperator>distanceFolder){this(distanceFolder);initRoot(new TreeNode(rootValue,this));}protected Tree(){this((Pair<Double,DoubleBinaryOperator>)null);}protected Tree(Pair<Double,DoubleBinaryOperator>distanceFolder){this.distanceFolder=distanceFolder==null?new Pair<>(0.0,Double::sum):distanceFolder;}protected void initRoot(TreeNode<T>node){if(root!=null)throw new IllegalStateException("Can't modify the root after it has already been initialized!");this.root=node;}public TreeNode<T>getRoot(){return root;}public String toString(){return root.toString();}};

class Pair<A,B>extends Tuple implements Map.Entry<A,B>{public A a;public B b;public Pair(A a,B b){this.a=a;this.b=b;}public A getLeft(){return a;}public B getRight(){return b;}public void setLeft(A a){this.a=a;}public void setRight(B b){this.b=b;}public<A1,B1>Pair<A1,B1>map(Function<A,A1>mapA,Function<B,B1>mapB){return new Pair<>(mapA.apply(this.a),mapB.apply(this.b));}public A getKey(){return a;}public A setKey(A a){A old=this.a;this.a=a;return old;}public B getValue(){return b;}public B setValue(B b){B old=this.b;this.b=b;return old;}public Object[]toArray(){return new Object[]{a,b};}public boolean equals(Object other){if(!(other instanceof Pair))return super.equals(other);Pair pair=(Pair)other;return Objects.equals(this.a,pair.a)&&Objects.equals(this.b,pair.b);}public int hashCode(){return 961+31*Objects.hashCode(a)+Objects.hashCode(b);}};

class TreeNode<T>implements Serializable{private T value;private int height;private double distance;private double distanceToParent;private List<TreeNode<T>>children;private TreeNode<T>parent;private Tree<T>tree;private Map<String,Object>attributeMap=null;public TreeNode(T value){this(value,null);}protected TreeNode(T value,Tree<T>tree){this.value=value;this.parent=null;this.tree=tree;this.children=new ArrayList<>();this.height=0;this.distance=tree.distanceFolder.a;}protected TreeNode(T value,TreeNode<T>parent,double distanceToParent){this.value=value;this.parent=parent;this.tree=parent.tree;this.children=new ArrayList<>();this.height=parent.getHeight()+1;this.distanceToParent=distanceToParent;this.distance=tree.distanceFolder.b.applyAsDouble(parent.getDistance(),distanceToParent);}public T getValue(){return value;}public void setValue(T value){this.value=value;}public int getHeight(){return height;}public double getDistance(){return distance;}public double getDistanceToParent(){if(!hasParent())throw new NoSuchElementException("Node has no parent!");return this.distanceToParent;}public List<TreeNode<T>>getChildren(){return Collections.unmodifiableList(children);}public int getChildCount(){return children.size();}public TreeNode<T>addChild(T value){return addChild(value,1);}public TreeNode<T>addChild(T value,double distance){return createUnattached(value,distance).attach();}public TreeNode<T>.Unattached createUnattached(T value,double distance){return new Unattached(value,distance);}class Unattached extends TreeNode<T>{private boolean isAttached=false;private Unattached(T value,double distance){super(value,TreeNode.this,distance);}public TreeNode<T>attach(){if(isAttached())throw new NoSuchElementException("Node has already been attached!");TreeNode.this.children.add(this);isAttached=true;return this;}public boolean isAttached(){return isAttached;}}public TreeNode<T>getParent(){return parent;}public List<TreeNode<T>>getParentChain(){List<TreeNode<T>>res=new ArrayList<>();TreeNode<T>node=this;while((node=node.getParent())!=null){res.add(node);}Collections.reverse(res);return res;}public boolean hasParent(){return getParent()!=null;}public Tree<T>getTree(){return tree;}public boolean isAttached(){return true;}public Map<String,Object>getAttributeMap(){if(attributeMap==null)attributeMap=new HashMap<>(3);return attributeMap;}public<U>U inheritAttribute(String attrName,U firstValue,BiFunction<U,TreeNode<T>,U>fold){return(U)getAttributeMap().computeIfAbsent(attrName,k->{U val=firstValue;for(TreeNode<T>node:getParentChain()){Map<String,Object>map=node.getAttributeMap();if(map.containsKey(attrName))return map.get(attrName);val=fold.apply(val,node);}return firstValue;});}public String toString(){return value.toString()+(children.isEmpty()?"":children.toString());}};

abstract class Tuple extends Structure{public abstract Object[]toArray();public boolean equals(Object obj){if(obj==null)return false;if(!(obj instanceof Tuple))return false;return Arrays.equals(this.toArray(),((Tuple)obj).toArray());}public int hashCode(){return Arrays.hashCode(this.toArray());}public String toString(){Object[]els=toArray();String[]elements=new String[els.length];for(int i=0;i<els.length;i++){elements[i]=""+els[i];}return "("+String.join(", ",elements)+")";}};

abstract class Structure implements Serializable,Cloneable{public Structure clone(){try{Structure struct=(Structure)super.clone();for(Field field:this.getClass().getDeclaredFields()){field.setAccessible(true);if(Modifier.isTransient(field.getModifiers())){continue;}field.set(struct,field.get(this));}return struct;}catch(CloneNotSupportedException e){throw new AssertionError("Cloning a structure should always be supported - please report this bug",e);}catch(IllegalAccessException e){throw new RuntimeException("Can't access my own elements!",e);}}private NavigableMap<String,Object>getFields(){try{NavigableMap<String,Object>result=new TreeMap<String,Object>();for(Field field:this.getClass().getFields()){if(Modifier.isTransient(field.getModifiers())){continue;}result.put(field.getName(),field.get(this));}return result;}catch(IllegalAccessException e){throw new RuntimeException("Can't access my own elements!",e);}}public boolean equals(Object obj){if(obj==null)return false;if(getClass()!=obj.getClass())return false;return getFields().equals(((Structure)obj).getFields());}public int hashCode(){return getFields().hashCode();}public String toString(){return getFields().toString();}};

class VoidOutputStream extends OutputStream{public void write(int b){return;}public void write(byte b[]){return;}public void write(byte b[],int off,int len){return;}};

class VoidPrintStream extends PrintStream{public VoidPrintStream(){super(new VoidOutputStream());}public void write(int b){return;}public void print(char[]buf){return;}public void print(String s){return;}public void print(Object obj){return;}public void println(char[]buf){return;}public void println(String s){return;}public void println(Object obj){return;}public PrintStream format(Locale l,String s,Object...objs){return this;}public PrintStream format(String s,Object...objs){return this;}};


// Hash: QB+kPgBNSKHMiIS2X8Q8zGcGZuNow0BYoMe+W4FocNQ=

import java.security.*;
import java.util.*;
import java.nio.file.*;
import java.lang.annotation.*;
import java.util.stream.*;
import java.text.*;
import java.util.function.*;
import java.nio.charset.*;
import java.io.*;
import java.util.concurrent.*;
import java.lang.reflect.*;
import java.math.*;

// Solution can be found in Submission.testCase(). psvm method can be found in Main.main(String[] args)
// Please note that the code isn't obfuscated; only compressed

public class Solution {
    public static void main(String[] args) throws Exception {
        Main.main(args);
    }
}

class Main{public static void main(String[]args)throws Exception{new TaskC().runSubmission();}};

@ContestSubmission(ContestType.CODEFORCES)
@CacheVersion(0)
class TaskC extends AbstractSubmission {

	@Override
	public void testCase() {
		int t = sc.nextInt();
		outer: for (int it = 0; it < t; it++) {
			int h = sc.nextInt();
			int n = sc.nextInt();
			ArrayList<Integer> list = new ArrayList<>();
			for (int i = 0; i < n; i++) {
				list.add(sc.nextInt());
			}
			Collections.reverse(list);

			int total = 0;

			while (true) {
				int x = list.isEmpty() ? 0 : list.get(list.size() - 1);
				list.remove(list.size() - 1);
				int u = list.isEmpty() ? 0 : list.get(list.size() - 1);
				if (u == x - 1) {
					if (!list.isEmpty()) list.remove(list.size() - 1);
				} else {
					list.add(x - 1);
				}
				u = list.isEmpty() ? 0 : list.get(list.size() - 1);
				if (x - u > 2) {
					total++;
					list.add(x - 2);
				}
				int nu = list.isEmpty() ? 0 : list.get(list.size() - 1);
				if (nu == 0) break;

				if (list.size() >= 2 && list.get(list.size() - 1) - 3 > list.get(list.size() - 2)) {
					list.set(list.size() - 1, list.get(list.size() - 2) + 2);
				}
				if (list.size() == 1) {
					list.set(list.size() - 1, 1);
				}
			}

			out.println(total);
		}
	}

	@Override
	public void init() {
		// Nothing here! Good for initializing look-up tables

		// Note that there could be multiple Problem instances running on different threads. Writing static variables
		// here (or anywhere else) could lead to race conditions! Use static initialization instead
	}

	// Set to TRUE to override default (which may both be true or false). Setting to FALSE has no effect

	/* DISABLE-CODE-COMPRESSION: TRUE */
	/* GLOBAL-DISABLE-CODE-COMPRESSION: DEFAULT */
	/* JAVA-6-COMPATIBILITY-MODE: DEFAULT */
	/* KEEP-UNUSED-DEPENDENCIES: DEFAULT */

};

abstract class AbstractSubmission{public Scanner sc;public InputStream in;public PrintStream out;public PrintStream debug;public volatile double score=0;public volatile int testCaseCount=-1;public volatile int testCaseIndex;public volatile double progress=0;public void runSubmission(){runSubmission(false);}public void runSubmission(boolean debug){runSubmission(System.in,System.out,debug);}public void runSubmission(InputStream in,PrintStream out){runSubmission(in,out,false);}public void runSubmission(InputStream in,PrintStream out,boolean debug){runSubmission(in,out,debug?out:new VoidPrintStream());}public void runSubmission(InputStream in,OutputStream out,OutputStream debug){this.in=in;this.sc=new Scanner(this.in);this.out=new PrintStream(out);this.debug=debug instanceof VoidOutputStream?new VoidPrintStream():new PrintStream(debug);ContestType type=getType();testCaseCount=type.testCaseCount;init();if(testCaseCount<=0){testCaseCount=sc.nextInt();sc.nextLine();}testCaseIndex=0;for(testCaseIndex=1;testCaseIndex<=testCaseCount;testCaseIndex++){progress=0;this.out.printf(type.caseString,testCaseIndex,testCaseCount);testCase();}}public ContestType getType(){return getType(getClass());}public static ContestType getType(Class<?extends AbstractSubmission>clss){return getAnnotation(clss).value();}private static ContestSubmission getAnnotation(Class<?extends AbstractSubmission>clss){if(!clss.isAnnotationPresent(ContestSubmission.class)){throw new RuntimeException("ContestSubmission annotation not present on class "+clss.getCanonicalName()+"!");}return clss.getAnnotation(ContestSubmission.class);}private static String b64Hash(String s)throws NoSuchAlgorithmException{MessageDigest digest=MessageDigest.getInstance("SHA-256");byte[]encodedhash=Arrays.copyOf(digest.digest(s.getBytes(StandardCharsets.UTF_8)),3);return Base64.getEncoder().encodeToString(encodedhash);}public abstract void testCase();public abstract void init();};

abstract class Algorithm{private Object result;private boolean end;protected Object runCustomAlgorithm(Runnable runnable){end=false;result=null;runnable.run();return result;}protected void end(){end(null);}protected void end(Object result){if(shouldEnd())return;this.result=result;this.end=true;}protected boolean shouldEnd(){return end;}};

@Retention(RetentionPolicy.RUNTIME)@Target(ElementType.TYPE)@interface CacheVersion{int value();};

@Retention(RetentionPolicy.RUNTIME)@Target(ElementType.TYPE)@interface ContestSubmission{ContestType value();};

enum ContestType{PLAIN("",-1),ETH_JUDGE("",-1,null,false,false,6),GOOGLE("Case #%d: ",-1),GOOGLE_JAM("Case #%d: ",-1,"Solution.java",false,false,8),GOOGLE_JAM_INTERACTIVE("",-1,"Solution.java",false,false,8),FACEBOOK("Case #%d: ",-1),BLOOMBERG("",1,"Problem.java",false,false,8),SINGLE_TESTCASE("",1),OPTIMIZER("",1,null,false,false,8,true),HACKERRANK("",1,"Solution.java",false,false,8),CODEFORCES("",1,"Solution.java",false,false,8);public int testCaseCount;public String caseString;public String launcher;public boolean disableCompression;public boolean keepUnusedDependencies;public int javaVersion;public boolean isOptimizer;ContestType(String caseString,int testCaseCount,String launcher,boolean disableCompression,boolean keepUnusedDependencies,int javaVersion,boolean isOptimizer){this.caseString=caseString;this.testCaseCount=testCaseCount;this.launcher=launcher;this.disableCompression=disableCompression;this.javaVersion=javaVersion;this.keepUnusedDependencies=keepUnusedDependencies;this.isOptimizer=isOptimizer;}ContestType(String a1,int a2,String a3,boolean a4,boolean a5,int a6){this(a1,a2,a3,a4,a5,a6,false);}ContestType(String a1,int a2){this(a1,a2,null,false,false,8);}};

@Retention(RetentionPolicy.SOURCE)@Target(ElementType.METHOD)@interface O{String value();};

@Target(ElementType.FIELD)@Retention(RetentionPolicy.RUNTIME)@interface Optimize{long imin()default 0;long imax()default 100;double fmin()default 0;double fmax()default 1;};

class VoidOutputStream extends OutputStream{public void write(int b){return;}public void write(byte b[]){return;}public void write(byte b[],int off,int len){return;}};

class VoidPrintStream extends PrintStream{public VoidPrintStream(){super(new VoidOutputStream());}public void write(int b){return;}public void print(char[]buf){return;}public void print(String s){return;}public void print(Object obj){return;}public void println(char[]buf){return;}public void println(String s){return;}public void println(Object obj){return;}public PrintStream format(Locale l,String s,Object...objs){return this;}public PrintStream format(String s,Object...objs){return this;}};


// Hash: RYqDUv4SVHhGtzgRB4YBtQx+yQo6AOf6ZMidhbJzHRo=

import java.security.*;
import java.util.*;
import java.nio.file.*;
import java.lang.annotation.*;
import java.util.stream.*;
import java.text.*;
import java.util.function.*;
import java.nio.charset.*;
import java.io.*;
import java.util.concurrent.*;
import java.lang.reflect.*;
import java.math.*;

// Solution can be found in Submission.testCase(). psvm method can be found in Main.main(String[] args)
// Please note that the code isn't obfuscated; only compressed

public class Solution {
    public static void main(String[] args) throws Exception {
        Main.main(args);
    }
}

class Main{public static void main(String[]args)throws Exception{new TaskC().runSubmission();}};

@ContestSubmission(ContestType.CODEFORCES)
@CacheVersion(0)
class TaskC extends AbstractSubmission {

	@Override
	public void testCase() {
		int t = sc.nextInt();
		outer: for (int it = 0; it < t; it++) {
			int h = sc.nextInt();
			int n = sc.nextInt();
			ArrayList<Integer> list = new ArrayList<>();
			for (int i = 0; i < n; i++) {
				list.add(sc.nextInt());
			}
			Collections.reverse(list);

			int total = 0;

			while (true) {
				int x = list.isEmpty() ? 0 : list.get(list.size() - 1);
				list.remove(list.size() - 1);
				int u = list.isEmpty() ? 0 : list.get(list.size() - 1);
				if (u == x - 1) {
					if (!list.isEmpty()) list.remove(list.size() - 1);
				} else {
					list.add(x - 1);
				}
				u = list.isEmpty() ? 0 : list.get(list.size() - 1);
				if (x - u > 2) {
					total++;
					list.add(x - 2);
				}
				int nu = list.isEmpty() ? 0 : list.get(list.size() - 1);
				if (nu == 0) break;
			}

			out.println(total);
		}
	}

	@Override
	public void init() {
		// Nothing here! Good for initializing look-up tables

		// Note that there could be multiple Problem instances running on different threads. Writing static variables
		// here (or anywhere else) could lead to race conditions! Use static initialization instead
	}

	// Set to TRUE to override default (which may both be true or false). Setting to FALSE has no effect

	/* DISABLE-CODE-COMPRESSION: TRUE */
	/* GLOBAL-DISABLE-CODE-COMPRESSION: DEFAULT */
	/* JAVA-6-COMPATIBILITY-MODE: DEFAULT */
	/* KEEP-UNUSED-DEPENDENCIES: DEFAULT */

};

abstract class AbstractSubmission{public Scanner sc;public InputStream in;public PrintStream out;public PrintStream debug;public volatile double score=0;public volatile int testCaseCount=-1;public volatile int testCaseIndex;public volatile double progress=0;public void runSubmission(){runSubmission(false);}public void runSubmission(boolean debug){runSubmission(System.in,System.out,debug);}public void runSubmission(InputStream in,PrintStream out){runSubmission(in,out,false);}public void runSubmission(InputStream in,PrintStream out,boolean debug){runSubmission(in,out,debug?out:new VoidPrintStream());}public void runSubmission(InputStream in,OutputStream out,OutputStream debug){this.in=in;this.sc=new Scanner(this.in);this.out=new PrintStream(out);this.debug=debug instanceof VoidOutputStream?new VoidPrintStream():new PrintStream(debug);ContestType type=getType();testCaseCount=type.testCaseCount;init();if(testCaseCount<=0){testCaseCount=sc.nextInt();sc.nextLine();}testCaseIndex=0;for(testCaseIndex=1;testCaseIndex<=testCaseCount;testCaseIndex++){progress=0;this.out.printf(type.caseString,testCaseIndex,testCaseCount);testCase();}}public ContestType getType(){return getType(getClass());}public static ContestType getType(Class<?extends AbstractSubmission>clss){return getAnnotation(clss).value();}private static ContestSubmission getAnnotation(Class<?extends AbstractSubmission>clss){if(!clss.isAnnotationPresent(ContestSubmission.class)){throw new RuntimeException("ContestSubmission annotation not present on class "+clss.getCanonicalName()+"!");}return clss.getAnnotation(ContestSubmission.class);}private static String b64Hash(String s)throws NoSuchAlgorithmException{MessageDigest digest=MessageDigest.getInstance("SHA-256");byte[]encodedhash=Arrays.copyOf(digest.digest(s.getBytes(StandardCharsets.UTF_8)),3);return Base64.getEncoder().encodeToString(encodedhash);}public abstract void testCase();public abstract void init();};

abstract class Algorithm{private Object result;private boolean end;protected Object runCustomAlgorithm(Runnable runnable){end=false;result=null;runnable.run();return result;}protected void end(){end(null);}protected void end(Object result){if(shouldEnd())return;this.result=result;this.end=true;}protected boolean shouldEnd(){return end;}};

@Retention(RetentionPolicy.RUNTIME)@Target(ElementType.TYPE)@interface CacheVersion{int value();};

@Retention(RetentionPolicy.RUNTIME)@Target(ElementType.TYPE)@interface ContestSubmission{ContestType value();};

enum ContestType{PLAIN("",-1),ETH_JUDGE("",-1,null,false,false,6),GOOGLE("Case #%d: ",-1),GOOGLE_JAM("Case #%d: ",-1,"Solution.java",false,false,8),GOOGLE_JAM_INTERACTIVE("",-1,"Solution.java",false,false,8),FACEBOOK("Case #%d: ",-1),BLOOMBERG("",1,"Problem.java",false,false,8),SINGLE_TESTCASE("",1),OPTIMIZER("",1,null,false,false,8,true),HACKERRANK("",1,"Solution.java",false,false,8),CODEFORCES("",1,"Solution.java",false,false,8);public int testCaseCount;public String caseString;public String launcher;public boolean disableCompression;public boolean keepUnusedDependencies;public int javaVersion;public boolean isOptimizer;ContestType(String caseString,int testCaseCount,String launcher,boolean disableCompression,boolean keepUnusedDependencies,int javaVersion,boolean isOptimizer){this.caseString=caseString;this.testCaseCount=testCaseCount;this.launcher=launcher;this.disableCompression=disableCompression;this.javaVersion=javaVersion;this.keepUnusedDependencies=keepUnusedDependencies;this.isOptimizer=isOptimizer;}ContestType(String a1,int a2,String a3,boolean a4,boolean a5,int a6){this(a1,a2,a3,a4,a5,a6,false);}ContestType(String a1,int a2){this(a1,a2,null,false,false,8);}};

@Retention(RetentionPolicy.SOURCE)@Target(ElementType.METHOD)@interface O{String value();};

@Target(ElementType.FIELD)@Retention(RetentionPolicy.RUNTIME)@interface Optimize{long imin()default 0;long imax()default 100;double fmin()default 0;double fmax()default 1;};

class VoidOutputStream extends OutputStream{public void write(int b){return;}public void write(byte b[]){return;}public void write(byte b[],int off,int len){return;}};

class VoidPrintStream extends PrintStream{public VoidPrintStream(){super(new VoidOutputStream());}public void write(int b){return;}public void print(char[]buf){return;}public void print(String s){return;}public void print(Object obj){return;}public void println(char[]buf){return;}public void println(String s){return;}public void println(Object obj){return;}public PrintStream format(Locale l,String s,Object...objs){return this;}public PrintStream format(String s,Object...objs){return this;}};


import java.util.*;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
public class A
{
      public static void main(String ar[]) throws Exception
      {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            int q=Integer.parseInt(br.readLine());
            for(int r=0;r<q;r++)
            {
                  String s1[]=br.readLine().split(" ");
                  int h=Integer.parseInt(s1[0]);
                  int n=Integer.parseInt(s1[1]);

                  String s2[]=br.readLine().split(" ");
                  int a[]=new int[n];
                  for(int i=0;i<n;i++)
                   a[i]=Integer.parseInt(s2[i]);

                  TreeSet<Integer> ts=new TreeSet<Integer>();
                  HashMap<Integer,Integer> hm=new HashMap<Integer,Integer>();
                  ts.add(h);
                  hm.put(h,0);

                  if(n>=2)
                  {
                        int u=a[1];
                        int v=u+1;
                        if(!ts.contains(v))
                        {
                              hm.put(v,0);
                              ts.add(v);
                        }
                        ts.add(u);
                        hm.put(u,1);
                  }

                  for(int i=2;i<n;i++)
                  {
                        int u=a[i];
                        int v=u+1;
                        if(!ts.contains(v))
                        {
                              int x=hm.get(ts.higher(v))+1;
                              int p=ts.higher(ts.higher(v));
                               x=Math.min(x,1+hm.get(p));
                              hm.put(v,x);
                              ts.add(v);
                        }
                        // System.out.println(ts.higher(u)+" "+hm.get(ts.higher(u)));
                        int x=hm.get(ts.higher(u))+1;
                        int p=ts.higher(ts.higher(u));
                        if(p==u+2)
                         x=Math.min(x,hm.get(p));
                        else
                         x=Math.min(x,2+hm.get(p));
                        ts.add(u);
                        hm.put(u,x);
                  }

                  if(ts.higher(ts.higher(0))==null)
                   System.out.println(hm.get(ts.higher(0)));
                  else
                  {
                        int x=hm.get(ts.higher(0));
                        int p=ts.higher(ts.higher(0));
                        if(p==2)
                         x=Math.min(x,hm.get(p));
                        System.out.println(x);
                  }
            }
      }
}


import java.util.*;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
public class A
{
      public static void main(String ar[]) throws Exception
      {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            int q=Integer.parseInt(br.readLine());
            for(int r=0;r<q;r++)
            {
                  String s1[]=br.readLine().split(" ");
                  int h=Integer.parseInt(s1[0]);
                  int n=Integer.parseInt(s1[1]);

                  String s2[]=br.readLine().split(" ");
                  int a[]=new int[n];
                  HashSet<Integer> hh=new HashSet<Integer>();
                  for(int i=0;i<n;i++)
                  {
                   a[i]=Integer.parseInt(s2[i]);
                   hh.add(a[i]);
                  }

                  TreeSet<Integer> ts=new TreeSet<Integer>();
                  HashMap<Integer,Integer> hm=new HashMap<Integer,Integer>();
                  ts.add(h);
                  hm.put(h,0);

                  if(n>=2)
                  {
                        int u=a[1];
                        int v=u+1;
                        if(!ts.contains(v))
                        {
                              hm.put(v,0);
                              ts.add(v);
                        }
                        ts.add(u);
                        hm.put(u,1);
                  }

                  for(int i=2;i<n;i++)
                  {
                        int u=a[i];
                        int v=u+1;
                        if(!ts.contains(v))
                        {
                              int x=hm.get(ts.higher(v));
                              int p=ts.higher(ts.higher(v));
                               x=Math.min(x,1+hm.get(p));
                              hm.put(v,x);
                              ts.add(v);
                        }
                        // System.out.println(ts.higher(u)+" "+hm.get(ts.higher(u)));
                        int x=hm.get(ts.higher(u))+1;
                        int p=ts.higher(ts.higher(u));
                        if(p==u+2 && hh.contains(ts.higher(u)))
                         x=Math.min(x,hm.get(p));
                        else if(!hh.contains(ts.higher(u)))
                         x=Math.min(x,1+hm.get(p));
                        else
                         x=Math.min(x,2+hm.get(p));
                        ts.add(u);
                        hm.put(u,x);
                  }

                  if(ts.higher(ts.higher(0))==null)
                   System.out.println(hm.get(ts.higher(0)));
                  else
                  {
                        int x=hm.get(ts.higher(0));
                        int p=ts.higher(ts.higher(0));
                        if(p==2)
                         x=Math.min(x,hm.get(p));
                        System.out.println(x);
                  }
                  // System.out.println(hm);
            }
      }
}


import java.util.*;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
public class A
{
      public static void main(String ar[]) throws Exception
      {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            int q=Integer.parseInt(br.readLine());
            for(int r=0;r<q;r++)
            {
                  String s1[]=br.readLine().split(" ");
                  int h=Integer.parseInt(s1[0]);
                  int n=Integer.parseInt(s1[1]);

                  String s2[]=br.readLine().split(" ");
                  int a[]=new int[n];
                  HashSet<Integer> hh=new HashSet<Integer>();
                  for(int i=0;i<n;i++)
                  {
                   a[i]=Integer.parseInt(s2[i]);
                   hh.add(a[i]);
                  }

                  TreeSet<Integer> ts=new TreeSet<Integer>();
                  HashMap<Integer,Integer> hm=new HashMap<Integer,Integer>();
                  ts.add(h);
                  hm.put(h,0);

                  if(n>=2)
                  {
                        int u=a[1];
                        int v=u+1;
                        if(!ts.contains(v))
                        {
                              hm.put(v,0);
                              ts.add(v);
                        }
                        ts.add(u);
                        hm.put(u,1);
                  }

                  for(int i=2;i<n;i++)
                  {
                        int u=a[i];
                        int v=u+1;
                        if(!ts.contains(v))
                        {
                              int x=hm.get(ts.higher(v))+1;
                              int p=ts.higher(ts.higher(v));
                               x=Math.min(x,1+hm.get(p));
                              hm.put(v,x);
                              ts.add(v);
                        }
                        // System.out.println(ts.higher(u)+" "+hm.get(ts.higher(u)));
                        int x=hm.get(ts.higher(u))+1;
                        int p=ts.higher(ts.higher(u));
                        if(p==u+2 && hh.contains(ts.higher(u)))
                         x=Math.min(x,hm.get(p));
                        else if(!hh.contains(ts.higher(u)))
                         x=Math.min(x,1+hm.get(p));
                        else
                         x=Math.min(x,2+hm.get(p));
                        ts.add(u);
                        hm.put(u,x);
                  }

                  if(ts.higher(ts.higher(0))==null)
                   System.out.println(hm.get(ts.higher(0)));
                  else
                  {
                        int x=hm.get(ts.higher(0));
                        int p=ts.higher(ts.higher(0));
                        if(p==2)
                         x=Math.min(x,hm.get(p));
                        System.out.println(x);
                  }
            }
      }
}


import java.util.*;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
public class A
{
      public static void main(String ar[]) throws Exception
      {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            int q=Integer.parseInt(br.readLine());
            for(int r=0;r<q;r++)
            {
                  String s1[]=br.readLine().split(" ");
                  int h=Integer.parseInt(s1[0]);
                  int n=Integer.parseInt(s1[1]);

                  String s2[]=br.readLine().split(" ");
                  int a[]=new int[n];
                  HashSet<Integer> hh=new HashSet<Integer>();
                  for(int i=0;i<n;i++)
                  {
                   a[i]=Integer.parseInt(s2[i]);
                   hh.add(a[i]);
                  }

                  TreeSet<Integer> ts=new TreeSet<Integer>();
                  HashMap<Integer,Integer> hm=new HashMap<Integer,Integer>();
                  ts.add(h);
                  hm.put(h,0);

                  if(n>=2)
                  {
                        int u=a[1];
                        int v=u+1;
                        if(!ts.contains(v))
                        {
                              hm.put(v,0);
                              ts.add(v);
                        }
                        ts.add(u);
                        hm.put(u,1);
                  }

                  for(int i=2;i<n;i++)
                  {
                        int u=a[i];
                        int v=u+1;
                        if(!ts.contains(v))
                        {
                              int x=hm.get(ts.higher(v));
                              hm.put(v,x);
                              ts.add(v);
                        }
                        int x=hm.get(ts.higher(u))+1;
                        int p=ts.higher(ts.higher(u));
                        if(p==u+2 && hh.contains(ts.higher(u)))
                         x=Math.min(x,hm.get(p));
                        else if(!hh.contains(ts.higher(u)))
                         x=Math.min(x,1+hm.get(p));
                        ts.add(u);
                        hm.put(u,x);
                  }

                  if(ts.higher(ts.higher(0))==null)
                   System.out.println(hm.get(ts.higher(0)));
                  else
                  {
                        int x=hm.get(ts.higher(0));
                        int p=ts.higher(ts.higher(0));
                        if(p==2)
                         x=Math.min(x,hm.get(p));
                        System.out.println(x);
                  }
                  System.out.println(hm);
            }
      }
}


import java.util.*;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
public class A
{
      public static void main(String ar[]) throws Exception
      {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            int q=Integer.parseInt(br.readLine());
            for(int r=0;r<q;r++)
            {
                  String s1[]=br.readLine().split(" ");
                  int h=Integer.parseInt(s1[0]);
                  int n=Integer.parseInt(s1[1]);

                  String s2[]=br.readLine().split(" ");
                  int a[]=new int[n];
                  for(int i=0;i<n;i++)
                   a[i]=Integer.parseInt(s2[i]);

                  TreeSet<Integer> ts=new TreeSet<Integer>();
                  HashMap<Integer,Integer> hm=new HashMap<Integer,Integer>();
                  ts.add(h);
                  hm.put(h,0);

                  if(n>=2)
                  {
                        int u=a[1];
                        int v=u+1;
                        if(!ts.contains(v))
                        {
                              hm.put(v,0);
                              ts.add(v);
                        }
                        ts.add(u);
                        hm.put(u,1);
                  }

                  for(int i=2;i<n;i++)
                  {
                        int u=a[i];
                        int v=u+1;
                        if(!ts.contains(v))
                        {
                              int x=hm.get(ts.higher(v))+1;
                              int p=ts.higher(ts.higher(v));
                               x=Math.min(x,1+hm.get(p));
                              hm.put(v,x);
                              ts.add(v);
                        }
                        // System.out.println(ts.higher(u)+" "+hm.get(ts.higher(u)));
                        int x=hm.get(ts.higher(u))+1;
                        int p=ts.higher(ts.higher(u));
                        if(p==u+2)
                         x=Math.min(x,hm.get(p));
                        else
                         x=Math.min(x,2+hm.get(p));
                        ts.add(u);
                        hm.put(u,x);
                  }

                  if(ts.higher(ts.higher(0))==null)
                   System.out.println(hm.get(ts.higher(0)));
                  else
                  {
                        int x=hm.get(ts.higher(0));
                        int p=ts.higher(ts.higher(0));
                        x=Math.min(x,hm.get(p));
                        System.out.println(x);
                  }
            }
      }
}


import java.util.*;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
public class A
{
      public static void main(String ar[]) throws Exception
      {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            int q=Integer.parseInt(br.readLine());
            for(int r=0;r<q;r++)
            {
                  String s1[]=br.readLine().split(" ");
                  int h=Integer.parseInt(s1[0]);
                  int n=Integer.parseInt(s1[1]);

                  String s2[]=br.readLine().split(" ");
                  int a[]=new int[n];
                  HashSet<Integer> hh=new HashSet<Integer>();
                  for(int i=0;i<n;i++)
                  {
                   a[i]=Integer.parseInt(s2[i]);
                   hh.add(a[i]);
                  }

                  TreeSet<Integer> ts=new TreeSet<Integer>();
                  HashMap<Integer,Integer> hm=new HashMap<Integer,Integer>();
                  ts.add(h);
                  hm.put(h,0);

                  if(n>=2)
                  {
                        int u=a[1];
                        int v=u+1;
                        if(!ts.contains(v))
                        {
                              hm.put(v,0);
                              ts.add(v);
                        }
                        ts.add(u);
                        hm.put(u,1);
                  }

                  for(int i=2;i<n;i++)
                  {
                        int u=a[i];
                        int v=u+1;
                        if(!ts.contains(v))
                        {
                              int x=hm.get(ts.higher(v));
                              hm.put(v,x);
                              ts.add(v);
                        }

                        int x=hm.get(ts.higher(u))+1;
                        int p=ts.higher(ts.higher(u));
                        if(p==u+2 && hh.contains(ts.higher(u)))
                         x=Math.min(x,hm.get(p));
                        else if(!hh.contains(ts.higher(u)))
                         x=Math.min(x,1+hm.get(p));
                        ts.add(u);
                        hm.put(u,x);
                  }

                  if(ts.higher(ts.higher(0))==null)
                   System.out.println(hm.get(ts.higher(0)));
                  else
                  {
                        int x=hm.get(ts.higher(0));
                        int p=ts.higher(ts.higher(0));
                        if(p==2)
                         x=Math.min(x,hm.get(p));
                        System.out.println(x);
                  }
                  // System.out.println(hm);
            }
      }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;

public class StandardFree2play { // Template for CF
    public static class ListComparator implements Comparator<List<Integer>> {

        @Override
        public int compare(List<Integer> l1, List<Integer> l2) {
            for (int i = 0; i < l1.size(); ++i) {
                if (l1.get(i).compareTo(l2.get(i)) != 0) {
                    return l1.get(i).compareTo(l2.get(i));
                }
            }
            return 0;
        }
    }

    public static class Pair {
        int first;
        int second;

        public Pair(int first, int second) {
            this.first = first;
            this.second = second;
        }

        public int getFirst() {
            return first;
        }

        public int getSecond() {
            return second;
        }

        @Override
        public String toString() {
            return first + " " + second;
        }
    }

    public static void main(String[] args) throws IOException {
        // Check for int overflow!!!!
        // Should you use a long to store the sum or smthn?
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int T = Integer.parseInt(f.readLine());
        for (int i = 0; i < T; i++) {
            StringTokenizer st = new StringTokenizer(f.readLine());
            int h = Integer.parseInt(st.nextToken());
            int n = Integer.parseInt(st.nextToken());
            LinkedList<Integer> list = new LinkedList<>();
            st = new StringTokenizer(f.readLine());
            for (int j = 0; j < n; j++) {
                int a = Integer.parseInt(st.nextToken());
                list.add(a);
            }
            int sum = 0;
            list.add(0);
            while (list.size() > 2) {
                int a = list.pollFirst();
                if (a - list.peekFirst() == 1) {
                    list.pollFirst();
                    if (a - list.peekFirst() > 2) {
                        sum++;
                        list.addFirst(list.peekFirst() + 1);
                    }

                } else {
                    list.addFirst(list.peekFirst() + 1);
                }
            }
            out.println(sum);
        }
        out.close();
    }

}


//Code by Sounak, IIEST
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.Arrays;

public class Test2{
    public static void main(String args[])throws IOException{
        FastReader sc = new FastReader();
        StringBuilder sb = new StringBuilder();
        int test=sc.nextInt();
        while(--test>=0)
        {
            int h=sc.nextInt();
            int n=sc.nextInt();
            int i,c=0,prev=h-1;
            for(i=0;i<n;i++)
            {
                int temp=sc.nextInt();
                if(temp<h-1)
                {
                    if(prev-temp>1)
                    c++;
                }
                if(temp!=h)
                prev=temp;
            }
            if(h<=2)
            {
                System.out.println(0);
                continue;
            }
            System.out.println(c);
        }
    }
}

class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); }
    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
    int nextInt() { return Integer.parseInt(next()); }
    long nextLong() { return Long.parseLong(next()); }
    double nextDouble() { return Double.parseDouble(next()); }
    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}


//Code by Sounak, IIEST
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.Arrays;

public class Test2{
    public static void main(String args[])throws IOException{
        FastReader sc = new FastReader();
        StringBuilder sb = new StringBuilder();
        int test=sc.nextInt();
        while(--test>=0)
        {
            int h=sc.nextInt();
            int n=sc.nextInt();
            int p[]=new int[h];
            int i,c=0;
            for(i=0;i<n;i++)
            {
                int temp=sc.nextInt();
                p[temp-1]=1;
            }
            for(i=h-2;i>0;i--)
            {
                if(p[i]==0)
                {
                    continue;
                }
                else
                {
                    if(p[i-1]==0)
                    c++;
                    i--;
                }
            }
            System.out.println(c);
        }
    }
}

class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); }
    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
    int nextInt() { return Integer.parseInt(next()); }
    long nextLong() { return Long.parseLong(next()); }
    double nextDouble() { return Double.parseDouble(next()); }
    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}


/*package whatever //do not write package name here */
import java.util.*;
import java.io.*;

public class GFG {
	public static void main (String[] args) {
		Scanner sc=new Scanner(System.in);
		int T=sc.nextInt();
		int str[]=new int[10000005];
		while(T--!=0)
		{
			int n=sc.nextInt(),m=sc.nextInt(),ans=0;
			for(int i=1;i<=m;i++)
				str[i]=sc.nextInt();
			str[m+1]=0;
			for(int i=2;i<=m;i++)
			{
				if(str[i]-1==str[i+1])
					i++;
				else
					ans++;
			}
			System.out.println(ans);
	    }
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.LongStream;

public class Main4 {

    static long mod = 1000000007;
    static FastScanner scanner;

    static List<Integer>[] graph;

    static StringBuilder builder = new StringBuilder();

    public static void main(String[] args) {
        scanner = new FastScanner();
        int q = scanner.nextInt();
        for (int t = 0; t < q; t++) {
            solve();
        }
        System.out.println(builder.toString());
    }

    static void solve() {
        int h = scanner.nextInt();
        int n = scanner.nextInt();
        if (n == 1) {
            builder.append("0").append("\n");
            return;
        }
        int[] p = scanner.nextIntArray(n);

        int dat = 0;
        int magic = 0;
        p[0] = p[1] + 1;
        for (int i = 1; i < p.length; i++) {
            if (p[i] == p[i - 1] - 1) {
                dat++;
            } else {
                magic += dat % 2 == 0 ? 0 : 1;
                dat = 1;
            }
        }
        if (p[p.length - 1] > 1) {
            magic += dat % 2 == 0 ? 0 : 1;
        }
        builder.append(magic).append('\n');
    }

    static class WithIdx implements Comparable<WithIdx>{
        int val, idx;

        public WithIdx(int val, int idx) {
            this.val = val;
            this.idx = idx;
        }

        @Override
        public int compareTo(WithIdx o) {
            return Integer.compare(val, o.val);
        }
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            try {
                return br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException();
            }
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }

        int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) res[i] = nextInt();
            return res;
        }

        long[] nextLongArray(int n) {
            long[] res = new long[n];
            for (int i = 0; i < n; i++) res[i] = nextLong();
            return res;
        }

        String[] nextStringArray(int n) {
            String[] res = new String[n];
            for (int i = 0; i < n; i++) res[i] = nextToken();
            return res;
        }
    }

    static class PrefixSums {
        long[] sums;

        public PrefixSums(long[] sums) {
            this.sums = sums;
        }

        public long sum(int fromInclusive, int toExclusive) {
            if (fromInclusive > toExclusive) throw new IllegalArgumentException("Wrong value");
            return sums[toExclusive] - sums[fromInclusive];
        }

        public static PrefixSums of(int[] ar) {
            long[] sums = new long[ar.length + 1];
            for (int i = 1; i <= ar.length; i++) {
                sums[i] = sums[i - 1] + ar[i - 1];
            }
            return new PrefixSums(sums);
        }

        public static PrefixSums of(long[] ar) {
            long[] sums = new long[ar.length + 1];
            for (int i = 1; i <= ar.length; i++) {
                sums[i] = sums[i - 1] + ar[i - 1];
            }
            return new PrefixSums(sums);
        }
    }

    static class ADUtils {
        static void sort(int[] ar) {
            Random rnd = ThreadLocalRandom.current();
            for (int i = ar.length - 1; i > 0; i--)
            {
                int index = rnd.nextInt(i + 1);
                // Simple swap
                int a = ar[index];
                ar[index] = ar[i];
                ar[i] = a;
            }
            Arrays.sort(ar);
        }

        static void reverse(int[] arr) {
            int last = arr.length / 2;
            for (int i = 0; i < last; i++) {
                int tmp = arr[i];
                arr[i] = arr[arr.length - 1 - i];
                arr[arr.length - 1 - i] = tmp;
            }
        }

        static void sort(long[] ar) {
            Random rnd = ThreadLocalRandom.current();
            for (int i = ar.length - 1; i > 0; i--)
            {
                int index = rnd.nextInt(i + 1);
                // Simple swap
                long a = ar[index];
                ar[index] = ar[i];
                ar[i] = a;
            }
            Arrays.sort(ar);
        }
    }

    static class MathUtils {
        static long[] FIRST_PRIMES = {
                2,     3,      5,      7,     11,     13,     17,     19,     23,     29,
                31,     37,     41,     43,     47,     53,     59,     61,     67,     71,
                73,     79,     83,     89  ,   97 ,    101,    103,    107,    109,    113,
                127,    131,    137,    139,    149,    151,    157,    163,    167,    173,
                179,    181,    191,    193,    197,    199,    211,    223,    227,    229,
                233,    239,    241,    251,    257,    263,    269,    271,    277,    281,
                283,    293,    307,    311,    313,    317,    331,    337,    347,    349,
                353,    359,    367,    373,    379,    383,    389,    397,    401,    409,
                419,    421,    431,    433,    439,    443,    449,    457,    461,    463,
                467,    479,    487,    491,    499,    503,    509,    521,    523,    541,
                547,    557,    563,    569,    571,    577,    587,    593,    599,    601,
                607,    613,    617,    619,    631,    641,    643,    647,    653,    659,
                661,    673,    677,    683,    691,    701,    709,    719,    727,    733,
                739,    743,    751,    757,    761,    769,    773,    787,    797,    809,
                811,    821,    823,    827,    829,    839,    853,    857,    859,    863,
                877,    881,    883,    887,    907,    911,    919,    929,    937,    941,
                947,    953,    967,    971,    977,    983,    991,    997,   1009,   1013,
                1019,   1021,   1031,   1033,   1039,   1049,   1051};

        static long[] primes(int to) {
            long[] all = new long[to + 1];
            long[] primes = new long[to + 1];
            all[1] = 1;
            int primesLength = 0;
            for (int i = 2; i <= to; i ++) {
                if (all[i] == 0) {
                    primes[primesLength++] = i;
                    all[i] = i;
                }
                for (int j = 0; j < primesLength && i * primes[j] <= to && all[i] >= primes[j]; j++) {
                    all[(int) (i * primes[j])] = primes[j];
                }
            }
            return Arrays.copyOf(primes, primesLength);
        }

        static long modpow(long b, long e, long m) {
            long result = 1;

            while (e > 0) {
                if ((e & 1) == 1) {
                    /* multiply in this bit's contribution while using modulus to keep
                     * result small */
                    result = (result * b) % m;
                }
                b = (b * b) % m;
                e >>= 1;
            }

            return result;
        }

        static long submod(long x, long y, long m) {
            return (x - y + m) % m;
        }

        static public long gcdF(long a, long b) {
            while (b != 0) {
                long na = b;
                long nb = a % b;
                a = na;
                b = nb;
            }
            return a;
        }
    }
}

/*
5
3 2 3 8 8
2 8 5 10 1

 */


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.LongStream;

public class Main4 {

    static long mod = 1000000007;
    static FastScanner scanner;

    static List<Integer>[] graph;

    static StringBuilder builder = new StringBuilder();

    public static void main(String[] args) {
        scanner = new FastScanner();
        int q = scanner.nextInt();
        for (int t = 0; t < q; t++) {
            solve();
        }
        System.out.println(builder.toString());
    }

    static void solve() {
        int h = scanner.nextInt();
        int n = scanner.nextInt();
        int[] p = scanner.nextIntArray(n);
        if (n == 1) {
            builder.append("0").append("\n");
            return;
        }

        int dat = 0;
        int magic = 0;
        p[0] = p[1] + 1;
        for (int i = 1; i < p.length; i++) {
            if (p[i] == p[i - 1] - 1) {
                dat++;
            } else {
                magic += dat % 2 == 0 ? 0 : 1;
                dat = 1;
            }
        }
        if (p[p.length - 1] > 1) {
            magic += dat % 2 == 0 ? 0 : 1;
        }
        builder.append(magic).append('\n');
    }

    static class WithIdx implements Comparable<WithIdx>{
        int val, idx;

        public WithIdx(int val, int idx) {
            this.val = val;
            this.idx = idx;
        }

        @Override
        public int compareTo(WithIdx o) {
            return Integer.compare(val, o.val);
        }
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            try {
                return br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException();
            }
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }

        int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) res[i] = nextInt();
            return res;
        }

        long[] nextLongArray(int n) {
            long[] res = new long[n];
            for (int i = 0; i < n; i++) res[i] = nextLong();
            return res;
        }

        String[] nextStringArray(int n) {
            String[] res = new String[n];
            for (int i = 0; i < n; i++) res[i] = nextToken();
            return res;
        }
    }

    static class PrefixSums {
        long[] sums;

        public PrefixSums(long[] sums) {
            this.sums = sums;
        }

        public long sum(int fromInclusive, int toExclusive) {
            if (fromInclusive > toExclusive) throw new IllegalArgumentException("Wrong value");
            return sums[toExclusive] - sums[fromInclusive];
        }

        public static PrefixSums of(int[] ar) {
            long[] sums = new long[ar.length + 1];
            for (int i = 1; i <= ar.length; i++) {
                sums[i] = sums[i - 1] + ar[i - 1];
            }
            return new PrefixSums(sums);
        }

        public static PrefixSums of(long[] ar) {
            long[] sums = new long[ar.length + 1];
            for (int i = 1; i <= ar.length; i++) {
                sums[i] = sums[i - 1] + ar[i - 1];
            }
            return new PrefixSums(sums);
        }
    }

    static class ADUtils {
        static void sort(int[] ar) {
            Random rnd = ThreadLocalRandom.current();
            for (int i = ar.length - 1; i > 0; i--)
            {
                int index = rnd.nextInt(i + 1);
                // Simple swap
                int a = ar[index];
                ar[index] = ar[i];
                ar[i] = a;
            }
            Arrays.sort(ar);
        }

        static void reverse(int[] arr) {
            int last = arr.length / 2;
            for (int i = 0; i < last; i++) {
                int tmp = arr[i];
                arr[i] = arr[arr.length - 1 - i];
                arr[arr.length - 1 - i] = tmp;
            }
        }

        static void sort(long[] ar) {
            Random rnd = ThreadLocalRandom.current();
            for (int i = ar.length - 1; i > 0; i--)
            {
                int index = rnd.nextInt(i + 1);
                // Simple swap
                long a = ar[index];
                ar[index] = ar[i];
                ar[i] = a;
            }
            Arrays.sort(ar);
        }
    }

    static class MathUtils {
        static long[] FIRST_PRIMES = {
                2,     3,      5,      7,     11,     13,     17,     19,     23,     29,
                31,     37,     41,     43,     47,     53,     59,     61,     67,     71,
                73,     79,     83,     89  ,   97 ,    101,    103,    107,    109,    113,
                127,    131,    137,    139,    149,    151,    157,    163,    167,    173,
                179,    181,    191,    193,    197,    199,    211,    223,    227,    229,
                233,    239,    241,    251,    257,    263,    269,    271,    277,    281,
                283,    293,    307,    311,    313,    317,    331,    337,    347,    349,
                353,    359,    367,    373,    379,    383,    389,    397,    401,    409,
                419,    421,    431,    433,    439,    443,    449,    457,    461,    463,
                467,    479,    487,    491,    499,    503,    509,    521,    523,    541,
                547,    557,    563,    569,    571,    577,    587,    593,    599,    601,
                607,    613,    617,    619,    631,    641,    643,    647,    653,    659,
                661,    673,    677,    683,    691,    701,    709,    719,    727,    733,
                739,    743,    751,    757,    761,    769,    773,    787,    797,    809,
                811,    821,    823,    827,    829,    839,    853,    857,    859,    863,
                877,    881,    883,    887,    907,    911,    919,    929,    937,    941,
                947,    953,    967,    971,    977,    983,    991,    997,   1009,   1013,
                1019,   1021,   1031,   1033,   1039,   1049,   1051};

        static long[] primes(int to) {
            long[] all = new long[to + 1];
            long[] primes = new long[to + 1];
            all[1] = 1;
            int primesLength = 0;
            for (int i = 2; i <= to; i ++) {
                if (all[i] == 0) {
                    primes[primesLength++] = i;
                    all[i] = i;
                }
                for (int j = 0; j < primesLength && i * primes[j] <= to && all[i] >= primes[j]; j++) {
                    all[(int) (i * primes[j])] = primes[j];
                }
            }
            return Arrays.copyOf(primes, primesLength);
        }

        static long modpow(long b, long e, long m) {
            long result = 1;

            while (e > 0) {
                if ((e & 1) == 1) {
                    /* multiply in this bit's contribution while using modulus to keep
                     * result small */
                    result = (result * b) % m;
                }
                b = (b * b) % m;
                e >>= 1;
            }

            return result;
        }

        static long submod(long x, long y, long m) {
            return (x - y + m) % m;
        }

        static public long gcdF(long a, long b) {
            while (b != 0) {
                long na = b;
                long nb = a % b;
                a = na;
                b = nb;
            }
            return a;
        }
    }
}

/*
5
3 2 3 8 8
2 8 5 10 1

 */


import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author 20173936
 */
public class Free2Play {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        int curIndex = 0;
        for(int i = 0; i < q; i++) {
            int crystals = 0;
            int h = sc.nextInt();
            int n = sc.nextInt();
            int previousNum = sc.nextInt();
            int streak = 1;
            //System.out.println(i+ "TESTCASE");
            for(int j = curIndex+1; j < curIndex+n; j++) {
                int num = sc.nextInt();

                if(num == previousNum-1) {
                    if(previousNum == h) {
                        streak++;
                    }
                    streak++;
                } else {

                    if(streak%2 != 0 && !(streak == 1 && previousNum == h)) {
                        //System.out.println("Added at: " + previousNum);
                        crystals++;
                    }
                    streak = 1;
                }

                previousNum = num;
            }

            if(streak%2 != 0 && !(streak == 1 && previousNum == h) && previousNum > 1) {
                //System.out.println("Added at: " + previousNum);
                crystals++;
            }

            sb.append(crystals + "\n");
            curIndex += n;
        }

        System.out.println(sb);

    }

    public static int fall(boolean hMinOne, boolean hMinTwo) {
        if(!hMinOne) {
            return 1;
        } else if(hMinTwo) {
            return 2;
        } else {
            return 0;
        }
    }
}


import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author 20173936
 */
public class Free2Play {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        int curIndex = 0;
        int[] platForms = new int[2000001];
        for(int i = 0; i < q; i++) {
            int crystals = 0;
            int h = sc.nextInt();
            int n = sc.nextInt();
            int curHeight = h;

            for(int j = curIndex; j < curIndex+n; j++) {
                int num = sc.nextInt();
                platForms[j] = num;
            }

            int prevIndex = curIndex;
            while(curHeight>2) {
                boolean hMinOne = false;
                boolean hMinTwo = false;
                for(int j = curIndex; j < curIndex + n; j++) {
                    if(platForms[j] < curHeight - 2) { prevIndex = j-1; break;}
                    if(platForms[j] == curHeight - 1) { hMinOne = true; prevIndex = j;}
                    if(platForms[j] == curHeight - 2) { hMinTwo = true; prevIndex = j; break;}
                }
                switch (fall(hMinOne,hMinTwo)) {
                    case 0:
                        crystals++;
                        curHeight -= 2;
                        break;
                    case 1:
                        curHeight -= 1;
                        break;
                    default:
                        curHeight -= 2;
                        break;
                }
            }
            sb.append(crystals + "\n");
            curIndex += n;
        }

        System.out.println(sb);

    }

    public static int fall(boolean hMinOne, boolean hMinTwo) {
        if(!hMinOne) {
            return 1;
        } else if(hMinTwo) {
            return 2;
        } else {
            return 0;
        }
    }
}


import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author 20173936
 */
public class Free2Play {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        int curIndex = 0;
        for(int i = 0; i < q; i++) {
            int crystals = 0;
            int h = sc.nextInt();
            int n = sc.nextInt();
            int previousNum = -10;
            int streak = 0;
            //System.out.println(i+ "TESTCASE");
            for(int j = curIndex; j < curIndex+n; j++) {
                int num = sc.nextInt();
                if(num == previousNum-1) {

                    streak++;
                    if(previousNum == h) {
                        streak++;
                    }

                } else if(streak%2==0 && num != h) {
                    if(streak == 0) {
                        if(num < 2) {
                            break;
                        }
                    }
                    //System.out.println(": added at " + num + "  with streak: " + streak + "previousNum was" + previousNum);
                    crystals++;
                    streak = 0;
                } else {
                    streak = 0;
                }
                previousNum = num;
            }

            sb.append(crystals + "\n");
            curIndex += n;
        }

        System.out.println(sb);

    }

    public static int fall(boolean hMinOne, boolean hMinTwo) {
        if(!hMinOne) {
            return 1;
        } else if(hMinTwo) {
            return 2;
        } else {
            return 0;
        }
    }
}


import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author 20173936
 */
public class Free2Play {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        int curIndex = 0;
        boolean[] platForms = new boolean[(int)(2 * 10e5) + 1];
        for(int i = 0; i < q; i++) {
            int crystals = 0;
            int h = sc.nextInt();
            int n = sc.nextInt();
            int curHeight = curIndex + h;

            for(int j = 0; j < n; j++) {
                int num = sc.nextInt();
                platForms[curIndex + (num - 1)] = true;
            }

            while(curHeight>curIndex+2) {
                switch (fall(platForms[curHeight-2], platForms[curHeight-3])) {
                    case 0:
                        crystals++;
                        curHeight -= 2;
                        break;
                    case 1:
                        curHeight -= 1;
                        break;
                    default:
                        curHeight -= 2;
                        break;
                }
            }
            sb.append(crystals + "\n");
            curIndex += h;
        }

        System.out.println(sb);

    }

    public static int fall(boolean hMinOne, boolean hMinTwo) {
        if(!hMinOne) {
            return 1;
        } else if(hMinTwo) {
            return 2;
        } else {
            return 0;
        }
    }
}


import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author 20173936
 */
public class Free2Play {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        int curIndex = 0;
        int[] platForms = new int[2000001];
        for(int i = 0; i < q; i++) {
            int crystals = 0;
            int h = sc.nextInt();
            int n = sc.nextInt();
            int curHeight = h;

            for(int j = curIndex; j < curIndex+n; j++) {
                int num = sc.nextInt();
                platForms[j] = num;
            }

            int prevIndex = curIndex + n;
            while(curHeight>2) {
                boolean hMinOne = false;
                boolean hMinTwo = false;
                for(int j = prevIndex - 1; j >= curIndex; j--) {
                    if(platForms[j] < curHeight - 2) { prevIndex = j+1; break;}
                    if(platForms[j] == curHeight - 1) { hMinOne = true; prevIndex = j;}
                    if(platForms[j] == curHeight - 2) { hMinTwo = true; prevIndex = j; break;}
                }
                switch (fall(hMinOne,hMinTwo)) {
                    case 0:
                        crystals++;
                        curHeight -= 2;
                        break;
                    case 1:
                        curHeight -= 1;
                        break;
                    default:
                        curHeight -= 2;
                        break;
                }
            }
            sb.append(crystals + "\n");
            curIndex += n;
        }

        System.out.println(sb);

    }

    public static int fall(boolean hMinOne, boolean hMinTwo) {
        if(!hMinOne) {
            return 1;
        } else if(hMinTwo) {
            return 2;
        } else {
            return 0;
        }
    }
}


import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author 20173936
 */
public class Free2Play {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        int curIndex = 0;
        for(int i = 0; i < q; i++) {
            int crystals = 0;
            int h = sc.nextInt();
            int n = sc.nextInt();
            int previousNum = sc.nextInt();
            int streak = 1;
            //System.out.println(i+ "TESTCASE");
            for(int j = curIndex+1; j < curIndex+n; j++) {
                int num = sc.nextInt();

                if(num == previousNum-1) {
                    if(previousNum == h) {
                        streak++;
                    }
                    streak++;
                } else {

                    if(streak%2 != 0 && !(streak == 1 && previousNum == h)) {
                        System.out.println("Added at: " + previousNum);
                        crystals++;
                    }
                    streak = 1;
                }

                previousNum = num;
            }

            if(streak%2 != 0 && !(streak == 1 && previousNum == h) && previousNum > 1) {
                System.out.println("Added at: " + previousNum);
                crystals++;
            }

            sb.append(crystals + "\n");
            curIndex += n;
        }

        System.out.println(sb);

    }

    public static int fall(boolean hMinOne, boolean hMinTwo) {
        if(!hMinOne) {
            return 1;
        } else if(hMinTwo) {
            return 2;
        } else {
            return 0;
        }
    }
}


import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author 20173936
 */
public class Free2Play {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        int curIndex = 0;
        for(int i = 0; i < q; i++) {
            int crystals = 0;
            int h = sc.nextInt();
            int n = sc.nextInt();
            int previousNum = 0;
            int streak = 0;

            for(int j = curIndex; j < curIndex+n; j++) {
                int num = sc.nextInt();
                    if(num == previousNum-1) {
                        streak++;
                        if(previousNum == h) {
                            streak++;
                        }
                    } else {
                        if(streak%2==0 && streak > 0) {
                            crystals++;
                        }
                        streak = 0;
                    }
                previousNum = num;
            }

            sb.append(crystals + "\n");
            curIndex += n;
        }

        System.out.println(sb);

    }

    public static int fall(boolean hMinOne, boolean hMinTwo) {
        if(!hMinOne) {
            return 1;
        } else if(hMinTwo) {
            return 2;
        } else {
            return 0;
        }
    }
}


import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author 20173936
 */
public class Free2Play {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        int curIndex = 0;
        boolean[] platForms = new boolean[2000001];
        for(int i = 0; i < q; i++) {
            int crystals = 0;
            int h = sc.nextInt();
            int n = sc.nextInt();
            int curHeight = curIndex + h;

            for(int j = 0; j < n; j++) {
                int num = sc.nextInt();
                platForms[curIndex + (num - 1)] = true;
            }

            while(curHeight>curIndex+2) {
                switch (fall(platForms[curHeight-2], platForms[curHeight-3])) {
                    case 0:
                        crystals++;
                        curHeight -= 2;
                        break;
                    case 1:
                        curHeight -= 1;
                        break;
                    default:
                        curHeight -= 2;
                        break;
                }
            }
            sb.append(crystals + "\n");
            curIndex += h;
        }

        System.out.println(sb);

    }

    public static int fall(boolean hMinOne, boolean hMinTwo) {
        if(!hMinOne) {
            return 1;
        } else if(hMinTwo) {
            return 2;
        } else {
            return 0;
        }
    }
}


import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author 20173936
 */
public class Free2Play {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        int curIndex = 0;
        Integer[] platForms = new Integer[2000001];
        for(int i = 0; i < q; i++) {
            int crystals = 0;
            int h = sc.nextInt();
            int n = sc.nextInt();
            int curHeight = h;

            for(int j = curIndex; j < curIndex+n; j++) {
                int num = sc.nextInt();
                platForms[j] = num;
            }

            while(curHeight>2) {
                boolean hMinOne = false;
                boolean hMinTwo = false;
                if(Arrays.binarySearch(platForms, curIndex, curIndex+n, curHeight-1, Comparator.reverseOrder()) >= 0) {
                    hMinOne = true;
                }
                if(Arrays.binarySearch(platForms, curIndex, curIndex+n, curHeight-2, Comparator.reverseOrder()) >= 0) {
                    hMinTwo = true;
                }
                switch (fall(hMinOne,hMinTwo)) {
                    case 0:
                        crystals++;
                        curHeight -= 2;
                        break;
                    case 1:
                        curHeight -= 1;
                        break;
                    default:
                        curHeight -= 2;
                        break;
                }
            }
            sb.append(crystals + "\n");
            curIndex += n;
        }

        System.out.println(sb);

    }

    public static int fall(boolean hMinOne, boolean hMinTwo) {
        if(!hMinOne) {
            return 1;
        } else if(hMinTwo) {
            return 2;
        } else {
            return 0;
        }
    }
}


import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author 20173936
 */
public class Free2Play {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < q; i++) {
            int crystals = 0;
            int h = sc.nextInt();
            int n = sc.nextInt();
            int curHeight = h;

            boolean[] platForms = new boolean[h];
            for(int j = 0; j < n; j++) {
                platForms[sc.nextInt() - 1] = true;
            }

            while(curHeight>2) {
                int nextStep = fall(platForms[curHeight-2], platForms[curHeight-3]);
                switch (nextStep) {
                    case 0:
                        crystals++;
                        curHeight -= 2;
                        break;
                    case 1:
                        curHeight -= 1;
                        break;
                    default:
                        curHeight -= 2;
                        break;
                }
            }
            sb.append(crystals + "\n");
        }
        System.out.println(sb);
    }

    public static int fall(boolean hMinOne, boolean hMinTwo) {
        if(!hMinOne) {
            return 1;
        } else if(hMinTwo) {
            return 2;
        } else {
            return 0;
        }
    }
}


import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author 20173936
 */
public class Free2Play {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        int curIndex = 0;
        boolean[] platForms = new boolean[(int)30];
        for(int i = 0; i < q; i++) {
            int crystals = 0;
            int h = sc.nextInt();
            int n = sc.nextInt();
            int curHeight = curIndex + h;

            for(int j = curIndex; j < curIndex + n; j++) {
                platForms[curIndex + (sc.nextInt() - 1)] = true;
            }

            while(curHeight>curIndex+2) {
                switch (fall(platForms[curHeight-2], platForms[curHeight-3])) {
                    case 0:
                        crystals++;
                        curHeight -= 2;
                        break;
                    case 1:
                        curHeight -= 1;
                        break;
                    default:
                        curHeight -= 2;
                        break;
                }
            }
            sb.append(crystals + "\n");
            curIndex += h;
        }

        System.out.println(sb);

    }

    public static int fall(boolean hMinOne, boolean hMinTwo) {
        if(!hMinOne) {
            return 1;
        } else if(hMinTwo) {
            return 2;
        } else {
            return 0;
        }
    }
}


import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author 20173936
 */
public class Free2Play {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        int curIndex = 0;
        for(int i = 0; i < q; i++) {
            int crystals = 0;
            int h = sc.nextInt();
            int n = sc.nextInt();
            int previousNum = -10;
            int streak = 0;

            for(int j = curIndex; j < curIndex+n; j++) {
                int num = sc.nextInt();
                    if(num == previousNum-1) {
                        streak++;
                        if(previousNum == h) {
                            streak++;
                        }
                    } else {
                        if(streak%2==0 && streak > 0) {
                            crystals++;
                        }
                        streak = 0;
                    }
                previousNum = num;
            }

            sb.append(crystals + "\n");
            curIndex += n;
        }

        System.out.println(sb);

    }

    public static int fall(boolean hMinOne, boolean hMinTwo) {
        if(!hMinOne) {
            return 1;
        } else if(hMinTwo) {
            return 2;
        } else {
            return 0;
        }
    }
}


import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author 20173936
 */
public class Free2Play {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        int curIndex = 0;
        boolean[] platForms = new boolean[(int)10e5];
        for(int i = 0; i < q; i++) {
            int crystals = 0;
            int h = sc.nextInt();
            int n = sc.nextInt();
            int curHeight = curIndex + h;

            for(int j = 0; j < n; j++) {
                int num = sc.nextInt();
                platForms[curIndex + (num - 1)] = true;
            }

            while(curHeight>curIndex+2) {
                switch (fall(platForms[curHeight-2], platForms[curHeight-3])) {
                    case 0:
                        crystals++;
                        curHeight -= 2;
                        break;
                    case 1:
                        curHeight -= 1;
                        break;
                    default:
                        curHeight -= 2;
                        break;
                }
            }
            sb.append(crystals + "\n");
            curIndex += h;
        }

        System.out.println(sb);

    }

    public static int fall(boolean hMinOne, boolean hMinTwo) {
        if(!hMinOne) {
            return 1;
        } else if(hMinTwo) {
            return 2;
        } else {
            return 0;
        }
    }
}


import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author 20173936
 */
public class Free2Play {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        int curIndex = 0;
        int[] platForms = new int[2000001];
        for(int i = 0; i < q; i++) {
            int crystals = 0;
            int h = sc.nextInt();
            int n = sc.nextInt();
            int curHeight = h;

            for(int j = curIndex; j < curIndex+n; j++) {
                int num = sc.nextInt();
                platForms[j] = num;
            }

            while(curHeight>2) {
                boolean hMinOne = false;
                boolean hMinTwo = false;
                for(int j = curIndex + n - 1; j >= curIndex; j--) {

                    if(platForms[j] == curHeight-1) { hMinOne = true; }
                    if(platForms[j] == curHeight-2) { hMinTwo = true; }
                    if(hMinOne&&hMinTwo) { break; }
                }
                switch (fall(hMinOne,hMinTwo)) {
                    case 0:
                        crystals++;
                        curHeight -= 2;
                        break;
                    case 1:
                        curHeight -= 1;
                        break;
                    default:
                        curHeight -= 2;
                        break;
                }
            }
            sb.append(crystals + "\n");
            curIndex += n;
        }

        System.out.println(sb);

    }

    public static int fall(boolean hMinOne, boolean hMinTwo) {
        if(!hMinOne) {
            return 1;
        } else if(hMinTwo) {
            return 2;
        } else {
            return 0;
        }
    }
}


import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author 20173936
 */
public class Free2Play {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        int curIndex = 0;
        Integer[] platForms = new Integer[2000001];
        for(int i = 0; i < q; i++) {
            int crystals = 0;
            int h = sc.nextInt();
            int n = sc.nextInt();
            int curHeight = h;

            for(int j = curIndex; j < curIndex+n; j++) {
                int num = sc.nextInt();
                platForms[j] = num;
            }

            while(curHeight>2) {
                boolean hMinOne = false;
                boolean hMinTwo = false;
                if(Arrays.binarySearch(platForms, curIndex, curIndex+n+1, curHeight-1, Comparator.reverseOrder()) >= 0) {
                    hMinOne = true;
                }
                if(Arrays.binarySearch(platForms, curIndex, curIndex+n+1, curHeight-2, Comparator.reverseOrder()) >= 0) {
                    hMinTwo = true;
                }
                switch (fall(hMinOne,hMinTwo)) {
                    case 0:
                        crystals++;
                        curHeight -= 2;
                        break;
                    case 1:
                        curHeight -= 1;
                        break;
                    default:
                        curHeight -= 2;
                        break;
                }
            }
            sb.append(crystals + "\n");
            curIndex += n;
        }

        System.out.println(sb);

    }

    public static int fall(boolean hMinOne, boolean hMinTwo) {
        if(!hMinOne) {
            return 1;
        } else if(hMinTwo) {
            return 2;
        } else {
            return 0;
        }
    }
}


import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author 20173936
 */
public class Free2Play {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        int curIndex = 0;
        boolean[] platForms = new boolean[(int)30];
        for(int i = 0; i < q; i++) {
            int crystals = 0;
            int h = sc.nextInt();
            int n = sc.nextInt();
            int curHeight = curIndex + h;

            for(int j = curIndex; j < curIndex + n; j++) {
                platForms[curIndex + (sc.nextInt() - 1)] = true;
            }

            System.out.println(curHeight + "FSDFSDFSDF");

            while(curHeight>curIndex+2) {
                switch (fall(platForms[curHeight-2], platForms[curHeight-3])) {
                    case 0:
                        crystals++;
                        curHeight -= 2;
                        break;
                    case 1:
                        curHeight -= 1;
                        break;
                    default:
                        curHeight -= 2;
                        break;
                }
            }
            sb.append(crystals + "\n");
            curIndex += h;
            System.out.println(curIndex + "LMAO");
        }

        System.out.println("");
            for(boolean f : platForms) {
                System.out.print(f + "  -  ");
            }
            System.out.println("");
        System.out.println(sb);

    }

    public static int fall(boolean hMinOne, boolean hMinTwo) {
        if(!hMinOne) {
            return 1;
        } else if(hMinTwo) {
            return 2;
        } else {
            return 0;
        }
    }
}