"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules.A total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.

The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).

Output the number of participants who advance to the next round.

NoteIn the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.In the second example nobody got a positive score.

#include <iostream>
using namespace std;
int main()
{
    int x;
    int y;
    cin>>x>>y;
    int *z=new int[x];

    int q=0;
    for(int i=0;i<x;i++)
        cin>>z[i];

    for(int i=0;i<x;i++)
    if(z[i]>=z[y-1] && z[i]!= 0)
            q++;

    cout<<q<<endl;

    return 0;
}

#include<stdio.h>
int mm[120];
int main(){
    int n,k;
    while(scanf("%d%d",&n,&k)!=EOF){
        for(int i=1;i<=n;i++)
          scanf("%d",&mm[i]);
        int res=k;
        if(mm[k]>0){
            for(int i=k+1;i<=n;i++){
                if(mm[i]<mm[k])break;
                res++;
            }
        }
        else{
            res--;
            for(int i=k-1;i>=1;i--){
                if(mm[i]>0) break;
                res--;
            }
        }

        printf("%d\n",res);
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
	const int size = 50;
	int arr[size];
	int n, k, a, s=0;
	cin >> n >> k;
	for (int i=0;i<n;i++)
	{
		cin >> arr[i];

		if (i + 1 == k)
			a = arr[i];
	}

	for (int i = 0; i < n; i++)
	{
		if (arr[i] >= a && arr[i]>0)
		{
			s++;
		}
	}
	cout << s << endl;

	return 0;
}

#include<iostream>__msvc_all_public_headers.hpp
using namespace std;
int main()
{
	int size, k, count = 0, temp;
	int* arr;

	cin >> size;
	cin >> k;
	arr = new int[size];
	for (int i = 0;i < size;i++)
	{
		cin >> arr[i];
	}
	temp = k;

	if (arr[0] == 0)
	{
		k = 0;
	}
	for (int i = 0;i < size;i++)
	{
		if (k)
		{
			if (arr[k - 1] == arr[k] && arr[k] != 0)
			{
				k++;
			}
		}
	}
	for (int i = 1;i < k;i++)
	{
		if (arr[i] == 0)
		{
			count++;
		}
	}
	cout << k - count;
}

#include<iostream>
using namespace std;

int main()
{
    int n,k,z=0;
    cin >> n >>k;
    int *a = new int [n];
    for(int i=0; i<n; i++)
    {
        cin >> a[i];
    }
    for(int i=0;i<n;i++)
    {
        if(a[k-1]==0)
        {
            if(a[i]>a[k-1])
            {
                z++;
            }
        }
        else
        {
            if(a[i]>=a[k-1])
            {
                z++;
            }
        }
    }
    cout << z;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int n,k,f,ans,sum,i;
int main()
{
    scanf("%d%d",&n,&k);
    for(i=1;i<=n;i++)
	{
        scanf("%d",&f);
        if(f<=0)
		{
            printf("%d",i-1);
            return 0;
        }
        if(i==k)
		sum=f;
        if(f<sum)
		{
            printf("%d",i-1);
            return 0;
        }
    }
    printf("%d",n);
    return 0;
}

#include <stdio.h>

using namespace std;

int n,k,i,ans,a[55];

int main()
{
    scanf("%d%d",&n,&k);
    for(i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
    }

    i = 1;
    while(a[i] >=  a[k] && i <= n)
    {
        if(a[i] > 0) ans++;
        i++;
    }

    printf("%d",ans);
    return 0;

}

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int c=0;
	int a[n];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int kv=a[k];
	for(int i=1;i<=n;i++)
	   	if(a[i]>=kv&&a[i]>0)
		  c++;

	cout<<c;

}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[100],j,i,n,x,k,r,y,res=0,kq=0;
	cin >> n>>k;
	for(i=1;i<=n;i++)
	cin >> a[i];
	x=a[k];
	for(i=1;i<=n;i++)
	 {
	 	if(a[i]!=0)
	 	{
	 	  if(a[i]>=x)
		   res++;
		}
	 }
	 cout << res;
	return 0;
}

#include<iostream>
using namespace std;
int main(){
    int a,b;
	cin>>a>>b;
	int c[a];
	for(int i=0;i<a;i++){
		cin>>c[i];
	}
	int per=c[b-1];
	for(int i=0;i<a;i++){
		if(c[i]<max(1,per)){
			cout<<i;
			return 0;
		}
		if(i==a-1)cout<<a;
	}
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

int score[100];

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &score[i]);
    }
    while (m + 1 <= n && score[m + 1] == score[m]) {
        ++m;
    }
    while (m >= 1 && score[m] <= 0) {
        --m;
    }
    printf("%d\n", m);
    return 0;
}
/*fF8swlZtF2y4n96nKPGiFGXTYsB8V2eV4ieYPYFUxqggwmjE2eP2AXxBQxHuRlSI*/

#include<stdio.h>
int main(){
	int n,a[100],k,b,num=0;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",a+i);
	}
	b=a[k];
	for(int i=1;i<=n;i++)
	{
		if(a[i]>=b && a[i]>0)
			num++;
	}
	printf("%d",num);
	return 0;
}

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
    int n, k, num = 0;
    cin>>n>>k;
    vector<int> v(n);
    for(int i = 0; i < n; i++){
	    cin>>v[i];
    }
    for(int i = 0; i < n; i++){
        if(v[i]>=v[k-1] && v[i]>0)
            num++;
    }

    cout<<num;
}

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>
using namespace std;
int main()
{    int n, k;
    cin >> n >> k;
    int a;
    for (int i = 0; i < k; ++i)
    {
        cin >> a;
        if (a == 0)
        {
            cout << i << endl;
            return 0;
        }
    }
    int b;
    for (int i = k; i < n; ++i)
    {
        cin >> b;
        if (b != a)
        {
            cout << i << endl;
            return 0;
        }    }
    cout << n;
    return 0;
}

#include<iostream>
using namespace std;

int main()
{
    int n,k=0;
    cin >> n >> k;
    int i = 0;
    int a[50];
    for(i=0; i<n; i++)
    {
       cin >> a[i];
    }
    int count = 0;
    for(i=0; i<n; i++)
    {
        if(a[i]>=a[k-1] && a[i]!=0)
        {
            count++;
        }
        else
        {
            count = count;
        }
    }
    cout << count << endl;

    return 0;
}

#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	int n,k;
	cin>>n>>k;
	int a,b,count=k;
	bool breakflag=0;
	for(int i=1 ; i<=k ; ++i){
		cin>>a;
		if(a==0){
			breakflag=1;
			count=i-1;
			break;
		}
	}
	b=a;
	for(int i=k+1 ; i<=n ; ++i){
		if(breakflag)break;
		cin>>a;
		if(a==b)count++;
	}
	cout<<count<<"\n";
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

int score[100];

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &score[i]);
    }
    while (m + 1 <= n && score[m + 1] == score[m]) {
        ++m;
    }
    while (m >= 1 && score[m] <= 0) {
        --m;
    }
    printf("%d\n", m);
    return 0;
}
/*40hsBFI7qBTx2FHmQ2KBFevz6TmOk6JzO7earzm1m3cvr4mwPuL8F1OebnrPjff1*/

#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie();
    string c,ss = "";
    int n,m,s = 0;
    cin >> n >> m;
        for (int i = 0; i < n; i++) {
                cin >> c;
            if ((c != "0" && s < m) || (s >= m && ss == c)) {
                ss = c;
                s++;
            }

        }
        cout << s;

    return 0;
}

#include<iostream>
using namespace std;
int main(){
    int n,k,count=0;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i<k&&a[i]>0)
            count++;
    }
    for(int i=k;i<n;i++){
        if(a[i]==a[k-1]&&a[k-1]>0)
            count++;
    }
    cout<<count<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main(){
	int n; cin >> n;
	int k; cin >> k;
	int nr = 0;
	int b;
	for(int i=1; i<=n; i++){
		int a; cin >> a;
		if(a == 0) break;
		if(i<k) nr++;
		else{
		    if(i==k){
		        b = a;
		        nr++;
		    }
		    else{
			    if(a == b) nr++;
			    else break;
		    }
		}
	}
	cout << nr << endl;
	return 0;
}
// 1536972488821

#include<iostream>
#include<string>
using namespace std;

int main(){
    int n,k,count;

    cin>>n>>k;
    count=k;
    int scores[50];
    for (int i=0; i<n; i++){
        cin>> scores[i];
        if(scores[i]==0 && i<k){

                count=i;
                break;

        }
    }
    for(int i=k; i<n;i++){
        if(scores[i]== scores[i-1]){
            count++;
        }
        else{
            break;
        }
    }

    cout<<count;
}

#include <iostream>
using namespace std;
int main()
{int n,k,ctr,num,num2;
 cin>>n>>k;
 for(int i=1;i<=n;i++){
    cin>>num;
    if(num==0||(i>k&&num<num2))break;
    if(i>k&&num==num2){ctr++; continue;}
    else if(i==k)num2=num;
    ctr++;}
 cout<<ctr;
return 0;}

#include <cstdio>

int main()
{
int n, k, a, a2, r = 0;

scanf("%d%d", &n, &k);

int i;
for(i = 0; i < k; i++)
    {
    scanf("%d", &a);

    if(a <= 0)
        break;
    }

r = i;

int j = 0;
if(k < n && a > 0)
    {
    do
        {
        scanf("%d", &a2);
        j++;
        }
    while(a2 == a && i + j < n);

    if(a2 != a)
        r = i +j -1;
    else
        r = i + j;
    }

printf("%d\n", r);
return 0;
}

#include <iostream>
using namespace std;
int main()
{
    int x;
    int y;
    cin>>x>>y;
    int *z=new int[x];

    int q=0;
    for(int i=0;i<x;i++)
        cin>>z[i];

    for(int i=0;i<x;i++)
    if(z[i]>=z[y-1] && z[i]!= 0)
            q++;

    cout<<q<<endl;

    return 0;
}

#include<stdio.h>
int main()
{
    int n,m,i,j,k;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        int q[100];
        for(i=0;i<n;i++)
        {
            scanf("%d",&q[i]);
        }
        int sum=0;
            for(i=0;i<n;i++)
            {
                if(q[i]>=q[m-1] && q[i]>0)
                    sum++;
            }
        printf("%d\n",sum);
    }
    return 0;
}

#include<iostream>
#include<string>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	int temp[100];
	int counter = 0;
	int i;
	for (i = 0; i < n; i++) {
		cin >> temp[i];
	}
	for (i = 0; i < n; i++) {
		if (temp[i] > 0 && temp[i] >= temp[k - 1]) {
			counter++;
		}
	}
	cout << counter;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,i,c=0;
	cin>>n>>k;
	int A[n];
	for(i=0;i<n;i++)
	{
		cin>>A[i];
	}
	for(i=0;i<n;i++)
	{
		if(A[i]==0||A[i]<A[k-1])
		break;
		else if(A[i]>=A[k-1])
		c++;
	}
	cout<<c;
}

#include <iostream>

using namespace std;

int main()
{
	/*unsigned int n, k, s = 0;
	cin >> n >> k;
	unsigned int *a = new unsigned int[n];
	for (unsigned int i = 0; i <= n - 1; i++)
		cin >> a[i];
	cout << a[k] << endl;
	if (a[k-1] > 0)
		for (s; s <= n - 1; s++)
		{
			if (a[s] < a[k-1]) break;
			cout << s << endl;
		}
	else for (s; s <= n - 1; s++)
			if (a[s] == 0) break;
	cout << s << endl;
	if (s == n - 1) s = n;
	cout << s;*/

	unsigned int n, k, s = 0;
	cin >> n >> k;
	unsigned int *a = new unsigned int[n];
	for (unsigned int i = 0; i <= n - 1; i++)
		cin >> a[i];
	if (a[s] < a[n - 1]) s = n; else
	if (a[k - 1] > 0)
		for (s; s <= n - 1; s++)
		{
			if (a[s] < a[k - 1]) break;
		}
	else for (s; s <= n - 1; s++)
		if (a[s] == 0) break;
	cout << s;
}

#include <iostream>
using namespace std;

int main()
{
    int n, k, scr, pscr = -1, memb = 0;

    cin >> n >> k;

    while(n--)
    {
        cin >> scr;

        if(scr && --k >= 0)
        {
            ++memb;
            pscr = scr;
        }
        else
        {
            if(pscr == scr)
                ++memb;
        }
    }

    cout << memb << endl;
    return 0;
}

#include <iostream>
using namespace std;

int main(void)
{
    int n, k;
    cin >> n >> k;
    int arr[n];
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    int bar = arr[k - 1];
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        if (arr[i] >= bar && arr[i] > 0)
        {
            count++;
        }
    }
    cout <<count << endl;
    return 0;
}

#include<string>
#include <iostream>
#include<vector>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int flag = 0;
    int* Arr = new int[n];
    for (int i = 0; i < n ; ++i) {
        cin >> Arr[i];
    }
    int ans = 0;

    if (Arr[0] == 0) {
        cout << 0;
        return 0;
    }

    for (int i = 0; i < k; ++i) {
        if (Arr[i] != 0) ans++;
        else break;
    }
    for (int i = k; i < n; i++) {
        if (Arr[i] == Arr[k - 1]&&Arr[i]!=0)ans++;
    }
    cout << ans;
    cin.get();
    cin.get();
}

#include <iostream>

using namespace std;

int main()
{

    short int n, k;
    short int a[n];

    cin>>n;
    cin>>k;
    for (int i=0;i<n;i++)
    cin>>a[i];

    short int result=k;
    if (a[k-1] > 0 ) {
        short int tmp=a[k-1];
        for (int i=k;i<n;i++)
            if (a[i]==tmp) result++;
            else break;
    } else {
        result=0;
        for (int i=k-2;i>=0;i--)
            if (a[i]>0) { result=i+1; break; }
    }

    cout << result;
    return 0;
}

#include<iostream>
using namespace std;

int main()
{
    int i,a[100],n,res=0,k;
    cin>>n>>k;
    for(i=1;i<=n;i++)
    cin>>a[i];
    for(i=1;i<=n;i++)
    if(a[i]>0&&a[i]>=a[k])
    res++;
    cout<<res<<endl;
}

#include <iostream>
using namespace std;
int main()
{
    int n,K,c=0;
    cin>>n>>K;
    int *a=new int[n];
    for(int i=0;i<n;i++)
      cin>>a[i];
   for(int j=0;j<n;j++)
   {
       if(a[j]>=a[K-1]&&a[j]!=0)
          c++;
   }
   cout<<c<<endl;
   // system ("pause");
    return 0;
}

#include <iostream>

using namespace std;

void f1A()
{
	long long x, y, a;

	cin >> x >> y >> a;

	//if (a <= 0) { cout << 0; return 0; }

	long long sumX = 0;
	long long sumY = 0;

	if (x%a != 0)
		sumX = 1;
	if (y%a != 0)
		sumY = 1;

	sumX += x / a;
	sumY += y / a;

	cout << sumX*sumY << endl;
}

void f4A()
{
	long long a;

	cin >> a;

	if (a % 2 == 0 && a >= 4)
		cout << "YES";
	else
		cout << "NO";
}

void f158A()
{

		long long n, k;
		cin >> n >> k;

		long long *arr = new long long[n];

		for (int i = 0; i < n; i++)
			cin >> arr[i];

		long long count = 0;

		for (int i = 0; i < n; i++)
		{
			if (arr[i] >= arr[k-1] && arr[i] > 0){
				count++;
			}
		}

		cout << count << endl;

		delete arr;

}

int main()
{
	f158A();

	return 0;
}

#include<iostream>
using namespace std;

void main()
{
    int k;
    int n;
    cin>>n;
    cin>>k;
    int sum2=0;
    if(n>=k && n>0 && k>0 && n<51)
    {
        int i=0;
        int sum[100];
        int D=0;
        while(i<n)
        {
            int s;
            cin>>s;
            sum[i]=s;
            if(i<k && sum[i]>0)
            {
                sum2++;
            }
            i++;

        }

        while(D<n-k)
        {

        if (sum[k-1]==sum[k+D] && sum[k-1]>0)
            {
                sum2++;
            }
        D++;
        }

        cout<<sum2;
    }
    else
    {
        cout<<sum2;
    }

}

#include <iostream>
using namespace std;
int n, k, a, b = 0, mas[10000];
int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a;
        mas[i] = a;
    }
    for (int j = 1; j <= n; j++) {
        if (mas[j] >= mas[k] && mas[j] > 0) {
            b++;
        }
    }
    cout << b;
}

#include <iostream>

using namespace std;

int main()
{
int x,n,i,c=0;
cin>>n>>x;
int *a=new int[n];
for(i=0;i<n;i++)
cin>>a[i];
//cout<<x<<","<<a[x-1]<<endl;
for(i=0;i<n;i++)
{
if(a[i]>=a[x-1]&&a[i]>0){c++;}
}
cout<<c<<endl;

return 0;
}

#include <iostream>
using namespace std;
int main(){
int i, N, ans, n[100], k;
cin >> N >> k;
for(i=0; i < N; i++)
cin >> n[i];
    ans=0;
    for(i=0; i < N; i++){
  	if(n[i] >= n[k-1] && n[i] != 0)
  	ans++; }
    cout << ans;

	return 0;
}

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int n,k;
	int i,s=0,a[101];
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)
	scanf("%d",&a[i]);
	for(i=1;i<=n;i++)
	{
		if(a[i]>=a[k]&&a[i]!=0)
		s++;
    }
		printf("%d\n",s);
	    return 0;
}

#include <iostream>
#include <string>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int a[50];
  int p=0;
  for(int i=0;i<n;i++){
      cin>>a[i];
  }
  for(int i=0;i<n;i++){
      if(a[i]>0 && a[i]>=a[k-1])
     p++;

  }

  cout<<p;

  return 0;

}

#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int x,y;
  int c=0;
  cin>>x>>y;
  int a[x];
  for (size_t i = 0; i <x; i++) {
    cin>>a[i];
  }
  for (size_t i = 0; i < x; i++) {
    if (a[i]>0)
  {
      if(a[i]>=a[y-1]){
      c++;
    }
  }
  }
  std::cout << c << '\n';
  return 0;
}

#include <iostream>
using namespace std;
int a[101]={0},n,k,dem=0;
int main()
{
	cin>>n;
	cin>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]>=a[k]&&a[i]>0)
			dem++;
	}
	cout<<dem;
}

#include <bits/stdc++.h>
using namespace std;

int main(){
	int n;
	int k;
	cin >> n >> k;
	k--;
	int next; next=0;
	vector<int> vec(n);
	for (int i=0; i<n; i++){
		cin >> vec[i];
		if (vec[i]>=vec[k] and vec[i]>0) next++;
	}
	cout << next << '\n';
}
// 1501883284315

#include<iostream>
using namespace std;

int main() {
    int n, k, count = 0;
    cin >> n >> k;
    int a[n];
    bool isOK = false, isException = false, isSame = false;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    for(int i=0; i<n; i++){
        if(a[i] < a[k-1]) isOK = true;
        if(a[i] == 0) isOK = true;
        if(isOK == true) break;
        count++;
    }

    if(a[0] == a[n-1]) isSame = true;
    if(a[0] == 0) isException = true;

    if(isException) cout << 0 << endl;
    if(isSame && not isException) cout << n << endl;
    if(not isException && not isSame) cout << count << endl;
}

// Subscribe to Caramelio on Youtube

#include <iostream>
using namespace std;

int main() {
	int n,k,i,c=0;
	cin>>n>>k;
	int a[n];
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n;i++){
		if(a[i]>0){
		if(a[i]>=a[k-1]){
		c++;
		}
		}
		else{
			c=c;
		}
	}
	cout<<c;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define ll long long

int main() {
  int num, pos, count = 0;
  cin >> num;
  cin >> pos;
  int arr[num];

  for (int i = 0; i < num; i++) {
    cin >> arr[i];
  }
  int val = arr[pos - 1];
  for (int i = 0; i < num; i++) {
    if (arr[i] >= val && arr[i] > 0) count++;
  }
  cout << count;
}

#include <iostream>

using namespace std;

int main()
{
    int n,k;
    int l = 0;
    cin>> n >> k;
    int  s[n];
    for (int i = 0; i < n ; i++)
      {cin>> s[i];}
  for (int i=0; i<k; i++)

      {if (s[i] != 0 )
         { ++l; }}
for (int i = n-1; i >=k ; i--){
if (s[k-1] == s[i] && s[i]!=0)
         {
             l++;
         }

}
      cout << l;
}

#include<bits/stdc++.h>

using namespace std;

int convertir(string stt){
    int ret = 0;
    for(int i = 0; i<stt.length();i++){
        ret = ret + stt[i]-'0';
        ret = ret*10;
    }
    ret = ret/10;
    return ret;
}

string copr(string st){
    st = st.substr(st.find(" ")+1,st.length()-1);
    return st;
}

int nextN(string strr){
    int n;
    n = convertir(strr.substr(0,strr.find(" ")));
    return n;
}

int main(){
    string strCnsl;
    getline(cin,strCnsl);
    int n = nextN(strCnsl);
    int indP = 101;
    strCnsl = copr(strCnsl);
    int k = nextN(strCnsl);
    getline(cin,strCnsl);
    int scores[n];
    for(int i=0;i<n;i++){
        scores[i] = nextN(strCnsl);
        strCnsl = copr(strCnsl);
    }
    for(int i=n;i>=0;--i){
        if (scores[i]==0){
            indP = i;}}
    int scoreWin = scores[k-1];
    int j = k-1;
    while(j<n){
            ++j;
        if(scoreWin!=scores[j]){
            goto terminar;
            }
    }

    terminar:
        cout << min(j,indP) << endl;

return 0;}

// 1501873871986

#include<iostream>
using namespace std;
int main()
{
	int n,k;
	cin >> n >> k;
	int ar[n];
	int count = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> ar[i];
	}
	for(int j = 0; j < n; j++)
	{

		if((ar[j] >= ar[k-1])&&(ar[j] > 0))
		count++;
	}
	cout << count;
}

#include <iostream>
using namespace std;
int k,n,m,x,p;
int a[100];
main (){
    cin>>n>>k;
        for (int i=0;i<n;i++){
            cin>>m;
            if(m>0) {a[i]=m;}
        }
        for (p=k;p<n;p++){
                    if(a[k-1]==a[p]) k++;

        }
        for (int j=0;j<n;j++){
            if(a[j]>0&&a[j]>=a[k-1]) x++;

        }

       cout<<x;

}

#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,k,i,count,cutoff;
    cin >> n>>k;
    string s;
    int nums[n];

    i = 0 ;
    while(i<n){
        cin >> nums[i];
        i++;
    }
    i = 0;
    count = 0;
    cutoff = nums[k-1];
    if(cutoff == 0){
        for(int j = 0 ;j < k; j++){
            if(nums[j]>0){
                count++;
            }
        }
    }
    else{
        while(i < n){
            if(nums[i] >= cutoff){
                count++;
            }
            else{
                break;
                }
                i++;

        }

    }cout<<count;
}

#include<stdio.h>
int mm[120];
int main()
{

    int n,k;

    while(scanf("%d%d",&n,&k)!=EOF)
    {
        for(int i=1;i<=n;i++)
          scanf("%d",&mm[i]);
        int res=k;
        if(mm[k]>0)
        {
            for(int i=k+1;i<=n;i++)
            {
                if(mm[i]<mm[k])break;
                res++;
            }
        }
        else
        {
            res--;
            for(int i=k-1;i>=1;i--)
            {
                if(mm[i]>0) break;
                res--;
            }
        }

        printf("%d\n",res);
    }

    return 0;
}

#include <iostream>
#include <string>
#include <cmath>
#include <clocale>
#include <cstdio>

using namespace std;

int main() {
	int participants[55];
	int n, temp;

	int k = 0;

	cin >> n >> k;

	for (int i = 0; i < n; i++) {
		cin >> temp;
		participants[i] = temp;
	}

	int min, swap1, swap2;

	for (int i = 0; i < n; i++) {
		min = participants[i];
		for (int h = i + 1; h < n; h++) {
			if (participants[h] > participants[i]) {
				min = participants[h];
				swap1 = participants[h];
				swap2 = participants[i];
				participants[i] = swap1;
				participants[h] = swap2;
			}
		}
	}

	int f = k;

	for (int i = 0; i < n-k; i++) {
		if (participants[k - 1] == participants[k + i] && participants[k - 1] > 0) {
			f++;
		}
	}
	for (int i = 0; i < k; i++) {
		if (participants[k - 1 - i] == 0) {
			f--;
		}
	}

	cout << f;
}

#include <iostream>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;

    int a;
    for (int i = 0; i < k; ++i)
    {
        cin >> a;
        if (a == 0)
        {
            cout << i << endl;
            return 0;
        }
    }

    int b;
    for (int i = k; i < n; ++i)
    {
        cin >> b;
        if (b != a)
        {
            cout << i << endl;
            return 0;
        }
    }

    cout << n << endl;
    return 0;
}

#include <iostream>
using namespace std;

int main() {

int k,n,s,count=0,arr[50];

cin>>n>>k;

for(int i=0;i<n;i++){
cin>>s;
arr[i]=s;
}

for(int i=0;i<n;i++){
if(arr[i]>=arr[k-1] && arr[i]>0) count++;
}

cout<<count;
}

#include <iostream>

using namespace std;

int main()
{
    int n,k,b=0;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
    {
        if(a[i]!=0)
        {
            if(a[i]>=a[k-1])
                b++;
        }
    }
    cout<<b;
    return 0;
}

#include <iostream>
using namespace std;

int main()
{
    int k;
    int n;
    int cpt = 0;
    int *a;
    cin >> n;
    cin >> k;
    a = new (nothrow) int[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < k; i++)
    {
        if (a[i] != 0)
            cpt++;
    }
    for (int i = k; i < n; i++)
    {
        if ((a[k - 1] == a[i]) && a[i] != 0)
            cpt++;
    }
    cout << cpt;
    delete[] a;
}

#include<iostream>
using namespace std;
int main(){
    int n,k,a[100],count = 0;
    cin>>n>>k;
   for(int i = 0; i < n; i++){
     cin>>a[i];
   }

   for(int j = 0; j < n; j++){
       if(a[j]>0 && a[j]>= a[k-1])count++;
       else count = count+0;
   }
   cout<<count<<endl;
}

#include <iostream>
#include <string>
using namespace std;

int main() {
    int n;
    int p;
    int win = 0;
    cin >> n >> p;
    int arr[n];

    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }

    for(int i = 0; i < n; i++) {
        if(arr[i] >= arr[p - 1] && arr[i] > 0)
            win++;
    }
    cout << win;
    return 0;
}

#include <iostream>
#include <math.h>

using namespace std;

int main()
{

	int n, k, b;
	int r = 0;
	int l = 0;
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
	{
		cin >> b;

		if (b > 0)
		{
			if (i == k)
				r = b;

			if (b >= r)
				l++;
		}

	}
	cout << l << endl;
}

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a[105], i, n, k, m;
	cin >> n >> k;
	for (i = 1; i <= n; i++)cin >> a[i];
	m = 0;
	for (i = 1; i <= n; i++) if (a[i] != 0 && a[i] >= a[k])m += 1;
	cout << m;
    return 0;
}

#include <iostream>
using namespace std;
int a,b,c[51],i,ans,n,k;
int main()
{
cin>>n>>k;
//ans=k;

for(i=1;i<=n;i++)
{
cin>>c[i];

}
if (c[k]<=0)
    {
    //cout<<"c[k]"<<c[k]<<endl;
b=k;
ans=b;

while (c[b]<=0 && b>1)
{
    if(b>=2) b=b-1;
//cout<<"b="<<b<<endl;
    if (ans==0)break;
    ans=b;
//cout<<c[ans]<<endl;
//if(b==1)break;
//cout<<"b="<<b<<endl;

}

//cout<<ans<<endl;
//cout<<c[ans]<<endl;
if (c[ans]==0)
{ans=0;

cout<<ans<<endl;
return 0;
}cout<<ans<<endl;
    }

if (c[k]>0) {ans=k;

a=k;
//cout<<ans<<endl;
while (c[k]==c[a])
{ ans=a;

//cout<<"ans="<<ans<<endl;
if(a<n) a++;else break;

}
cout<<ans<<endl;

}
}

#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
typedef long long ll;
int n,m,a[105];
string s;
int main(){
    ios::sync_with_stdio(false);
    cin>>n>>m;
    int res = 0;
    for(int i = 1 ; i <= n ; ++i ){
        cin>>a[i];
    }
    for(int i = 1 ; i <= n ; ++i ){
        if(a[i]>=a[m] and a[i]!=0)++res;
    }
    cout<<res<<endl;
}

#include <iostream>
using namespace std;

int main()
{
	int n, k, count = 0;
	int grade[100];
	cin >> n >> k;
	for (int i = 0; i < n;i++)
		cin >> grade[i];
	for (int i = 0; i < n; i++)
	{
		if (grade[i] <= 0)
		{
			break;
		}
		if (grade[i] >= grade[k-1])
			count++;

	}
	cout << count;
	return 0;

}

#include <bits/stdc++.h>
#include <string>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t,j,r=0,p;
    cin >> t;
    cin >> j;
    p=t;
    int e[t];
    int o=0;
    while(t--){
       cin >> e[t];
        if (p-t == j)
            o=e[t];
    }
    for (int i=0;i<p;i++)
        {
            if(e[i]>=o and e[i]>0)
                r++;
        }
    cout << r;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll 		long long
int main()
{
	ll n,k;
	cin>>n>>k;
	vector<int> adj;
	for(int i=0;i<n;i++)
	{
		int m;
		cin>>m;
		adj.push_back(m);
	}
	ll a=adj[k-1];
	ll z=0;
	vector<int>::iterator itr;
	for(itr=adj.begin();itr!=adj.end();itr++)
	{
		if(*itr>0)
			{
				if(*itr>=a)
				{
					z++;
				}
			}
	}
	cout<<z;
}

#include<iostream>
using namespace std;

int main()
{
    int n,k,z=0;
    cin >> n >>k;
    int *a = new int [n];
    for(int i=0; i<n; i++)
    {
        cin >> a[i];
    }
    for(int i=0;i<n;i++)
    {
        if(a[k-1]==0)
        {
            if(a[i]>a[k-1])
            {
                z++;
            }
        }
        else
        {
            if(a[i]>=a[k-1])
            {
                z++;
            }
        }
    }
    cout << z;
    return 0;
}

#include <iostream>
using namespace std;

int main() {
int n,ka;
cin>>n>>ka;
int arr[n];
int answer=0;
for(int i=0;i<n;i++){
	cin>>arr[i];
}
int refrence=arr[ka-1];
for(int i=0;i<n;i++){
	if(arr[i]>=refrence&&arr[i])
	++answer;
}
cout<<answer;

	return 0;
}

#include<iostream>

using namespace std;

int main(){

	int n, k;

	while(1){
		cin >> n >> k;
		if(cin.eof()) break;

		int x[50] = {0};

		for(int i = 0; i < n; ++i) cin >> x[i];

		int key = x[k - 1];
		int count = 0;

		for(int i = 0; i < n; ++i){
			if(x[i] > 0 && x[i] >= key) ++count;
			else break;
		}

		cout << count << endl;
	}

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,count=0;
    int c[50];
    cin>> a>> b;
    for(int i=0; i<a; i++){
       cin>>c[i];
    }
    for(int i=0; i<a; i++){
     if(c[i]>=c[b-1] && c[i]!=0)
     count++;
  }
    cout<<count<<endl;

}

#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
    int n,m;
    cin >> n>> m;
    vector<int>a;
    for (int i=0;i<n;i++)
    {
        int k;
        cin >> k;
        a.push_back(k);
    }
    int sum=0;
    for (int i=0;i<n;i++)
    {
        if(a[m-1]==0)
        {
            if(a[i]>0)
            {
                sum=sum+1;
            }
        }
        else

        {
        if(a[i]>a[m-1]-1)
        {
            sum=sum+1;
        }
        else{
            sum=sum+0;
        }
        }
    }
    cout << sum;
    return 0;
}

#include <iostream>
using namespace std;

void main()
{
	__int16 n, k, ii, kk, v;
	ii = 0;
	v = 1;

	cin >> n; cout << " "; cin >> k; cout << endl;

	__int16* a = new __int16[n];

	for (__int16 i = 0; i < n; i++)
	{
		cin >> a[i];

		if (a[i] == 0)
		{
			//delete[] a;
			cout << i;
			exit(0);
		}

		if (i == k - 1) kk = a[i];

		if (a[i] >= kk) ii = i + 1;
		else
		{
			//delete[] a;
			cout << ii;
			exit(0);
		}

		cout << " ";
	}
	cout << ii;
}

#include<stdio.h>

int main(void)
{
	int advancer[105],i,n,k,count,j;
	while(scanf("%d%d",&n,&k) != EOF)
	{
		for(i = 0 ; i < n ; i ++)
			scanf("%d",&advancer[i]);
		count = 0;
		for(i = 0 ; i < k ; i ++)
		{
			if(advancer[i] == 0)
				break;
			else
				count++;
		}
		if(count == k)
		{
			for(i = k ; i < n ; i ++)
			{
				if(advancer[i] == advancer[i - 1])
					count++;
				else
					break;
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int count=0;
    int *a=new int [n];
    for(int i=0;i<n;i++)
    {
    cin>>a[i];}
    for(int j=0;j<n;j++)
    {
    if(a[j]>=a[k-1]&&a[j]>0)
    count++;}
    cout<<count<<endl;
    return 0;

    }

#include<iostream>
using namespace std;
int main()
{
     int n,k;
     int x[1000];
     cin>>n>>k;
     x[0]=-1;
     for(int i=1;i<=n;i++) cin>>x[i];
     while(k>0&&x[k]==0) k--;
     while(k+1<=n&&x[k+1]==x[k]) k++;
     cout<<k;
}

#include<iostream>
using namespace std;
 int main()
 {
 int n,k;
 cin>>n>>k;
 int arr[n];
  for(int i=0;i<n;i++)
   cin>>arr[i];
   int cnt=0;
   for(int i=0;i<n;i++)
   {

    if(arr[i]>=arr[k-1]&&arr[i]>0)
    cnt++;
    else if(arr[i]<arr[k-1])
    break;
     }
     cout<<cnt;
     }

#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;

    int a;
    for (int s = 0; s < k; ++s)
    {
        cin >> a;
        if (a == 0)
        {
            cout << s << endl;
            return 0;
        }
    }

    int b;
    for (int s = k; s < n; s++)
    {
        cin >> b;
        if (b != a)
        {
            cout << s << endl;
            return 0;
        }
    }

    cout << n << endl;
    return 0;
}

#include <cstdio>
#include <cstring>
int main()
{
    int score[60],n,k,i,count;
    while(scanf("%d %d",&n,&k)==2)
    {
        count=0;
        for(i=1;i<=n;i++)
            scanf("%d",&score[i]);
        for(i=1;i<=n;i++)
            if(score[i]>0&&score[i]>=score[k])count++;
        printf("%d\n",count);
    }
    return 0;
}

#include <iostream>
#include <string>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int resultCounter = 0;
    int duplicateCounter = 0;
    int input[50];
    for (int i = 0; i < n; i++) {
        cin >> input[i];
    }
    for (int i = 0; i < n; i++) {
        if (input[i] == 0) {
            break;
        }
        if (i < k) {
            resultCounter++;
        }
        if (i >= k) {
            if (input[i] != input[i - 1]) {
                break;
            } else {
                duplicateCounter++;
            }
        }
    }
    cout << resultCounter + duplicateCounter;
}

#include<iostream>
using namespace std;
int n,k,i,a[50],x;

int main()
{
cin>>n>>k;
x=0;
for (int i=1;i<=n;i++) cin>>a[i];
for (int i=1;i<=n;i++){
if (a[i]>=a[k] and a[i]>0)  x++;
}
cout<<x;
}

#include<stdio.h>
int main()
{
	int n,k,i;
	while(scanf("%d%d",&n,&k) != EOF)
	{
	int total=0;
	int a[50];
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	if(a[k-1]==0)
	{
		for(i=0;i<n;i++)
		{
			if(a[i]>a[k-1])
				total=total+1;
		}
	printf("%d",total);
	return 0;
	}
	else
	{
		for(i=0;i<n;i++)
		{
		if(a[i]>=a[k-1])
			total=total+1;
		}
	printf("%d",total);
	return 0;
	}
}
}

#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    int i,j,k=0,n,m;
    cin >> n;
    int a[n];
    cin >> m;
    for(i=0;i<n;i++)
    {
        cin >> a[i];
    }
    if(a[m-1]==0) for(i=m-1;i>=0;i--)
                  {
                      if(a[i]!=0) {k=i+1; break;}
                  }
    i=m;
    if(a[m-1]!=0)
	{
		if(a[m]!=a[m-1]) k=m;
		else if(a[m]==a[m-1])
		{
			do
   		 	{
       			if(a[i]<a[m-1] || i>n-1) {k=i; break;}
                i++;
            }	while(i<n+2);
	    }
	}
    if(a[0]==0) k=0;
    cout << k;
    return 0;
}

#include <iostream>
using namespace std;
int main(){
    int A[50];
	int x,y;
	int a=0,b=0,c=0;
    cin>>x>>y;
    y=y-1;
    b=y;
    for(int i=0;i<x;i++){
    	cin>>A[i];
    	if (A[i]!=0)
    	a++;
	}
	if(a==0){
	cout<<"0";
	return 0;}
	for(int i=y;i<x;i++){
		if (A[y]==A[i]&&A[y]!=0)
		b++;
	}
	if (a<b)
	cout<<a;
	else cout<<b;

	return 0;

}

#include <iostream>
using namespace std;

int main() {
    cin.tie(NULL);
    cout.tie(NULL);
    int n, k; cin >> n >> k;
    int a;
    for(int i = 0; i < k; i++){
        cin >> a;
        if(a == 0){
            cout << i << "\n";
            return 0;
        }
    }
    for(int i = k; i < n; i++){
        int b; cin >> b;
        if(b != a){
            cout << i << "\n";
            return 0;
        }
    }
    cout << n << "\n";
    return 0;
}

#include <iostream>

using namespace std;

int main()
{
	int n,k,a[200],dau=0;

	cin >> n >> k;

	for (int i=1 ; i<=n ; i++)
	{
		cin >> a[i];
	}

	if (a[k]>0)
	{
		for (int i=1 ; i<=n ; i++)
		{
			if (a[i]>=a[k])
				dau += 1;
		}
	}
	if (a[k]==0)
	{
		for (int i=1 ; i<=n ; i++)
		{
			if (a[i]>0)
				dau += 1;
		}
	}

	cout << dau;
}

#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
    int n,k,i,score,out,cnt;
    int a[200];
    cin>>n>>k;

    for(i=0;i<n;i++)
    {
        cin>>a[i];

         score=a[k-1];

    }

    cnt=0;
    for(i=0;i<n;i++)
    {
        if(a[i]>=score&&a[i]>0)
        cnt++;
    }

    cout<<cnt;
}

#include <iostream>

using namespace std;

const int MAX = 55;
int v[MAX];

int
main() {

  int n, k;

  cin >> n >> k;

  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  int nr = 0;
  for (int i = 0; i < n; i++) {

    if (v[i] >= v[k-1] && v[i] > 0) {
      nr++;
    }
  }
  cout << nr << endl;
  return 0;
}

#include <iostream>
#include <string>
#include <vector>

int main() {
	int n = 0, k = 0, count = 0, buffer = -1, a = 0;
	std::cin >> n >> k;
	for (int i = 1; i <= n; i++) {

		std::cin >> a;
		if (a == 0)
			continue;
		else if (i == k) {
			buffer = a;
			count++;
			//std::cout << "Case: 1;\nCount: " << count  << ";" << std::endl;
		}
		else if (i < k) {
			count++;
			//std::cout << "Case: 2;\nCount: " << count << ";" << std::endl;
		}
		else if (a == buffer) {
			count++;
			//std::cout << "Case: 3;\nCount: " << count << ";" << std::endl;
		}

	}
	std::cout << count;
	return 0;
}

#include <stdio.h>
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int m,n;
	cin >> m;
	cin >> n;
	int zero = 0;
	int Original[m];
	int CopyOriginal[m];
	int Place = 0;
	for (int i = 0;i < m; i++) {
			cin >> Original[i];
	}
	for (int i = 0; i < m; i++) {
			CopyOriginal[i] = Original[i];
	}
	if (m == n) {
		int reptitions = 1;
		for (int i = 0; i < m; i++)
		{
			bool repeat = false;
			for (int counter = 0; (counter < i) && (repeat == false); counter++) {
				if (Original[i] == Original[counter]) {
					repeat = true;
					reptitions++;
				}
			}
		}
		if (reptitions == 1) {
			reptitions = 0;
		}
		int final = m - reptitions;
	} else if (Original[0] != Original[m-1]) {
		for (int i = 0; i < m; i++)
		{
			bool repeat = false;
			for (int counter = 0; (counter < i) && (repeat == false); counter++) {
				if (Original[i] == Original[counter]) {
					repeat = true;
				}
			}
		}
		Place = Original[(n-1)];
		int FinalAnswer = 0;
		for (int i = 0; i < m; i++) {
			if (CopyOriginal[i] >= Place) {
				FinalAnswer++;
			}
		}
		printf("%d\n", FinalAnswer);
	} else if (n == 1){
		printf("%d\n", m);
	} else {
		printf("%d\n", zero);
	}
	return 0;
}

#include<stdio.h>
int main(){
    int n,k,i,j,b,count=0;
    scanf("%d%d",&n,&k);
    char a[n+10];
    for(j=1;j<=n;j++){
        scanf("%d",&b);
        a[j]=b;
        if(a[1]==0){
        printf("0");
        return 0;}
    }
    count=k;
    for(i=k;1;i++){
        if(i==n)
            break;
        else if(a[i]==a[i+1])
            count++;
        else
            break;}
    printf("%d",count);
return 0;
}

#include <iostream>
using namespace std ;
int main ()
{
    int arr [10000] ;
    long long x , y , k , l = 888888889 , z=0 ;
    cin >>x >> y ;

    for (int i = 0 ; i < x ; i++)
    {
        cin >> arr [i] ;
    }
    for (int j = 0 ; j < x ; j++ )
    {
        if (arr [j] >= arr [y] && arr [j] > 0)
        {
            z++ ;
        }
    }
    cout << z << "\n";
    return 0 ;
}

#include <iostream>
using namespace std;
int main()
{

	int k;
	int n;
	cin >> n;
	cin >> k;
	int s = 0;
	if (k >= 1 && n >= k && k <= 50)
	{
		int arr[n];
		for (int i = 0; i < n; i++)
		{
			cin >> arr[i];
			if (arr[i] >= arr[k - 1] && arr[i]>0)
			{
				s++;
			}
		}

		cout << s;
	}

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int a[55],n,k,b,c,d,e,f,g,i,sum;
main() {
	cin>>n>>k;
	for (i=0; i<n; i++) {
		cin>>a[i];
	}
	for (i=1; i<n; i++)	{
	sum+=a[i];}
	if (sum==0) {cout<<"0"; return 0;
	}
	b=a[k];
	for (i=0; i<n; i++) {
		if (a[i]>b) c++;
		if (a[i]==b) d++;
	}
	if (d>1) cout<<c+d;
	else cout<<c;
}

#include <iostream>
using namespace std;

int main()
{
	int n,k,a[50],jumlah;
	cin>>n>>k;
	for(int x=1;x<=n;x++)
	{
		cin>>a[x];
		if(a[x]>k)
		{
			jumlah++;
		}
	}
	cout<<jumlah;
}

#include <iostream>

using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    int num;
    int sum=0;
    int scores[n];
    int threshold;

    for(int i=0;i<n;i++){
            scanf("%d",&scores[n]);
            }
    threshold=scores[k];

    for(int i=0;i<n;i++){
            if(scores[n]>threshold && scores[n]>0){sum++;}
    }

    cout << sum;
}

#include<iostream>
using namespace std ;
int main()
{int n,k ;
int count=0 ;
int a[50] ;

    cin>>n>>k ;

    for(int i=0 ;i<n ;i++)
    {

    cin>>a[i] ;}

    for(int i=0 ;a[i]>0 && a[i]>=a[k-1] && a[i]<n ;i++)
    ++count ;

    cout<<count<<endl ;
    return 0 ;
}

#include<iostream>
using namespace std;

int main()
{
    int n,k,cnt=1,a,b;

    cin>>n>>k;
    cin>>a;
    for(int i=1;i<n;i++)
    {
        cin>>b;
        if(k==1 && a ==b)
            k++;
        if(a>=b && a!=0 && k>1)
        {
            cnt++;
            a = b;
            k--;
        }

    }
    if(k==1)
        cout<<cnt<<endl;
    else
        cout<<0<<endl;
 return 0;
}

#include <iostream>
int main(){
	int n,k;
	std::cin>>n>>k;
	int a[n];
	for (int i=0;i<n;i++){
		std::cin>>a[i];
	}
	int kq=0;
	for (int i=0;i<n;i++){
		if (a[i]>=a[k] && a[i]!=0){
			kq++;
		}
	}
	std::cout<<kq;
}

#include<iostream>
using namespace std;
int main()
{
	int n;
	int k;
	int d=0;
	cin>>n>>k;
	for (int i=0;i<n;i++){
		int h[n];
		cin>>h[i];
		if (h[i]>k)
		d++;
	}
	cout <<d<<endl;

}

#include<iostream>
  using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    int arr[105];
    int i=0,res=0;
    while(i<n)
    {
        cin>>arr[i];
        i++;
    }

    if(arr[0]==0)
    {
     cout<<"0"<<endl;
     exit(0);
    }

    if(n==1)
    {
      cout<<1<<endl;
      exit(0);
    }

    if(n==2)
    {
        if(arr[0]>=arr[1])
        cout<<1<<endl;
        exit(0);

    }

    if(k!=0 && arr[k-1]!=0)
    {
        res=k;

        int i;
        for(i=k;i<n;i++)
        {
            if(arr[i]!=0 && arr[i]==arr[i-1])
             res++;
            else
             break;
        }

        if(i==n-1)
        {
            if(arr[i]!=0 && arr[i-1]==arr[i])
             res++;
        }
    }
    else
    {
        int i;
        for(i=0;i<k-1;i++)
        {
            if(arr[i]!=0 && arr[i]>=arr[i+1])
             res++;
            else
             break;
        }

        if(i==k-1)
        {
            if(arr[i-1]>=arr[i])
             res++;
        }
    }

    cout<<res<<endl;
}

#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,k,c=0;
    int a[200];
    cin>>n>>k;

    if(1<=n && n<=50 && 1<=k && k<=50)
    {

        for(int i=1;i<=n;i++)
        {
            cin>>a[i];

        }

        for(int i=1;i<=n;i++)
        {

            if(a[k]>0 && a[i]>=a[k])
            {
                c++;
            }

        }

    }
    cout<<c;
    return 0;

}

#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n,k;
    int ptemp=-1,temp=0;
    bool consec=false;
    int count=0;

    cin>>n>>k;

    for(int i=0;i<n;i++)
    {
        cin>>temp;

        if(ptemp==temp)
        {
            consec=true;
        }

        if(temp>k)
        {
            if(!consec)
            {
                count++;
                ptemp=temp;
                continue;
            }

            if(consec)
            {
                if(ptemp==temp)
                count++;
                else
                {
                    cout<<count;
                    return 0;
                }
            }
        }

        ptemp =temp;

    }
    cout<<count;
    return 0;
}

#include <iostream>
#include <string>
#include <cmath>
#include <clocale>
#include <cstdio>

using namespace std;

int main() {
	int participants[55];
	int n, temp;

	int k = 0;

	cin >> n >> k;

	for (int i = 0; i < n; i++) {
		cin >> temp;
		participants[i] = temp;
	}

	int min, swap1, swap2;

	for (int i = 0; i < n; i++) {
		min = participants[i];
		for (int h = i + 1; h < n; h++) {
			if (participants[h] > participants[i]) {
				min = participants[h];
				swap1 = participants[h];
				swap2 = participants[i];
				participants[i] = swap1;
				participants[h] = swap2;
			}
		}
	}

	int f = k;

	int v = 0;

	for (int h = 0; h < n; h++) {
		if (participants[h] == participants[h + 1]) {
			v += 1;
		}
		if (v == n -1) {
			cout << n;
			return 0;
		}
	}

	for (int h = 0; h < k; h++) {
		if (participants[k - 1] == participants[k + h] && participants[k + h] > 0) {
			f++;
		}
	}

	for (int h = 0; h < k; h++) {
		if (participants[h] == 0) {
			f = f - 1;
		}
	}

	cout << f;
}

#include<string>
#include <iostream>
#include<vector>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int flag = 0;
    int* Arr = new int[n];
    for (int i = 0; i < n ; ++i) {
        cin >> Arr[i];
    }
    int ans = 0;

    if (Arr[0] == 0) {
        cout << 0;
        return 0;
    }

    for (int i = 0; i < k; ++i) {
        if (Arr[i] != 0) ans++;
        else break;
    }
    for (int i = k; i < n; i++) {
        if (Arr[i] == Arr[k - 1])ans++;
    }
    cout << ans;

    cin.get();
    cin.get();
}

#include <stdio.h>

int main() {
    int n, k;
    scanf("%d %d\n", &n, &k);

    int num_k, num_next, res = -2;
    for(int i = 0; i < k; ++i){
        scanf("%d ", &num_k);
        if (num_k == 0) res = i - 1;
    }

    if (num_k != 0) {
        for(int i = k; i < n; ++i){
            scanf("%d ", &num_next);
            if (num_next != num_k){
                res = i;
                break;
                }
        }
    }

    if (res == -2) res = n;
    else if (res == -1) res = 0;

    printf("%d", res);

    return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,k,i,count,cutoff;
    cin >> n>>k;
    string s;
    int nums[n];

    i = 0 ;
    while(i<n){
        cin >> nums[i];
        i++;
    }
    i = 0;
    count = 0;
    cutoff = nums[k];
    if(cutoff == 0){
        cout<<0;
    }
    else{
        while(i < n){
            if(nums[i] >= cutoff){
                count++;
            }
            else{
                break;
                }
                i++;

        }
        cout<<count;
    }
}

#include<iostream>
using namespace std;
int main()
{
	int k, c = 0, n; cin >> n >> k;
	int a[101];
	if (n >= k) {

		for (int i = 1; i <= n; i++) {
			if(i==1)
				cin >> a[0];
			cin >> a[i];
			if ((a[i] <= a[i - 1]) && ((a[i - 1] > k) || (a[i - 1] == 1))){
				c++;

		}
		}
		cout << c;
	}
	else
	{
		cout << 1;
	}
    return 0;
}

#include <iostream>
using namespace std;
int main()
{
    int x;
    int y;
    cin>>x>>y;
    int z[x];

    int q=0;
    for(int i=0;i<x;i++)
        cin>>z[i];

    for(int i=0;i<x;i++)
    if(z[i]>=z[y] && z[i]!= 0)
            q++;

    cout<<q<<endl;

    return 0;
}

#include <iostream>

using namespace std;

int main() {
	int n, k, a[49], count = 0;
	do {
		cin >> n >> k;
	} while (k < 1 || n > 50 || n < k);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		if (a[i] >= a[k]) count++;
	cout << count;
	return 0;
}

 #include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<int>a;
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0; i<n;i++){
	int b;
	cin>>b;
	a.push_back(b);}
		sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
    int y=0;
	for(int i=0;i<n;i++)
	if (a[i]>=a[k-1])
	y++;
	if ( a[k-1]!=0)
cout<<y;
else cout<<0;

	return 0;}

#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

int main()
{
    int n,k;

        cin>>n>>k;
        int c=k;
    int p[55];
    for(int i=1; i<=n; i++){
            cin >> p[i];

            }
            for(int j=k+1; j<=n; j++){
                if (p[j]==p[k]&&p[j]>0){ c++;}
            }
            cout << c;

}

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
    int n, a[100], k, sum=0;
    vector<int> niz;
    int x;

    cin >> n >> k;

    for (int i=0;i<n;i++)
    {
        cin >> x;
        if (x==0)
            sum++;
        niz.push_back(x);
    }

    k--;

    sort (niz.begin(), niz.end());
    reverse (niz.begin(), niz.end());

    if (sum==n)
    {
        cout <<"0";
        return 0;
    }

    if (k+1==n)
    {
        if (niz[k]==0)
        {
            while (niz[k]==0)
                k--;
        }

        cout << k+1;
        return 0;
    }
    int pb;

    if (niz[k]==niz[k+1])
    {
        for (int i=k+1;i<n;i++)
            if (niz[i]!=niz[k])
            {
                cout << i;
                pb=i;
                break;
            }

                else if (i==n-1)
                    {
                        pb= n;
                    }
    }
    else
    {
        pb= k+1;
    }

    if (niz[k]==0)
        {
            while (niz[pb]==0)
                pb--;
        }

        cout << pb;

    return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
    int n,k;
    cin>>n;
    cin>>k;
    vector<int> input(n);
    for(auto i=input.begin();i!=input.end();i++)
    {
        cin>>*i;
    }
    if(upper_bound(input.begin(),input.end(),k)==input.end())
        cout<<0;
    else
        cout<< (upper_bound(input.begin(),input.end(),k)) - input.begin() + 1 ;
}

#include <iostream>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    bool check = true;
    int result = 0;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if(!check) continue;
        if(a <= 0 || i >= k)
            check = false;
        result++;
    }
    cout << result;
    return 0;
}

#include <iostream>
using namespace std;

int main() {
    int n, k, t = 0;
   cin >> n >> k;
   int* a = new int [n];
   for(int i=0; i<n; i++){
       cin >> a[i];
   }
    int i = 0;
    while(a[k-1]<=a[i] && a[i]>0){
    ++t;
    ++i;
    }
cout << t;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,i,Count=0;
    cin>>n>>k;
    int arr[50];
    for(i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    for(i=0; i<n; i++)
    {
        if(arr[i]<arr[i+1])
        {
            swap(arr[i],arr[i+1]);
        }
    }
    for(i=0; i<k; i++)
    {
        if(arr[i]!=0)
            Count++;
    }
    for(i=k-1;i<n;i++)
    {
        if(arr[i]==arr[i+1] && (arr[i] && arr[i+1]!=0))
        {
            Count++;
        }
    }
    cout<<Count<<endl;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
	int n,k,count = 0;
	cin>>n>>k;
	int arr[n];
	for(int i = 0; i < n; i++)
	{
		cin>>arr[i];
		if(arr[i] > k)
		{
			count++;
		}
		if(arr[i] >= 1)
		{
			count++;
		}
	}
	cout<<count;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int x[n];
    int counter=0;
    for(int i=0;i<=n-1;i++){
        cin>>x[i];
    }

    for(int i=0;i<=n-1;i++){
        if(x[i]>=x[k]){
            counter++;
        }

    }
    for(int i=0;i<=n-1;i++){
        if(x[i]==0){
            counter=0;
        }

    }
    cout<<counter;
    return 0;
}

#include<stdio.h>
int main()
{
    int j,k,g=0,u=0,l,f,p=8;
    scanf("%d%d",&j,&k);
    for(int i=0; i<j; i++)
    {
        scanf("%d",&l);
        if((g==0 and   l==k )or( g==u and  l==f)or(g==0 and p==0 ))
        {
            g++;
            f=l;
            u++;

        }
        if(l>k){            g++;

}
else
p=0;
    }
    printf("%d",g);

}

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    /*long long int n,m;
    long long int a;
    long long int l;
    long long int w;
    long long int num1;
    long long int num2;
    long long int z;
    cin >> n >> m;
    cin >> a;
    for (int i = 0 ; i >= 0  ; i++){
        num1 = i*a;
        if (num1 >= n){
           l = i;
           cout << l << endl;
           break;
        }
    }
    for (int h = 0; h>=0 ; h++){
        num2 = h*a;
        if (num2 >= m){
            w = h;
            cout << w <<endl;
            break;
        }
    }
    z = w*l;
    cout << z << endl;*/

    /*int w;
    cin >> w ;
    if(w%2 == 0){
            if(w == 2){
                cout << "No" << endl;
            }else{
                cout << "yes" << endl ;
            }
    }else{
        cout << "No" << endl;
    }*/
    /*int y,a,b=0,s;
    cin >> y;
    a = y/3600;
    s=y%60;
    while(y>60){
            if(y>3600){
            y-=3600;
        }
        else if(y>60){
            y-=60;
            b++;
        }
    }
    cout << a << ":" << b << ":" << s;*/

    /*string a;
    string w ="" ;
    string Vewols="a,e,i,o,u,y";
    cin >> a;
    /*to change uppercase to lowercase*/
    /*transform(a.begin(), a.end(), a.begin(), ::tolower);
    for (int i = 0 ; i < a.size(); i++){
        int y = 0;
        for (int x = 0 ; x < Vewols.size() ; x++){
            if (Vewols[x] == a[i]){
                y = 1;
            }
        }
        if (y == 0){
            w+=".";
            w+=a[i];
        }
    }
    cout << w << endl;*/

    int n,k,e,x=0;
    cin >>n>>k;
    int a[n];
    for(int h=0; h<n ;h++){
        cin >> e;
        a[h]=e;
    }
    for(int i=0; i<n; i++){
        if(a[i]>=a[k]){
            if(a[i] != 0){
                x++;
            }
        }
        /*if (k == n){
            if(a[i] >= a[k-1]){
                if(a[i] !=0){
                    x++;
                }
            }
        }*/
    }
    cout << x<<endl;
    return 0;
}

#include<iostream>
using namespace std;

int main()
{
          int n,k,a[100],count=0;
          cin >> n>>k;
          for(int i=0; i<n; ++i)
          {
                    cin >> a[i];
                    if(a[i]>=k) count++;
          }
          cout << count;
          return 0;
}

#include <iostream>

using namespace std;
int main() {
	int n, k,kth;
		int y[100];
	int count=0 ;

	cin >> n >> k;
	cout << endl;

		for (int i = 0; i < n; i++)
			cin >> y[i];

		kth = y[k];
		for (int i = 0; i < n; i++) {
			if (kth <= y[i] && y[i] > 0)
				count++;

		}

		cout << count << endl;

	return 0;
}

#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int* scores = new int[n];
    for(int i = 0; i < n; ++i)
        cin >> scores[i];

    int count = n - 1;
    for(; count >= 0; --count)
        if(scores[count] >= scores[k - 1])
            break;
    ++count;

    cout << count;

    return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int n,k,x,y=0;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if (x>k)
            y++;
    }
    cout<<y;
    return 0;
}

#include<iostream>
#include<vector>

using namespace std ;
bool equal(int * a,int n,int k){

    for(int i = 0 ; i < n ; i++)
        if(a[0] != a[i] )
             return false ;
    if(a[0] == k)
        return true ;
    return false ;
}
int main(){
    int n,k,next,first ;
    cin >> n >> k ;
    int a[n] ;
    for(int i = 0 ; i < n ; i++)
        cin >> a[i] ;
    next = 0 ;
    for(int i = 0 ; i < n ; i++)
        if(a[i] > k)
            next += 1 ;
    if(equal(a,n,k))
        next = n ;
    cout << next << endl ;
    return 0 ;
}

#include <iostream>
int main(){
	int n,k;
	std::cin>>n>>k;
	int a[n];
	for (int i=0;i<n;i++){
		std::cin>>a[i];
	}
	int kq=0;
	for (int i=0;i<n;i++){
		if (a[i]>=a[k]){
			kq++;
		}
	}
	std::cout<<kq;
}

#include <stdio.h>

int main(){
    int i,j;
    int out;

    int input[2];
    int caa[50];

    scanf("%d %d", &input[0], &input[1]);

    for(i=0;i<input[0];i++){
        scanf("%d ",&caa[i]);
    }

    if(i<input[1]){
        for(i=0; i<input[1]; i++){
            if(caa[i]==0){
                out=i;
            }
        }
    }
    else if(caa[input[1]-1]!=caa[input[1]]) {
        out=input[1];
    }
    else{
        for(i=0; i<input[0]-input[1]; i++){
           if(caa[input[1]-1]== caa[input[1]+i]){
            out=input[1]+i+1;
            }
        }
    }

    printf("%d",out);

    return 0;

}

#include <iostream>
#include <cmath>

using namespace std;

int main() {

    int n,k,ans = 0, temp = 0, count = 1;

    cin >> n >> k;

    int a[n];

    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    temp = a[0];

    for (int i = 1; i < n; i++) {

        if (count == k) {

            if (a[i] < temp)

                temp = a[i];

        }

        if (count < k){

            if (a[i] < temp){

           temp = a[i];
            count++;

            }

        }

        if (count == k) {

            if (a[i] < temp)

                temp = a[i];

        }

    }

    for (int i = 0; i < n; i++) {

        if (a[i] > temp && a[i] > 0)

        ans++;

    }

    cout << ans;

    return 0;

}

#include<iostream>
using namespace std;

int main ()
{
  int n,k,a[100];
  int c=0;
  cin>>n>> k;
  for(int i=1;i<=n;i++){
   cin>>a[i];
  }
  for(int j=k+1;j<=n;j++){
    if(a[j]>=a[k]&&(a[j]!=0)){
      c++;
    }
  }
  for(int i=1;i<=n;i++){
   if(a[i]==0){
    c--;
  }
  }

  cout<<(c+k);

  return 0;
}

# include<iostream>
using namespace std;
void main()
{
    int n,k,c=0;
    int a[51];
    cin>>n>>k;
    while((n<k)||(n>50))
        cin>>n;
    while((k<1)||(k>n))
        cin>>k;
    for(int j=0;j<n;j++)
        {
            cin>>a[j];
            while((a[j]<0)||(a[j]>100))
                cin>>a[j];
    }
    for(int j=0;j<n;j++)
    {
            if(a[j]>k)
            c++;
    }

    cout<<c;
}

 #include <iostream>
using namespace std;
int main()
{
  int a[1000];
  int n,k,c=0;
  cin>>n>>k;
  for(int i=0;i<n;i++)
    cin>>a[i];
  c=k;

      if(a[k]==0){cout<< 0;return 0;}
  for(int i=k+1;i<n||i==k+1;i++)
      if(a[i-1]==a[k])c++;
  cout<<c;
    return 0;
}

#include <iostream>
using namespace std ;
int main ()
{
    int arr [100000] ;
    long long x , y ,k = 9999999 , z=0 ;
    cin >>x >> y ;

    for (int i = 0 ; i < x ; i++)
    {
        cin >> arr [i] ;
    }
    for (int j = 0 ; j < x ; j++ )
    {
        if (arr [j] >= arr [y] && arr [j] > 0 && arr [j] <= k)
        {
            z++ ;
        }
        k = arr [j] ;
    }
    cout << z << "\n";
    return 0 ;
}

#include<iostream>
using namespace std;

int main()
{
	int n,k,count=0;
	cin>>n>>k;
	int a[n];

	if(n>0)
	{

	if(n>=k)
	{

	for(int i=0;i<n;i++)
	{

		cin>>a[i];

	}
	for(int i=0;i<n;i++)
	{
		if(a[i]<0)
		{
			cout<<"0";
			return -1;
	}
}
for(int i=0;i<n-1;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(a[i]<a[j])
			{
				cout<<"0";
				return -1;
			}
		}
	}

	for(int i=0;i<k;i++)
	{
	  if(a[i]>=a[k-1]&&a[i]>0)
	  count++;

	}
	if(a[k]==a[k-1]&&a[k]>0)
	{
		count++;
	}

}

	cout<<count;

	return 0;
}
}

#include<iostream>
using namespace std;

int main()
{
          int n,k,a[100],count=0;
          cin >>n>>k;
          for(int i=0; i<n; ++i)
          {
                    cin >> a[i];
          }
          if(a[k]>=k)
          cout<<k+1;

          return 0;
}

#include<stdlib.h>
#include<stdio.h>
#include<math.h>
int main()
{
  int n,k,i, a[51];
  scanf("%d %d",&n,&k);
  for(i=0;i<n;++i)
  scanf("%d",&a[i]);
  if(a[k]==0)
  {
    printf("0");
  return 0;
  }
  for(i=k-1;a[i]==a[i+1] && i<n;++i);

  if(i==n-2)
    printf("%d",n-1);
  else
  printf("%d",i+1);
  return 0;
}

#include <iostream>
using namespace std;

int main(void) {
    int n, k;
    cin >> n;
    cin >> k;

    int* arr = new int[n];
    for (int i = 0; i < n; ++i) cin >> arr[i];

    int freq[101] = {};

    for (int i = 0; i < n; ++i) freq[arr[i]]++;

    int count = 0;
    for (int i = 0; i < 101; ++i) {
        if (count >= k) break;
        count += freq[i];
    }
    if (n == k) {
        cout << n << endl;
    } else {
        cout << count << endl;
    }
}

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k,i,cont=0,l;
    cin>>n>>k;
    int a[n]={};
    for(int i=0;i<n;i++){cin>>a[i];}
    for(int l=0;l<n;l++){
        if(a[l]>=a[k]){
            cont++;
        }
    }
    cout<<cont<<endl;
return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main(){
	int n;
	int k;
	cin >> n;
	cin >> k;
	int next=0;
	int ai;
	for (int i=0; i<n; i++){
		cin >> ai;
		if (ai>k){
			next=next+1;
		}

	}
	cout << next << "\n";

	return 0;
}
// 1501885740868

#include <iostream>
using namespace std;
int n,k,i,a[55],b,c,d,jami;
main() {
	cin>>n>>k;
	for (i=0; i<n; i++) {
		cin>>a[i];
	}
	for (i=0; i<n; i++) {
		jami+=a[i];
	}
	if (jami==0) { cout<<"0"; return 0;
	}
	b=a[k];
	for (i=0; i<n; i++) {
		if (b!=0 && a[i]>b) c++;
		if (b!=0 && a[i]==b) d+=1;
	}
	if (d==1) { cout<<c; return 0;
	}
	if (d!=1) { cout<<c+d; return 0;
	}
}

#include <iostream>
using namespace std;

int main()
{
	int n, k,count=0,a=0,x=0;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{

		cin >> x;
		if (x == a && x>=k)
		{
			count++;
		}
		else
		{
			if (x > k)
			{
				count++;
				a = x;
			}
		}

	}
	cout << count;
	return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int k,n=0,i,j=0,b=0,c=0,t,z=0;
    cin>>n;
    cin>>k;
    int a[n];
    int q=0;

    for (i=0;i<n;i++)
    {
        cin >>a[i];
        //q=q+a[i];
        if(a[i]==0&&i!=n-1);
            {z=i;
            c--;
            }

    }

    while(a[k-1]==a[k])
    {
        //b++;
        k++;
    }
    //if (a[])
    //if (q==0)
        //cout<<"0";
        int e ;
        e=k+c;
        if(k>z)
            cout <<e;
       else
    cout<<k;

    return 0;
}

#include <iostream>
using namespace std;
int main()
{
	int n[50],m,k,i,w=0,a=0;
    cin>>m>>k;
	if(k>=1 && k<=100)
	{
		for(i=0;i<m;i++)
		{
			cin>>n[i];
			a+=n[i];
		}
		if(a%m==0 && a>0 )
		{
			cout<<m;
			return 0;
		}
		if(m>=k)
		{
			for(i=0;i<m;i++)
			{

				if(n[i]>k)
					w+=1;
			}
			cout<<w;
		}
	}
		return 0;
	}

#include <iostream>
using namespace std;

int main() {
	int n,k;

	cin>>n>>k;

	int scores[101];
	for(int i=0; i<n; i++){
		cin>>scores[i];
	}
	if(scores[0]==0){
		cout<<0;
	}

	if(scores[0]!=0 && k<=k+1){
		cout<<k+1;
	}
	else{
		cout<<k;
	}

	return 0;
}

#include <set>
#include <bitset>
#include <queue>
#include <deque>
#include <set>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <cassert>

#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

using namespace std;

int main()
{
	int n,k,b=0;
	int a[50];
	do{
	cin >> n >> k;
	}while( k > n );
	for ( int i = 0 ; i < n ; i ++ )
	{
		cin >> a[i];
	}

	for ( int i = 0 ; i < n ; i ++ )
	{
		if ( a[i] < k && a[i] >= 1)
		b = n;
		if (k == 1 )
		{
		if (a[i] >= 1)
		b++;
		}
		else
		if ( a[i] >= k + 1)
		b++;
	}
	cout << b;
}

#include<iostream>
using namespace std;
int main()
{
int a,b,n,t,y,h=0;
cin>>n>>t;
int arr [n+1];
for (int i=1;i<=n;i++)
     {cin>> arr[i];
     }
if (arr[1]==0)
    {cout<< arr[1];
    return 0;
    }

a= arr [t];
if (a==0){

for (int j=1;j<n;j++)
    {if (arr[j]<=a)
      h=h+1;
     }
         }
  else
    {for (int r=1;r<=n;r++)
    {if (arr[r]<=a)
      h=h+1;
     }
         }

cout<<h;
return 0;
}

#include <iostream>
using namespace std ;
int main ()
{
int k , n ,s, sum ;
cin >>n>>k ;
for ( int i=1 ; i<= n ; i++ )
{
cin >> s;
if ( s>k )
sum +=1 ;
}
return 0 ;
}

#include <iostream>
#include <string>
using namespace std;

int main()
{
	int sum = 0, n, k;
	cin >> n >> k;
 	int x[100] = { 0 };

		for (int i = 0; i < n; i++)
		{
			cin >> x[i];
		}
		if (x[k - 1] != 0) {
			for (int i = 0; i < n; i++)
			{
				if (x[i] >= x[k - 1])
					sum++;
			}
		}
	cout << sum;
	return 0;
}

 #include <iostream>
using namespace std;
main()
{ int j,p,i,n,k;
int T[n];
cin>> n >>k;
for (i=0;i<n;i++)
cin >> T[i] ;
p=0;
for (i=0;i<k;i++)
if (T[i]>0) {p=p+1;}

j=k;
while ((T[k-1]!=0)&&(T[k-1]==T[j]))
{p=p+1;
j=j+1;}
cout<<j;}

#include<iostream>
using namespace std;
int main(void)
{
int n,k;
cin>>n;
cin>>k;
int a[100];
for (int i = 1; i <= n; i++) {
    cin>>a[i];
}
if (a[k]==0) cout<<"0";
else{
    int i=k+1;
    while (a[i]==a[k]) i++;
    cout<<(i-1);
}
}

#include <iostream>
using namespace std;

int main()
{
	unsigned int n = 0, k = 0, a[51], ct = 0;
	cin >> n >> k;
	if (n >= k)
	{
		for (int i = 1; i <= n; i++)
		{
			cin >> a[i];
			if (a[i] > k) ct++;
		}
	}
	cout << ct;
	//system("pause>nul);
	return 0;
}

#include <iostream>

using namespace std;

int main()
{

	int n = 0, k = 0, i = 0,otvet=0;
	cin >> n;
	cin >> k;
	int* a = new int[n];
	for (i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	if (a[0] > a[n])
	{
		otvet = k;
	}
	if (a[k-1] == a[k] && a[0]!=a[1])
		{
			otvet = k+1;
		}
    if (a[0] == 0)
	{
		otvet = 0;

	}
	if ((a[0] != 0) && (otvet!=k+1)) {
		for (i = 0; i < n; i++)
		{
			if (a[i] == a[i + 1])
			{
				otvet=n;
			}

		}

	}
	cout << otvet;

    return 0;
}

#include <iostream>
#include <string>
using namespace std;

int main()
{
	int a, b , counter;
	int c[51];
	cin >> a;
	cin >> b;

	counter = b;

	for (int i = 1; i <= a; i++)
	{
		cin >> c[i];
	}

	for (int i = b+1; i <= a; i++)
	{
		if (c[i] >= c[b] && c[i]>0)
			counter++;
	}

	cout << counter;

	return 0;
}

#include <cstring>
#include <iostream>
using namespace std;

int main(int argc, char** argv) {
	int b,c,t=0,sayac=0,e,f;
	cin>>b;
	string a[b];
	cin>>c;
	for(int i=0;i<b;i++) cin>>a[i];
	for(int i=1;i<b+1;i++)
	{
		if(a[i-1]>a[i]&&a[i]>"0")
		{
			t++;
			sayac++;

		}
		else if(a[i-1]==a[i]&&a[i]>"0"){

				t++;
				sayac++;
			}

		if (t>=c) break;

	}
	cout<<sayac;

}

#include <bits/stdc++.h>
using namespace std;
int n,k,ans=0;

main()
{
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for (int i=0;i<n;i++)
    {

        if (a[i]==k && ans ==0)
            ans++;
        else if (a[i]>k)
            ans++;

    }
    cout <<ans<<endl;
}

#include <iostream>
using namespace std;
int n, k,cnt;
int main() {

	cin >> n >> k;
	int* A = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> A[i];

	}
	for (int i = 0; i < n; i++) {
		if (A[i] > A[k]) {
			cnt++;
		}
	}

	cout << cnt;
}

#include <iostream>
#include <string>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a;
  int k;
  cin>>k;
  int cnt=0;
  for(int i=0;i<n;i++)
  {
      cin>>a;
      if(a>k)
      {
          cnt++;
      }
  }
   cout<<cnt;

}

#include <iostream>

using namespace std;

int main()
{
    int n,k,z[100],num=0;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>z[i];
    }
    for(int a=0;a<n;a++)
    {
         if(z[a]>k)
            if(z[a]>=z[a-1])
                num++;
         else
            num++;
    }
    cout<<num<<endl;
    return 0;
}

#include<bits/stdc++.h>

int main(){
    int n, k;
    int answer=0;
    std::cin >> n >> k;
    int min = INT_MAX, prise = 0;
    for(int i=0; i<n; i++){
        int x;
        std::cin >> x;
        if(min > x){
            min = x;
            prise++;
        }
        if(prise >= k){
            answer++;
        }
    }

    std::cout << answer;
}

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long int n;
    long int k;
	cin>>n;

	long int c=0;
	cin>>k;
	long int a[n];
		for(int g=1;g<=n;g++)
		{
			cin>>a[g];
			if(a[g]<1)
		{
		c=0;
		}
		else if(a[g]>=a[k])
		{
			c++;
		}

		}
		cout<<c;
		return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int n,k,c = 0,ls;
    cin >> n >> k;
    cin >> ls;
    while(ls > 0 && k > 0)
    {
        c++;
        k--;
        cin >> ls;
    }
    if(k==0)
    {
        int ks = ls;
        cin >> ls;
        while(ls == ks)
        {
            c++;
            cin >> ls;
        }
    }
    cout << c;
}

#include <iostream>
using namespace std;

int main()
{

int n=0,k=0,count=0,temp=0;
cin>>n>>k;
int *mas = new int[n];

for(int i=0;i<=n;i++)
{
cin>>mas[i];
}

temp=mas[k-1];
for(int i=n-1;i>=0;i--)
{
//cout<<(int)mas[i]<<" ";

if(mas[i]==temp )
{
count=i;
break;

}
}

if(k>n)
{
count<<0;
return 0;
}

if(mas[k]>=mas[0])
cout<<0;
else
cout<<count+1;

	return 0;
}

#include <iostream>
#include <string>
using namespace std;
int main()
{
    int a,b,counter=0;
    cin >>a>>b;
    int c[a];
    for (int i=0;i<a;i++)
    {
        cin>>c[i];
        if (c[i]>=(b-1))
        {
            counter++;

        }
    }
    cout <<counter<<endl;

    return 0;
}

#include<iostream>
using namespace std;
void main()
{
	int n, k,total;
	total = 0;
	cin >> n;
	cin >> k;
	for (int i = 0; i < n; i++)
	{
		int number=0;
		cin >> number;
		if (number>k)
			total++;

	}
	cout << total;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n=0,k,i,m=0,u;
    scanf("%d%d",&n,&k);
    int a[n];
    for(i=0;i<n;i++)
    {
      scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        if(a[i]<=k)
        {
          m++;
        }
    }
    u=n-m;
    printf("%d",u);
    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <set>
#include <fstream>
#include <iomanip>
#include <exception>
#include <tuple>

using namespace std;

int main(void)
{
	int n = 0, k = 0, a = 0, j = 0, prev = 0;
	bool flag = true;
	cin >> n >> k;
	for(int i = 0; i < k; i++)
	{
		flag = false;
		cin >> a;
		if(a == 0 && flag == true)
		{
			cout << 0;
			return 0;
		}
	}
	prev = a;
	while(cin >> a)
	{
		if(a == prev)
		{
			j++;
		}
		else break;
	}
	cout << k + j;
	return 0;
}

#include <iostream>

int main()
{
	int n = 0, k = 0;
	while(n < k)
	{
    	while (n < 1 || n > 50 )
    	{
    		std::cin >> n;
    	}

    	while (k < 1 || k > 50)
    	{
    		std::cin >> k;
    	}
	}
	while (n < 1 || n > 50 || n < k)
	{
		std::cin >> n;
	}

	int vectorValori[50];
	for (int i = 0; i < n; ++i)
	{
		std::cin >> vectorValori[i];
	}

	int nr = k;
	while (vectorValori[nr - 1] == vectorValori[k - 1])
	{
		nr++;
	}
	std::cout << nr;

	return 0;
}

#include <iostream>
#include <string>
using namespace std;

int main()
{
    int a, b , counter;
    int c[51];
    cin >> a;
    cin >> b;

    counter = b;

    for (int i = 1; i <= a; i++)
    {
        cin >> c[i];
    }

    if (c[b] <= 0)
    {
      cout << 0;
     return 0;
    }

    for (int i = b+1; i <= a; i++)
    {
        if (c[i] >= c[b])
            counter++;
    }

    cout << counter;

    return 0;
}

#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int k,n,arr[101],r=0;
	cin>>n;
	cin>>k;

	if(1<=k&&k<=n&&n<=50)
	{
		for(int i=1;i<=n;i++)
		{
			cin>>arr[i];
		  sort(arr, arr+n, greater<int>());

		}
		 int p=arr[k];
		for(int i=1;i<=n;i++)
		{
			if(arr[i]>0&&arr[i]>=p)
			{
				r=r+1;
			}
		}

	}
	cout<<r;
}

#include <iostream>
#include <string>
using namespace std;

int main()
{
  int a, b, s, t;
  cin>>a>>b;
  t=0;
  for (int i=1;i<=a;i++){
      cin>>s;
      if(s>b){
          t++;
      }
  }
cout<<t;
}

#include <iostream>
#include<string>
using namespace std;
int main()
{
int x,y,z=0;
cin>>x>>y;
   int arr[x];
   z=y;
   for(int i=0; i<y; i++)
       {
        cin>>arr[i];
          if (arr[i]==0)
          z--;
          }
      if(arr[0]<1)
      cout<<"0";
      else
      {

      for(int i=y; i<x; i++)
          {
          if(arr[i]==0)
          break;
          if (arr[i]==arr[4])
              z++;
              }
        cout<<z;
        }
}

#include <bits/stdc++.h>
using namespace std;
int n,f[1001],k,i,b[110],ans,Max;
int main()
{
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&f[i]);
		if(f[i]>0 && k>0)
		{
			ans++;
			k--;
			Max=i;
		}
		else if(f[i]==f[Max])
		ans++;
	}
	cout<<ans;
	return 0;
}

#include<iostream>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int res=n;
	int a[n];
	if(a[k]>0)
		for(int i=k+1;i<n;i++)
			{
				if(a[i]>=a[k])
					res++;
				else break;
			}
	else
		for(int i=k-1;i>0;i--)
			{
				if(a[i]>0)
				break;
				else
				res--;
			}
			cout<<res;
	return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include "queue"
#include <deque>
#include <stack>
#include <numeric>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <cassert>
using namespace std;
int main()
{
	int n , k , x , c = 0;
	cin>> n;
	cin>> k;
	if(k>=1 && k<=50)
	{
		if(n>=k && n<=50)
		{
		for(int i=0;i<n;i++)
		{
			cin>>x;
			if(x==0)
			{
				break;
		     }
			c++;
		}
		}
	}
	cout<<c<<endl;
return 0;
}

#include<iostream>
using namespace std;
int main()
{
	int n,k;
	cin>> n >> k;
	int b,c=k,d=0,i=0;
	for(i=0;i<n;i++)
	{
	 cin>>b;
	 if(b==0)
	 {
	 cout<<i;
	 break;
	 }
     }
     int a;
	for(i=k;i<n;i++)
	{
	cin>> a;
	if(a!=b)
	{
	    cout<<i;
	}
}

}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int cutoff=a[k];
    cout<<cutoff;
    int pass=0;
    if(cutoff==0)
        cout<<0;
    else
    {
    for(int i=0;i<n;i++)
    {
        if(a[i]>=cutoff)
        {
            pass++;
        }

    }
     cout<<pass;
    }
}

#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()

 {
     int n,b,c,cnt=0;
     cin>>n>>b;
     int a[n];
     for(int i=1; i<=n; i++){
        cin>>i;
    }
    c=a[b];
    for(int j=1; j<c; j++ ){
        cnt++;
    }
    if(c==b){
        cout<<n;
    }
    else if(n==b){
        cout<<b;
    }
    else
       cout<<cnt;
 }

#include <iostream>

using namespace std;

int main()
{
    int x,y,b=0,i;
    cin>>x>>y;
    int c[50];
       for(i=0;i<x;i++)
       {
         cin>>c[i];
       }
       for(i=0 ;i<x;i++)
         {
          if(i>=y-1)
            if(c[i]<c[y])
            continue;
          if(c[i]>=c[y])
            b++;
         }
       cout<<b;
    return 0;
}

#include <iostream>
using namespace std;
int n,k,i,j,a[2];
main()
{
	cin>>n>>k;
    while(n>i) cin>>a[i++];

    while(a[j] && a[j]>=a[k-1]) ++j;
    cout<<j;
}

#include <iostream>
#include <vector>
#include <string>

using namespace std;
bool check(int n, int k);

int main()
{
    int k,n,l=0;
    cin>>n;
    cin>>k;
    int a[n];
    if(check(n,k)){
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        for(int i=0;i<n;i++){
            if(a[i]>=a[i+1]){
                if(a[i]>=a[k-1]){
                l++;
            }
            if(a[i]<1 && a[k-1]<1 ){
                l=0;
            }
            }
        }
        cout<< "\n\n\n"<<l;
    }
    else{
        cout<< "The given value is invalid!";
    }

    return 0;
}

bool check(int n, int k){
    if(k>=1 && k<=50 && n>=1 && n<=50 && n>=k){
        return 1;
    }else{
    return 0;
    }
}

#include<iostream>
#include<vector>

using namespace std;
int main()
{int n,k;
vector<int>a(51);
int h[101]={0};
int s=0,y=0;
cin>>n>>k;
for(int i=1;i<=n;i++)
    {cin>>a[i];
    h[a[i]]++;
    y=y+a[i]; // 3 2 0 0
        }
        if(y==0)
            cout<<"0";
        else
{
    const int c=k;
int x=a[c];
  for(int i=x;i<=a[0];i++)
   {
        s+=h[i];    // 8 7 5 3
   }
  cout<<s;

}

 return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    int i,k=0,n,m;
    cin >> n;
    int a[n];
    cin >> m;
    for(i=0;i<n;i++)
    {
        cin >> a[i];
    }
    for(i=m;a[i]>=a[m];i++)
    {
    if(a[m]==0) {k=0; break;}
    if(a[m]!=0) k=m;
    if(a[i]>=a[i+1]) k++;
    }
    cout << k;
    return 0;
}

        #include<iostream>
        using namespace std;

        int main()
        {
            long n,k,i=0;
            cin>>n>>k;
            long a[n];
            for(i=0;i<n;i++)
            cin>>a[i];
            if(a[0]<=0)
            cout<<"0";
            else
            {
                if(n>k){
                if(a[k]!=a[k-1])
                {
                    int l=k;
                    int u=2,r=0;
                    if(a[k-1]<=0)
                    {
                        while(l--)
                        {
                        if(a[k-u]==a[k-1])
                        r++;
                        u++;
                        }
                    cout<<k-r;
                    }
                    else
                    cout<<k;
                }
                else
                {
                    int i=n-k;
                    int j=0,m=0;
                    while(i--)
                    {
                        if(a[k+j]==a[k-1])
                        m++;
                        j++;
                    }
                    cout<<k+m;
                }}
                else
                {
                    int l=k;
                    int u=2,r=0;
                    if(a[k-1]<=0)
                    {
                        while(l--)
                        {
                        if(a[k-u]==a[k-1])
                        r++;
                        u++;
                        if(a[k-u]!=a[k-1])
                        break;
                        }
                    cout<<k-r;
                    }
                    else
                    cout<<k;
                }
            }
        }

#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n,m,arr[50],sum=0;
    cin>>n>>m;
    for (int x=0; x<n; x++)
    {
        cin>>arr[x];
    }
    if (arr[m-1]!=0)
    {
    sum=m;
    for (int x=m; x<n; x++)
    {

        if (arr[x]==arr[m-1])
            sum++;
        else
            break;
    }
    }
    cout<<sum<<endl;
    return 0;
}

#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
	int n, k, result;
	result = 0;
	cin >> n >> k;
	int *a = new int[n];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		if ((a[i] >= a[k-1]) && (a[i]>=0)&& (a[k]>=0) && (n >= k) && (a[i]>=a[i+1])&&(n,k>=1)&&(n,k<=50)) {
			result++;
		}
	}
	cout << result;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    long long ans=0;
    cin>>n>>k;
    int a[1005];
for(int i=0;i<n;i++)
{
    cin>>a[i];
}
for(int i=0;i<n;i++)
{
    if(a[i] >= a[k+1] && a[i]!=0)
        ans++;
        }
cout<<ans;
}