#include <stdio.h>

#define  swap (a,b)
{
  int temp;

if(a>b)
{
temp = b;
b = a;
a = temp;
}
}

int main (void)
{
int N,x;
int a[x];
int i;

scanf("%d%d",&N,&x);

for(i=0;i<N;i++)
scanf("%d",&a[i]);

for(i=0;i<N-1;i++)
swap(a[i],a[i+1];

Nx = N;
int count = 0;

do
{
if(Nx>a[i])
{
Nx -= a[i];
count ++;
}
else break;
}

printf("%d",count);

return 0;
}