#include<stdio.h> #include<string.h> #include<stdlib.h> int n,set[110],a; int erfen_search() { int low,mid,high; high=n; low=1; int flag=0; while(low<=high) { mid=(low+high)/2; if(set[a]>set[mid]) { low=mid+1; } else if(set[a]<set[mid]) { high=mid-1; } else { flag=mid; break; } } return flag; printf("%d\n",flag); } int main() { while(scanf("%d%d",&n,&a),n) { memset(set,0,sizeof(set)); for(int i=1;i<=n;i++) { scanf("%d",&set[i]); } printf("%d\n",erfen_search()); } system("pause"); return 0; }