#include<bits/stdc++.h> using namespace std; int n,x; int main() { while( ~scanf("%d%d",&n,&x) ) { vector<int> solve(n); for(int i=0; i<n; ++i) { scanf("%d",&solve[i]); } sort( solve.begin(), solve.end() ); int pos=(n-1)-(x-1);//pos if( 0==solve[pos] ) { while( pos<n ) { if( 0!=solve[pos] ) { break; } ++pos; } if( pos==n ) { printf("0\n"); } else { printf("%d\n", (n-pos) ); } } else { vector<int>::iterator it=lower_bound( solve.begin(), solve.end(), solve[pos] ); int need=it-solve.begin(); printf("%d\n", n-need ); } } return 0; }