package com.thinker.bishi.beiyou;

import java.util.Scanner;

/**
 * @author lzh
 */
public class Test {

    public static int search(int[] a, int fromIndex, int toIndex, int key) {
        if(fromIndex > toIndex) {
            return -1;
        }
        int mid = (fromIndex + toIndex) >> 1;
        if(a[mid] < key) {
            return search(a, mid + 1, toIndex, key);
        } else if(a[mid] > key) {
            return search(a, fromIndex, mid - 1, key);
        } else {
            return mid;
        }
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int key = in.nextInt();
        int len = in.nextInt();
        int[] arr = new int[len];
        for(int i=0;i<len;i++){
            arr[i] = in.nextInt();
        }
        System.out.println(search(arr,0,len-1,key));
    }
}
