/* package whatever; // 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 Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int nums[] = new int[n];
		for(int i=0; i<n; i++){
			nums[i]=sc.nextInt();
		}
		
		boolean res = findElementAtKDifference(k,nums);
		System.out.println(res);
		
	}
	
	public static boolean findElementAtKDifference(int k,int []nums){
		HashMap<Integer,Integer> map = new HashMap<>();
		for(int i=0; i<nums.length; i++){
			if(map.containsKey(nums[i])){
				int val = map.get(nums[i]);
				if(i - val == k){
				  return true;
				}
			}else{
				map.put(nums[i],i);
			}
		}
		
		return false;
		
	}
}