Help me in solving STUDVOTE problem

My issue

I am trying to solve it using HashMap. I am not founding any logical error for this please help me to find out my mistake

My code

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner sc = new Scanner(System.in);
	    int tc = sc.nextInt();
	    while(tc-->0)
	    {
	        int n = sc.nextInt();
	        int k = sc.nextInt();
	        int[] arr = new int[n];
	        for(int i = 0; i < n; i++)
	        {
	            arr[i] = sc.nextInt();
	        }
	        HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
	        for( int i = 0; i < arr.length; i++)
	        {
	            if(arr[i] != i+1)
	            {
	                
	                    map.put(arr[i],map.getOrDefault(arr[i],0)+1);
	            }
	        }
	        
	        int cnt = 0;
	        for(Map.Entry<Integer,Integer> e1 : map.entrySet())
	        {
	            if(e1.getValue() >= k)
	            {
	                cnt = cnt+1;
	            }
	        }
	        System.out.println(cnt);
	    }
		// your code goes here
	}
}

Problem Link: STUDVOTE Problem - CodeChef

@mde2022001
For test case
1
2 1
1 1
your code prints
1
and the answer should be
0