Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems to get to the olympiad like Vladik, but she was confused by the task proposed on the olympiad.Let's consider the following algorithm of generating a sequence of integers. Initially we have a sequence consisting of a single element equal to 1. Then we perform (n - 1) steps. On each step we take the sequence we've got on the previous step, append it to the end of itself and insert in the middle the minimum positive integer we haven't used before. For example, we get the sequence [1, 2, 1] after the first step, the sequence [1, 2, 1, 3, 1, 2, 1] after the second step.The task is to find the value of the element with index k (the elements are numbered from 1) in the obtained sequence, i. e. after (n - 1) steps.Please help Chloe to solve the problem!

The only line contains two integers n and k (1 ≤ n ≤ 50, 1 ≤ k ≤ 2n - 1).

Print single integer — the integer at the k-th position in the obtained sequence.

NoteIn the first sample the obtained sequence is [1, 2, 1, 3, 1, 2, 1]. The number on the second position is 2.In the second sample the obtained sequence is [1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1]. The number on the eighth position is 4.

#include <stdio.h>

#define ll long long
#define s(a) scanf("%lld", &a);
#define sd(a) ll a; s(a);
#define rep(i, a, n) for(i = a; i < n; i++)
#define pin(a) printf("%lld\n", a);

int main(){
	sd(n); sd(k); ll i, ans = 1;
	rep(i, 1, n){
		ans = 2 * ans + 1;
	}
	ll in = 1, fin = ans;
	while(1){
		ll mid = (fin + in) / 2;
		if (mid == k){ pin(n); break; }
		n--;
		if (k < mid) fin = mid - 1;
		else if (k > mid) in = mid + 1;
	}
	return 0;
}

#include <stdio.h>
#include <math.h>

long long pot (long long a, long long b){
	long long x = 1;

	for (long i = 0; i < b; i++){
		x = x*a;

	}

	return x;
}

int main (){

	long long n;long long a;

	scanf ("%lld", &n);
	scanf ("%lld", &a);

	long long k ;
	long long l ;
	long long x = 1;

	for (long i = n; i >= 2; i--){
		k = a - pot(2, i-1);
		l = pot (2, i);

		if (k % l == 0){
			x = i;
			break;
			}

	}

	printf("%lld\n",x );

	return 0;
}

#include<stdio.h>
#include<stdlib.h>
long long int solve(long long int l,long long int r,long long int k,long long int n)
{
	long long int m=l+(r-l)/2;
	if(k<m)
	{
		solve(l,m-1,k,n-1);
	}
	else if(k>m)
	{
		solve(m+1,r,k,n-1);
	}
	else
	 return n;
}
main()
{
	long long int n,k,i,size=1;
	scanf("%I64d %I64d",&n,&k);
	for(i=1;i<n;++i)
	{
		size=size*2+1;
	}
printf("%I64d",solve(1,size,k,n));
}

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX 1000
unsigned long long s[MAX];

int main(){
    unsigned long long  int a, b;
    for(int i = 0; i <= 50; i++){
        s[i] = pow(2, i);
    }
    while(scanf("%llu%llu", &a, &b) != EOF){
        for(int i = 1; i <= 50; i++){
            if(b == s[i]) {
                printf("%d\n", i + 1);
                break;
            }
            else if(b % s[i] == s[i - 1]) {
                printf("%d\n", i);
                break;
            }
        }
    }
    return 0;
}

#include <stdio.h>
int main(){
	int n;
	long long res=1,k;
	double res1=1;
	scanf("%d%lld",&n,&k);
	for(int i=0;i<n-1;i++){
		res=res*2+1;
	}
	long long i=1,j=res;
	while(i<j){
		long long mid=(i+j)/2;
		if(mid==k) break;
		if(mid<k){
			i=mid+1;
		}else{
			j=mid-1;
		}
		n--;
	}
	printf("%d\n",n);

}

#include<stdio.h>
#include<math.h>

int main()
{
	unsigned long long x = 0;
	unsigned long long i = 0;
	unsigned long long int n = 0;
	unsigned long long int ind = 0;
	unsigned long long int ans = 0;
//	printf("%u",sizeof(n));
	scanf("%llu %llu", &n, &ind);

	for (i = n; i >= 0; i--) {
		x =(unsigned long long) pow(2,i);
		if ( ind % x == 0LL)
		{
			ans = i+1;
			break;
		}
	}

	printf("%llu\n",ans);
	return 0;
}

#include<stdio.h>
int main(){
	long n;
	long long k;
	int i;
	scanf("%ld %lld",&n,&k);
	for(i=1;i<=n;i++){
		if(k%2==1){
			printf("%d\n",i);
			break;
		}
		else
			k=k/2;
	}
	return 0;
}

#include<stdio.h>
int main(void)
{
    int n,m,v;
    long long k;
    while(scanf("%d",&n)!=EOF)
    {
        m=1;
        v=0;
        scanf("%I64d",&k);
        do
        {
        if(k%2)
        {printf("%d\n",m);v=1;}
        else
        {k=k/2;m=m+1;}
        }
        while(v==0);
    }
    return 0;
}

//#include<stdio.h>
//#include<math.h>
//int main()
//{
//  double k;
//  int n;
//  scanf("%d %lf",&n,&k);
//  double int_ceil,int_floor;
//  int_ceil=ceil(log(k)/log(2));
//
//  int_floor=floor(log(k)/log(2));
//  printf("%lf %lf %lf\n",int_ceil,int_floor,k);
//  while(int_ceil>log(3)&&((int_ceil-int_floor)>0.000000001))
//{
//k-=pow(2,int_floor);
//int_ceil=ceil(log(k)/log(2));
//int_floor=floor(log(k)/log(2));
//printf("%lf %lf %lf\n",int_ceil,int_floor,k);
//}
//  if((int_ceil-int_floor)<0.00000001)
//printf("%lf",pow(2,int_floor-1));
//  else
//printf("1");
//
//}

//#include<stdio.h>
//#include<math.h>
//int main()
//{
//  double int_ceil,int_floor;
//  double k;
//  int n;
//  scanf("%d %lf",&n,&k);
//  int_ceil=ceil(log(k)/log(2));
//  int_floor=floor(log(k)/log(2));
//  if((int)k%2==1)
//{
//printf("1\n");
//return 0;
//}
//  if(log(k)/log(2)==int_ceil)
//{
//printf("%d\n",(int)log(k)/log(2)+1);
//return 0;
//}
//  while(int_floor>1)
//{
//k-=pow(2,int_floor);
//int_ceil=ceil(log(k)/log(2));
//int_floor=floor(log(k)/log(2));
//if(log(k)/log(2)==int_ceil)
//{
//printf("%d\n",(int)log(k)/log(2)+1);
//return 0;
//}
//}
//
//
//}
#include<stdio.h>
#include<math.h>
int main()
{
  long long k;
  long long n;
  long long i=1;
  scanf("%lld %lld",&n,&k);
  while(1)
    {
      if(k%2==1)
        {
          printf("%lld\n",i);
          return 0;
        }
      else
        {
          i++;
          k=k/2;
        }
    }
}

#include <stdio.h>

int main() {
	int n,count=0;
	long long int k;
	scanf("%d %lld",&n,&k);
	while(k%2==0){
		k=  k/2;
		count ++;
	}
	printf("%d\n",(1+count) );

	return 0;
}

#include<stdio.h>
#include<math.h>
main()
{
	int n,i;
    long long int m,r,k;
	scanf("%d%I64d",&n,&k);
	for(i=1;i<=n;i++)
	{
		m=k+pow(2,i-1);
		r=pow(2,i);
	if(m%r==0)
	{
		printf("%d",i);
		return 0;
	}

}
}

#include <stdio.h>
int main()
{
	long long int n,a,p;
	scanf("%lld %lld",&n,&p);
	for(n=0,a=1;(a&p)==0;n++,a<<=1);
	printf("%lld\n",n+1);
}

#include <stdio.h>

int n;
long long k;

int main() {
  scanf("%d %I64d", &n, &k);
  int ans = 1;
  while (k%2==0 && ++ans)
    k = k >> 1;
  printf("%d\n", ans);
}

#include<stdio.h>
int main()
{
    unsigned long long int n,k;
    while(scanf("%llu %llu",&n,&k)==2)
    {
        long long loop=1,m=1,left,right,mid,key,position;
        while(loop<n)
        {
            m=(m<<1)+1;
            ++loop;
        }
        if(k%2)printf("1\n");
        else
        {
            left=1;
            right=m;
            key=n;
            while(left<=right)
            {
                mid=(left+right)>>1;
                if(k<mid)right=mid-1;
                else if(k>mid)left=mid+1;
                else
                {
                    printf("%llu\n",key);
                    break;
                }
                --key;
            }
        }
    }
    return 0;
}

#include<stdio.h>
int main()
{
    long long int n,k,f=1;
    scanf("%lld%lld",&n,&k);
    while(1)
    {
        if (k%2==0)
        {
            f++;
            k/=2;
        }
        else
        {
            printf("%lld",f);
            break;

        }
    }
    return 0;
}

#include <stdio.h>
#include <math.h>
int main()
{
	int i,n;
	long long int k,ans;
	scanf("%d %lld",&n,&k);
	for(i=1;i<=n;i++)
	{
		ans=(long long int)pow(2,i);
		if(k%ans){
			printf("%d\n",i);
			break;
		}
	}
	return 0;
}

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

int main()
{
    long long a,b;
    scanf("%I64d%I64d",&a,&b);
    long long result=1;
    long long x=1;
    for(long long i=1;i<a;i++){
        x=x*2;
    }
    while(b!=x){
        if(b>(x)){
            b=b-x;
            if(b==0){

            }
        }
        x=(x-1)/2+1;
    }
    long long i=1;
    while(result!=x){
        result*=2;
        i++;
    }
    printf("%I64d\n",i);
    return 0;
}

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

#define M 1000000007

int main()
{
    long long int n,k,j;
    scanf("%lld %lld",&n,&k);
    j=0;
    if(k > pow(2,n-1))
    {
        k = k-pow(2,n-1);
    }
    while(k%2 == 0)
    {
        k=k/2;
        j++;
    }
    printf("%lld\n",j+1);
    return 0;
}

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

int main()
{
    int n;
    long long int k,l,i;
    scanf("%d %lli",&n,&k);
    for(i=1;i<n;i++)
    {
        double ans=(double)k-(pow(2,i-1));
        ans=ans/(pow(2,i));
        long long int int_ans=(long long int)ans;
        if(ans==int_ans)
            {
              break;
            }

    }
    printf("%lli",i);

}

#include <stdio.h>

int main() {
  long long n, k;
  scanf("%I64d %I64d", &n, &k);
  long long now = 1;
  long long ret = 1;
  while (1) {
    long long tmp = k - now;
    if (tmp % (now * 2LL) == 0) {
      printf("%I64d\n", ret);
      return 0;
    }
    now *= 2LL;
    ret += 1;
  }
  return 0;
}

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

int main() {
    int num1;
    scanf("%d ",&num1);
    long long k;

    scanf("%lld",&k);
  //  printf("%lld\n",k);
    int count=1;
    while(k>0){
        if(k%2==1){
            break;
        }
        count++;
     //   printf("%d\n",count);
        k=k/2;
    }
    printf("%d\n",count);
}

#include<stdio.h>
int main(){
    long long int n,k,m=1,i;
    scanf("%llu %llu",&n,&k);
    for(i=0;i<n;i++)
    {
        m=m*2;
        if(k%m!=0)
        {
            printf("%llu",i+1);
            break;
        }
    }

}

#include<stdio.h>
#include<math.h>
int main()
{
	long long int n,k,i,j;
	long long int ans=0,end;

	scanf("%lld%lld",&n,&k);
	for (i=1; i<=50; i++)
	{
		if (k%2 ==0)
		{
			k = k/2;
		}
		else
			break;
	}
	printf("%lld",i);
	return 0;
}

#include<stdio.h>
int main()
{
 unsigned long long int m,l=1,h=1,k,n,i;
 scanf("%llu %llu",&n,&k);
 for(i=0;i<n;i++)
        h=h*2;
 while(1)
 {
     m=(l+h)/2;
     if(m==k)
        break;
     else if(m<k)
        l=m;
     else
        h=m;
     n--;
 }
 printf("%llu",n);
return 0;

}

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

int main()
{ int n = 0;
  long long k = 0;

  scanf("%d %I64d", &n, &k);
  if (k%2 !=0)
  {
      printf( "1");
  }
 else
 {
     long long a = pow(2,n);
     int z = n;
     long long a1 = a/4;
     long long a2 = 0;
   while (a!=k)
   { if (a>k)
     {
         a1 = a;
        a = a/2;

        if(a==k)
       {
           printf("%d",z);
       }
       else
       {
           z--;

       }
     }
       else
       {
          k=a1-k;
       }

   }
   }

return 0;
 }

#include <stdio.h>
typedef long long int ll;

int main()
{
	ll n, k, ans = 1;

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

	while(k % 2 == 0)
	{
		k /= 2;
		ans++;
	}
	printf("%lld\n", ans);

	return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	long long int n,k,c,count=0,count1=0,lb,num;
	scanf("%lld%lld",&n,&k);
	c=k;
	if(k%2==1)
		printf("1\n");
	else
	{
		while(c!=1)
		{
			c=c/2;
			count++;
		}
		lb=count+1;

		num=k-pow(2,count);

		if(num==0)
			printf("%lld\n",lb);
		else
		{
			while(num%2!=1)
			{
				num=num/2;
				count1++;
			}
			printf("%lld\n",(count1+1));
		}
	}
	return 0;
}

#include <stdio.h>
int main(){
	int n;
	long long res=1,k;
	double res1=1;
	scanf("%d%lld",&n,&k);
	for(int i=0;i<n-1;i++){
		res=res*2+1;
	}
	long long i=1,j=res;
	while(i<j){
		long long mid=(i+j)/2;
		if(mid==k) break;
		if(mid<k){
			i=mid+1;
		}else{
			j=mid-1;
		}
		n--;
	}
	printf("%d\n",n);

}

#include <stdio.h>
#include <math.h>

int main(void)
{
	int n;
	long long k;

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

	long long low  = 1;
	long long high = ((long long) pow(2, n)) - 1;

	int step = n;
	while(low <= high)
	{
		long long mid = (low + high)/2;
		if(mid == k)
		{
			printf("%d", step);
			return 0;
		}
		else if(mid > k)
		{
			high = mid - 1;
		}
		else
		{
			low = mid + 1;
		}
		step--;
	}

	return 0;
}

#include <stdio.h>

int n;
long long k;

int main() {
  scanf("%d %I64d", &n, &k);
  int ans = 1;
  while (k%2==0 && ++ans)
    k = k >> 1;
  printf("%d\n", ans);
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
	long long int n,k;
	scanf("%lld%lld",&n,&k);
	if((k%2)==1) printf("1");
	else
	{
		int c=0;
		while((k>0)&&((k%2)==0))
		{
			 c++;
			k/=2;
		}
		printf("%d",c+1);
	}

	return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    long long n,k,sum;
    while(scanf("%lld%lld",&n,&k)!=EOF)
    {
        while(n>0)
        {
            sum=pow(2,n-1);
            if(sum==k)
            {
                printf("%lld\n",n);
                break;
            }
            else
            {
                n-=1;
                if(k>sum)k%=sum;
            }
        }
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int s[1100010];
int main()
{
    long long int a,b;
    int n;
    int i,j,k,m;
    while(~scanf("%lld%lld",&a,&b))
    {

        a=a-1;
        s[0]=1;
        long long int t=b;
        int flag=1;
        i=0;
        j=0;
        s[1]=2;
        s[2]=1;
        for(i=0;i<50;i++)
            if((long long int)pow(2,i)<=b&&b<(long long int)pow(2,i+1))
                break;
            //printf("%d\n",i);
        while(t%((long long int)pow(2,i))!=0)
        {
            t -= (long long int)pow(2,i);
            for(;i>=0;i--)
            if((long long int)pow(2,i)<=t&&t<(long long int)pow(2,i+1))
                break;
            //printf("%d\n",t);
        }
        //printf("hello\n");
        printf("%d\n",i+1);
    }
    return 0;
}

#include<stdio.h>

int main(){
  int n; long long k; scanf("%d %lld", &n, &k);
  if(k % 2){ printf("1\n"); return 0; }
  int c = 1;
  while(k && k % 2 == 0){ c++;  k/= 2; }
  printf("%d\n", c);
  return 0;
}

#include <stdio.h>
#include <math.h>

#define ll long long

ll recur(int n, ll k);

int main(void)
{
    int n;
    ll k;

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

    printf("%I64d\n", recur(n, k));

    return 0;
}

ll recur(int n, ll k)
{
    ll temp = pow(2, (double)n - 1);
    if (k == temp)
        return n;
    else if (k > temp)
    {
        k -= temp;
    }
    return recur(n - 1, k);
}

#include<stdio.h>
int main()
{
	int n,i=0,c=0;
	char s[60];
	long long int j=0;
	scanf("%d",&n);
	scanf("%s",s);
	while(s[i]!='\0')
		j=j*10+(int)(s[i++])-48;
	while(j>0)
	{
		if(j%2==0)
		c++;
		else
			break;
		j>>=1;
	}
	printf("%d\n",c+1);
	return 0;
}

#include <stdio.h>

int find(int n, long long k, long long size) {
	if (k == (size + 1) / 2)
		return n;
	if (k > (size + 1) / 2)
		k -= (size + 1) / 2;
	return find(n - 1, k, size / 2);
}

int main() {
	long long k, size;
	int n;

	scanf("%d%lld", &n, &k);
	size = (1LL << n) - 1;
	printf("%d\n", find(n, k, size));
	return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	long long int n,k;
	scanf("%lld%lld",&n,&k);
	if(k%2!=0){
		printf("1\n");
		return 0;
	}
	long long c,l,i;
	for(i=1;i<=n;i++)
	{
		c=k+pow(2,i-1);
		l=pow(2,i);
		if(c%l==0)
		{
			printf("%lld",i);
			return 0;
		}
	}

	return 0;
}

#include<stdio.h>
int main()
{
    long long int n,i,j,k,cnt=1;
    scanf("%lld %lld",&n,&k);
    while(1){
        if(k%2==0){
            cnt++;
            k=k/2;
        }
        else{
            printf("%d",cnt);
            return 0;
        }
    }
}

#include <stdio.h>

int main(void) {
	long long int n, k, twos = 0;
	scanf("%I64d %I64d", &n, &k);
	while ((k % 2) == 0) {
		k /= 2;
		twos++;
	}
	printf("%I64d", twos + 1);
	return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    unsigned long long n,k,m,s;
    scanf("%llu%llu",&n,&k);

    m=pow(2,n-1);

    if(k%2!=0) printf("1");
    else
    {
        s=m/2;
        while (m!=k)
        {
            if (k>m)
                m=m+s;
            else m=m-s;
            n--; s=s/2;
        }
        printf("%llu",n);
    }

    return 0;
}

#include<stdio.h>
#include<math.h>

int main()
{
    long long int n,m,number;
    scanf("%I64d%I64d",&m,&n);
    if(n%2==1)
    {
        printf("1\n");
        return 0;
    }
    while(n!=0)
    {
        long long int res;
        double ans;
        ans = log10(n)/log10(2);
        number=ans;
        res=pow(2,number);
        long long int dif=n-res;
        n=dif;
    }
    printf("%I64d",number+1);
    return 0;
}

#include<stdio.h>
main()
{
	long long int n,i,j,k,c=1;
	scanf("%I64d%I64d",&n,&k);
	while(1)
	{
		if(k%2==0)
		{
			c++;
			k=k/2;
		}
		else
		{
			printf("%I64d",c);return 0;
		}
	}
}

#include<stdio.h>
#include<math.h>
int f(int n, long long k)
{
  long long x = (long long)(pow(2.0, (double)(n-1)));
  if(k==x)
    return n;
  else if(k<x)
    return f(n-1, k);
  else
    return f(n-1, k-x);
}

int main(void)
{
  int n;
  long long k;
  scanf("%d %lld", &n, &k);
  printf("%d\n", f(n, k));
  return 0;
}

#include<stdio.h>
int main()
{
	long long n,k=0;
	scanf("%lld%lld",&n,&n);
	while((n>>k&1)==0)
		k++;
	printf("%d\n",k+1);
	return 0;
}

#include <stdio.h>
#include <math.h>
long long int Binary(long long int start,long long int end,long long int x,long long int n){
    if (start==end){
        return 1;
    }
    long long int mid = (start+end)/2;
    // printf("%lld\n",mid);
    if (mid==x){
        // printf("%lld\n",n);
        return n;
    }
    if (mid>x){
        return Binary(start,mid-1,x,n-1);
    }
    else{
        return Binary(mid+1,end,x,n-1);
    }
}
int main(){
    long long int n,k;
    scanf("%lld %lld",&n,&k);
    long long int end = pow(2,n)-2;
    // long long int s = end/2;
    // printf("%lld\n",s);
    long long int ans=Binary(0,end,k-1,n);
    printf("%lld\n",ans);
    return 0;
}

#include<stdio.h>
int main(){
int n,c=0;long long int k,i;
scanf("%d%I64d",&n,&k);
for(i=1;i<=k;i*=2)
  { if(k%i==0)
     { c++;continue;}
    else
        break;
  }
printf("%d",c);
return 0;
}

#include <stdio.h>
int main ()
{
    long long n, t, ans=0;
    scanf("%lld %lld",&n,&t);
    for(int i=1;i<=n;i++)
    	if(t%2==0){
    		t/=2;ans++;
		}
	printf("%lld",ans+1);
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	long long int i,n,k,j,flag,arr[100];
	scanf("%lld %lld",&n,&k);
	if(k%2==1)
		printf("1\n");
	else
	{
		arr[0]=0;
		arr[1]=1;
		for(i=2;i<=n+1;i++)
		{
			arr[i]=arr[i-1]*2;
		}
		flag=0;
		j=0;
		while(j<100)
		{
			for(i=1;i<=n+1;i++)
			{
		//		printf("%lld %lld\n",k,arr[i]);
				if(arr[i]>k)
				{
//					printf("%lld %lld\n",arr[i]-k,k-arr[i]);
					if(arr[i]-k<k-arr[i-1])
						k=arr[i]-k;
					else
						k=k-arr[i-1];
					break;
				}
				if(k==arr[i])
				{
					flag=1;
					printf("%lld\n",i);
					break;
				}
			}
			if(flag==1)
				break;
			j++;
		}
	}
	return 0;
}

#include<stdio.h>
int main()
{
   long long  n, k, sum = 1, i;
   scanf("%lld %lld", &n, &k);
   for(i = 1; i < n; i++)
   sum = sum * 2 + 1;
   while(1)
   {
      if(k > (sum - 1) / 2 + 1)
      {
         k -= (sum - 1) / 2 + 1;
         sum = (sum - 1) / 2;
      }
      else if(k < (sum - 1) / 2 + 1)
      {
        sum = (sum - 1) / 2;
      }
      else
      break;
      n--;
   }
   printf("%lld\n", n);
   return 0;
}

#include <math.h>
#include <stdio.h>

unsigned long long power_of_two(unsigned long long position) {
  unsigned long long temp_position = position;
  unsigned long long count = 0;

  while (temp_position > 1) {
    count++;
    temp_position /= 2;
  }

  if (pow(2, count) == position) {
    return count + 1;
  }

  return power_of_two(position - pow(2, count));
}

int main() {
  unsigned long long number;
  unsigned long long position;

  scanf("%llu", &number);
  scanf("%llu", &position);

  printf("%llu\n", power_of_two(position));

  return 0;
}

#include<stdio.h>
int main()
{
	long long int n,k,multiple=1,i;
	scanf("%lld %lld",&n,&k);
	for(i=0;i<n;i++)
	{
		multiple=multiple*2;
		if(k%multiple!=0)
		{
			printf("%lld\n",(i+1));
			break;
		}
	}
	return 0;
}

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
void r(int n,long long int k)
{

	int i;
	long long int j,c=0,l;
	if(k==1)
	{
		printf("1");
	}
	else
	{
		for(i=1;i<n;i++)
		{
			c=pow(2,i+1)-1;
			if(k<c)
			{
				j=k-pow(2,i);
				if(j>0)
				j=k-(2*j);
				//l=po/w(2,i+1)+1;
				if(j==0)
				{
					printf("%d",i+1);
					exit(0);
				}
				else if(j==1)
				{
					printf("1");
					exit(0);
				}
				else
				{
					//printf("dscdsh\n");
					r(i,j);
				}
			}
			else if(k==c)
			{
				//k=1;
				printf("1");
				exit(0);
			}
		}
	}
}
int main()
{
	int n,i;
	long long int k,j,c=0,l;
	scanf("%d%I64d",&n,&k);
	if(k%2!=0)
	{
		printf("1");
	}
	else
	r(n,k);
	return 0;
}

#include <stdio.h>

int main() {
	int n, cnt;
	long long k;

	scanf("%d%lld", &n, &k);
	cnt = 0;
	while (k % 2 == 0)
		k /= 2, cnt++;
	printf("%d\n", cnt + 1);
	return 0;
}

#include<stdio.h>
int main()
{
	long long int n,k,j,q,t,r,s,w;
	scanf("%lld %lld",&n,&k);
	long long int i=1;
	while(i<=52)
	{
		if(k%2==1)
		{
			printf("%lld\n",i);
			break;
		}
		else
		{
			i++;
			k=k/2;
		}
	}
	return 0;
}

#include<stdio.h>
#include<math.h>
int main(){
    long long int n,k,p,sum;
    scanf("%lld%lld",&n,&k);
    if(k%2==1){
        printf("1");
    }
    else{
        p=pow(2.0,n)-1;
       // printf("%d\n",p);
        if(k%4==2){
            printf("2");
        }
        else{
            sum=n;
            p=(p+1)/2;
            while(k!=p){
                sum--;

                if(k>p){
                    k=k-p;
                }
                p=(p+1)/2;
            }
            printf("%lld",sum);
        }
    }
}

#include <stdio.h>

int main() {
  long long n, k;
  scanf("%I64d %I64d", &n, &k);
  long long now = 1;
  long long ret = 1;
  while (1) {
    long long tmp = k - now;
    if (tmp % (now * 2LL) == 0) {
      printf("%I64d\n", ret);
      return 0;
    }
    now *= 2LL;
    ret += 1;
  }
  return 0;
}

#include<stdio.h>
#include<math.h>
int main() {
long long	int l,n,x;
	scanf ("%I64d %I64d",&l,&x);

	for (n=l;n>=1;n--) {
			if (x==(pow(2,n-1))){
			printf("%I64d",n);
		}
		if(x> (pow(2,n-1))){
			x-=pow(2,n-1);
		}

	}
}

#include<stdio.h>
#include<math.h>
main()
{
    int n,s;
    long long int k,l,i;
    scanf("%d ",&n);
    scanf("%I64d",&k);
    if(k%2!=0) {
        printf("1");
        return 0;
    }
    l=pow(2,n);
    s=n;
    for(i=l/2;i>=2;i/=2) {
        if(k%i==0) {
            printf("%d",s);
            return 0;
        }
        else s--;
    }

}

#include<stdio.h>
long long pick(long long len,long long pos,long long now)
{
    if((len+1)/2 == pos){
        return now;
    }else if(pos < pow(2,now-1)){
        return pick(pow(2,now-1)-1,pos,now-1);
    }else if(pos > pow(2,now-1)){
        return pick(pow(2,now-1)-1,pos-pow(2,now-1),now-1);
    }else{
        return now-1;
    }
}
int main()
{
    long long n,k,len;
    scanf("%lld%lld",&n,&k);
    len = pow(2,n)-1;
    printf("%d\n",pick(len,k,n));
    return 0;
}

#include<stdio.h>
#include<math.h>

long long int check(long long int k)
{
    if(k==1)
        return 1;
    long long i,x=1;
    for(i=1;i<=52;i++)
    {
        x*=2;
        if(x>=k)
            break;
    }
    if(x==k)
        return i+1;
    x/=2;
    return check(2*x-k);
}

int main()
{
    long long int n,k;
    scanf("%lld%lld",&n,&k);
    printf("%lld\n",check(k));
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    unsigned long long n,k,m,s;
    scanf("%llu%llu",&n,&k);

    m=pow(2,n-1);

    if(k%2!=0) printf("1");
    else
    {
        s=m/2;
        while (m!=k)
        {
            if (k>m)
                m=m+s;
            else m=m-s;
            n--; s=s/2;
        }
        printf("%llu",n);
    }

    return 0;
}

#include<stdio.h>
int main()
{
	long long int n,k;
	scanf("%lld%lld",&n,&k);
	int i,ans=1;
	for(i=0;i<60;i++)
	{
		if(k%2==0)
		{
			ans++;
			k=k/2;
		}
		else
			break;
	}
	printf("%d\n",ans);
	return 0;
}

#include <stdio.h>

int solve(int n, long long k);

int main(void)
{
    int n;
    long long k;

    scanf("%d %lld", &n, &k);
    k--;
    printf("%d\n", solve(n, k));

    return 0;
}

int solve(int n, long long k)
{
    long long tmp;
    tmp = ((long long)1 << (n-1))-1;
    if (k == tmp)
        return n;
    if (tmp < k)
        return solve(n-1, k-tmp-1);
    return solve(n-1, k);
}

#include <stdio.h>
#include <math.h>
int main() {
	int n;
    long long k, mid;
	scanf("%d %I64d", &n, &k);
	if (k % 2 == 1) { printf("1"); return 0; }
	mid = (long long)pow(2, (int)n - 1);
	while (k != mid ) {
		if (k > mid) k -= mid;
		n--;
		mid = (long long)pow(2, n - 1);
	}
	printf("%d", n);
	return 0;
}

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

int main(){
    int n;
    long long int k;
    scanf("%d %I64d", &n, &k);
    if ((n == 1) || (k == 1) || (k % 2)) printf("%d\n", 1);
    else {
        long long int powa = pow(2, n - 1);
        if (k == powa) printf("%d\n", n);
        else {
            while (k != powa){
                if (k > powa) k -= powa;
                n--;
                powa = pow(2, n - 1);
            }
            printf("%d\n", n);
        }
    }
    return 0;
}

#include<stdio.h>
typedef long long ll;
int main()
{
    ll power[50];
    for(int i=0;i<50;i++)
    {
    ll p=1;
    for(int j=0;j<=i;j++)
    p*=2;
    power[i]=p;
    }

    //for(int i=0;i<50;i++)
   // printf("%lld ",power[i]);
    int n;
    ll k;
    scanf("%d%lld",&n,&k);
    if(k%2!=0)
    printf("1");
    else
    {
    for(int i=0;i<50;i++)
    {
    if((k/power[i])%2!=0)
    {
    printf("%d",i+2);
    break;
    }
    }
    }
    return 0;
}

/* Codeforces Round #384 (Div. 2), problem B, by Abreto. */
#include <stdio.h>

typedef long long int ll;

long long int fstpow2(int n)
{
  if( 0 == n )
    return 1;
  else if ( 1 == n )
    return 2;
  else if ( 2 == n )
    return 4;
  else
  {
    long long int t = fstpow2(n/2);
    long long int r = ( n % 2 ) + 1;
    return t * t * r;
  }
}

int find(int n, long long int k)
{
  if( 1 == n )
    return 1;
  else
  {
    ll mid = fstpow2(n-1);
    if( k == mid )
      return n;
    else if ( k < mid )
      return find(n-1, k);
    else
      return find(n-1, k-mid);
  }
}

int main(void)
{
  int n = 0;
  long long int k = 0;

  scanf("%d %I64d", &n, &k);
  printf("%d\n", find(n,k));

  return 0;
}

#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
	long long int n,k,i;
	scanf("%lld%lld",&n,&k);
	long long int temp=2,num=k,count=0;
	int val=0;
	while(k>0)
	{

		count=0;
		num=k;
		while(num>0)
		{
			num=num/2;
			count++;
		}
		count--;
		if(k==pow(2,count))
		{
			val=1;
			printf("%lld",count+1);
			break;
		}
		k=k-pow(2,count);

	}
	if(val==0)
		printf("1");

	return 0;
}

#include <stdio.h>

typedef long long LL;
LL n,k,p[60];
int solve(int m,LL x);

int main(void)
{
    scanf("%I64d%I64d",&n,&k);
    int i;
    for(p[0]=1,i=1;i<=n;i++)
        p[i]=p[i-1]*2;
    printf("%d\n",solve(n,k));
    return 0;
}

int solve(int m,LL x)
{
    if(m==1) return 1;
    else if(x==p[m]/2) return m;
    else if(x>p[m]/2) return solve(m-1,x-p[m]/2);
    else return solve(m-1,x);
}

#include<stdio.h>
#include<math.h>
void f(long long t,long long n,long long k)
{
    if(n==1)printf("1\n");
    else{
    if(k==t/2+1)printf("%I64d\n",n);
    else if(k<t/2+1) f(t/2,n-1,k);
    else if(k>t/2+1) f(t/2,n-1,t+1-k);
    }
}
int main()
{
    long long n,k,t;
    scanf("%I64d%I64d",&n,&k);
    t=pow(2,n)-1;
    f(t,n,k);
    return 0;
}

#include <stdio.h>

int main()
{
    int n; long long k;
    scanf("%d %lld", &n, &k);
    int i;
    for(i = 1; i <= n; i++)
    {
        long long a = (long long)1<<(i - 1);
        long long b = (long long)1<<i;
        if( ((k - a)/(double)b) == ((k - a)/b) )
            printf("%d\n", i);
    }
    return 0;
}

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

int main()
{
    int n;
    long long int k,l,i;
    scanf("%d %lli",&n,&k);
    for(i=1;i<n;i++)
    {
        double ans=(double)k-(pow(2,i-1));
        ans=ans/(pow(2,i));
        long long int int_ans=(long long int)ans;
        if(ans==int_ans)
            {
              break;
            }

    }
    printf("%lli",i);

}

#include<stdio.h>
#define ll long long int
ll x;

ll bi(ll i){
   ll d=2,rem=1;
   while(i!=0){
    if(i%2==1)
      rem*=d;
    d*=d;
    i/=2;
   }
   return rem;
}

ll fun(ll k){
   ll a=0,i=0,b=k;
   for(i=0;b!=0;i++){
     if(b%2==1)
       a++;
     b/=2;
   }
   if(a==1){
     x=i;return 0;
   }
   else return fun(bi(i)-k);
}

  int main(){
    ll n,k,t=1;
    scanf("%lld%lld",&n,&k);
    while(t){
      t=fun(k);
    }
    printf("%lld\n",x);
    return 0;
  }

#include<stdio.h>
int main()
{
	long long n,k,i;
	scanf("%I64d %I64d",&n,&k);
	long long len=1;
	for(i=0;i<n;i++)len*=2;len=len-1;
	long long lo=0,hi=len,index;
	while(lo<hi)
	{
		if((hi+lo)%2==0)
		{
			index = (lo+hi)/2;
		}
		else
		{
			index = lo+(hi-lo)/2+1;
		}
		if(index==k)break;
		if(index<k)
		{
			lo=index;
		}
		else
		{
			hi=index;
		}
		n--;
	}
	printf("%I64d",n);
	return 0;
}

#include<stdio.h>
int main()
{
    long long int n,k,f=1;
    scanf("%lld%lld",&n,&k);
    while(1)
    {
        if (k%2==0)
        {
            f++;
            k/=2;
        }
        else
        {
            printf("%lld",f);
            break;

        }
    }
    return 0;
}

#include<stdio.h>
int main()
{
long long int n,k,c=1;
scanf("%lld%lld",&n,&k);
if(k%2==1)
printf("1");
else
{
c=1;
while(k!=0 && k%2==0)
{
c++;
k=k/2;
}

printf("%lld",c);

}
return 0;
}

#include<stdio.h>
int main(void)
{
    int n,m,v;
    long long k;
    while(scanf("%d",&n)!=EOF)
    {
        m=1;
        v=0;
        scanf("%I64d",&k);
        do
        {
        if(k%2)
        {printf("%d\n",m);v=1;}
        else
        {k=k/2;m=m+1;}
        }
        while(v==0);
    }
    return 0;
}

#include<stdio.h>
int main()
{
	int n,i=0,c=0;
	char s[60];
	long long int j=0;
	scanf("%d",&n);
	scanf("%s",s);
	while(s[i]!='\0')
		j=j*10+(int)(s[i++])-48;
	while(j>0)
	{
		if(j%2==0)
		c++;
		else
			break;
		j>>=1;
	}
	printf("%d\n",c+1);
	return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	long long int n,ans;
	long long int k,i,j,num,den;
	scanf("%lld%lld",&n,&k);
	for(i=1;i<=n;i++)
	{
	//	printf("\ni is %lld\n",i);
		num= k+pow(2,i-1);
	//	printf("num is %lld\n",num);
		den= pow(2,i);
	//	printf("den is %lld\n",den);
		ans=num%den;
		if(ans==0)
		{
			printf("%lld\n",i);
			break;
		}
	}
	return 0;
}

#include <stdio.h>
int main(void) {
    long long unsigned int n, k;
    scanf("%I64u %I64u", &n, &k);
    printf("%d", 1 + __builtin_ctzll(k));
}

#include<stdio.h>
#define ll long long
//#include<math.h>

ll power(int a,int b){
  if(!b) return 1;
  if(b % 2) return a * (power(a * a,(b - 1)/2));
  return power(a * a, b/2);
}

/*int ispow(ll n){
  int i = 1;
  while(power(2,i) <= n) i++;
  --i; if(n % power(2,i)) return 0; else return i;
  }
*/
int main(){
  int n, x; ll k; scanf("%d %lld", &n, &k);
  if(k % 2){printf("1\n"); return 0; }
  int ans;
//  ans = ispow(k); if(ans) printf("%d\n", ans + 1);
  //else{
    int flag = 1;
    for(x = 2; x <= n && flag; x++){
      ll p = power(2,x - 1), m = power(2,x); ll s = p;
      while(s <= k && flag){
        s += m; if(s == k){ ans = x; flag = 0;}
      }
    }
    printf("%d\n", ans);
  //}
  return 0;
}

#include <stdio.h>

int find(int n, int k, int size) {
	if (k == (size + 1) / 2)
		return n;
	if (k > (size + 1) / 2)
		k -= (size + 1) / 2;
	return find(n - 1, k, size / 2);
}

int main() {
	long long size;
	int n, k;

	scanf("%d%d", &n, &k);
	size = (1 << n) - 1;
	printf("%d\n", find(n, k, size));
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int s[1100010];
int main()
{
    int a,b;
    int n;
    int i,j,k,m;
    while(~scanf("%d%d",&a,&b))
    {
        a=a-1;
        s[0]=1;
        int t=b;
        int flag=1;
        i=0;
        j=0;
        s[1]=2;
        s[2]=1;
        for(i=0;i<50;i++)
            if(pow(2,i)<=b&&b<pow(2,i+1))
                break;
            //printf("%d\n",i);
        while(t%((int)pow(2,i))!=0)
        {
            t -= (int)pow(2,i);
            for(;i>=0;i--)
            if(pow(2,i)<=t&&t<=pow(2,i+1))
                break;
            //printf("%d\n",t);
        }
        //printf("hello\n");
        printf("%d\n",i+1);
    }
    return 0;
}

#include<stdio.h>
int main()
{
	int n,k,i;
	scanf("%d %d",&n,&k);
	int len=1;
	for(i=0;i<n;i++)len*=2;len=len-1;
	int lo=0,hi=len,index;
	while(lo<hi)
	{
		if((hi+lo)%2==0)
		{
			index = (lo+hi)/2;
		}
		else
		{
			index = lo+(hi-lo)/2+1;
		}
		if(index==k)break;
		if(index<k)
		{
			lo=index;
		}
		else
		{
			hi=index;
		}
		n--;
	}
	printf("%d",n);
	return 0;
}

#include <stdio.h>

int solve(int n, long long int k);

int main(void)
{
    int n;
    long long int k;

    scanf("%d %lld", &n, &k);
    k--;
    printf("%d\n", solve(n, k));

    return 0;
}

int solve(int n, long long int k)
{
    long long int tmp, ktmp;
    tmp = (1 << (n-1))-1;
    if (k == tmp)
        return n;
    if (tmp < k)
        return solve(n-1, k-tmp-1);
    return solve(n-1, k);
}

#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
    long long k,c;
    int a,b,i,j,sum=0,tmp,t,ara[1],ara1[1];
    double p,q,x,y,s,t1;
    char c1[1],c2[1];
    scanf("%d %I64d",&a,&k);
    for(i=1,c=2;;i++,c=c*2){
        b=c/2;
        if(k%c==b)
            break;

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

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
void r(int n,long long int k)
{

	int i;
	long long int j,c=0,l;
	for(i=1;i<n;i++)
	{
		c=pow(2,i+1)-1;
		if(k<c)
		{
			j=k-pow(2,i);
			//l=pow(2,i+1)+1;
			if(j==0)
			{
				printf("%d",i+1);
				exit(0);
			}
			else
			{
				r(n-1,j);
			}
		}
		else if(k==c)
		{
			//k=1;
			printf("1");
			exit(0);
		}
	}
}
int main()
{
	int n,i;
	long long int k,j,c=0,l;
	scanf("%d%lld",&n,&k);
	r(n,k);
	return 0;
}

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
void r(int n,long long int k)
{

	int i;
	long long int j,c=0,l;
	for(i=1;i<n;i++)
	{
		c=pow(2,i+1)-1;
		if(k<c)
		{
			j=k-pow(2,i);
			//l=pow(2,i+1)+1;
			if(j==0)
			{
				printf("%d",i+1);
				exit(0);
			}
			else
			{
				r(n-1,j);
			}
		}
		else if(k==c)
		{
			//k=1;
			printf("1");
			exit(0);
		}
	}
}
int main()
{
	int n,i;
	long long int k,j,c=0,l;
	scanf("%d%164d",&n,&k);
	r(n,k);
	return 0;
}

#include <stdio.h>

long long len[55] = { 0, 1 };

int next(long long k)
{
	int i;
	for (i = 1; k > len[i]; i++);

	if (k == len[i] - len[i - 1])
		return i;
	else
		return next(len[i] - k);
}

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

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

	for (i = 2; i <= n; i++)
		len[i] = 2 * len[i - 1] + 1;

	printf("%d", next(k));
}

#include <stdio.h>

long long len[55] = { 0, 1 };

int next(long long k)
{
	int i;
	for (i = 1; k > len[i]; i++);

	if (k == len[i])
		return i;
	else
		return next(len[i] - k);
}

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

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

	for (i = 2; i <= n; i++)
		len[i] = 2 * len[i - 1] + 1;

	printf("%d", next(k) + 1);
}

#include <stdio.h>
int main()
{
    int n,i,j,count;
    long long k;;
    scanf("%d %l64dd",&n,&k);
    if(k%2==1)
        printf("1\n");
    else if(k%4==0){
        count=0;
        while(k>0){
             if(k%2==1){
                count++;
                break;
             }
            k=k/2;
            count++;
        }
        printf("%d\n",count);
    }
    else
        printf("2\n");
    return 0;

}

#include <stdio.h>
int main()
{
    int n,i,j,count;
    unsigned long k;;
    scanf("%d %uld",&n,&k);
    if(k%2==1)
        printf("1\n");
    else if(k%4==0){
        count=0;
        while(k>0){
             if(k%2==1){
                count++;
                break;
             }
            k=k/2;
            count++;
        }
        printf("%d\n",count);
    }
    else
        printf("2\n");
    return 0;

}

#include <stdio.h>
int main()
{
    int n,i,j,count;
    long k;
    scanf("%d %ld",&n,&k);
    if(k%2==1)
        printf("1\n");
    else if(k%4==0){
        count=0;
        while(k>0){
             if(k%2==1){
                count++;
                break;
             }
            k=k/2;
            count++;
        }
        printf("%d\n",count);
    }
    else
        printf("2\n");
    return 0;

}

#include<stdio.h>

int main()
{
	long long x = 0;
	long long i = 0;
	long long int n = 0;
	long long int ind = 0;
	long long int ans = 0;
	scanf("%lld %lld", &n, &ind);

	for (i = n; i >= 0; i--) {
		x = 1<<i;
		if ( ind % x ==0)
		{
			ans = i+1;
			break;
		}
	}

	printf("%lld\n",ans);
	return 0;
}

#include<stdio.h>
int main()
{
	int n,k,x,r,i,j,c=0;
	scanf("%d%d",&n,&k);
	while(k>0)
	{
		c++;
		r=k%2;
		k/=2;
		if(r)
			break;
	}
	printf("%d",c);
	return 0;
}

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

int main()
{
    int n;
    long long int k,l,i;
    scanf("%d %lli",&n,&k);
    for(i=1;i<n;i++)
    {
        double ans=(double)k-(pow(2,i-1));
        ans=ans/(pow(2,i));
        long long int int_ans=(long long int)ans;
        if(ans==(double)int_ans)
            printf("%d",i);
    }
    return 0;
}

#include<stdio.h>
#include<math.h>
int main() {
	int l,n,x;
	scanf ("%d %d",&l,&x);

	for (n=l;n>=1;n--) {
			if (x==(pow(2,n-1))){
			printf("%d",n);
		}
		if(x> (pow(2,n-1))){
			x-=pow(2,n-1);
		}

	}
	return 0;
}

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

int n, i;
long long int pots[52], k;

int main()
{
	scanf("%d %I64d", &n, &k);
	for(i=0; i<=n; i++)
		pots[i]=pow(2,i);
	if(k%2!=0)
	{
		printf("1\n");
		return 0;
	}
	while(1)
	{
		i=0;
		while(pots[i]<k)
			i++;
		if((k-pots[i-1])<(pots[i]-k))
			i = i-1;
		if(abs(k-pots[i])==0)
		{
			printf("%d\n", i+1);
			return 0;
		}
		k=abs(k-pots[i]);
	}
	return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	long long int i,n,k,j,flag,arr[100];
	scanf("%lld %lld",&n,&k);
	if(k%2==1)
		printf("1\n");
	else
	{
		arr[0]=0;
		arr[1]=1;
		for(i=2;i<=n+1;i++)
			arr[i]=arr[i-1]*2;
		flag=0;
		j=0;
		while(j<100)
		{
			for(i=1;i<=n;i++)
			{
				if(arr[i]>k)
				{
					if(arr[i]-k<k-arr[i-1])
						k=arr[i]-k;
					else
						k=k-arr[i-1];

					break;
				}
				else if(k==arr[i])
				{
					flag=1;
					printf("%lld\n",i);
					break;
				}
			}
			if(flag==1)
				break;
			j++;
		}

	}
	return 0;
}

#include<stdio.h>
int main()
{
    long long int n,k,i,a=0,cnt=0,x;
    scanf("%lld %lld",&n,&k);

    if(k%4==1){
        printf("1");
        return 0;
    }
    else if(k%4==2){
        printf("2");
        return 0;
    }
    else if(k%4==3){
        printf("1");
        return 0;
    }
    else if(k%4==0){

        for(i=4;;i=i*2){
            cnt++;
            if(k==i){
                printf("%lld",cnt+2);
                return 0;
            }
            else if(i>k){
                break;
            }
        }
    }
    x=k/4;
    if(x%2==0){
        printf("4");
        return 0;
    }
    if(x%2!=0){
        printf("3");
        return 0;
    }
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    int n,k,m;
    scanf("%d%d",&n,&k);

    m=pow(2,n-1);

    if(k%2!=0) printf("1");
    else
    {
        if(k==m) printf("%d",n);
        else if (k>m) printf("%d",n-(k-m)/2);
        else printf("%d",n-(m-k)/2);
    }

    return 0;
}

#include <stdio.h>
int n , k ;
int main(void) {
scanf("%d%d",&n,&k);
if (k > (n/2)) k= k/2;
if(k%4==0){printf("%d",(k/4)+2); return 0 ; }
if(k%2==0){printf("2"); return 0 ; }
printf("1");

	return 0;
}

#include <stdio.h>
int n , k ;
int main(void) {
scanf("%d%d",&n,&k);
if(k%4==0){printf("%d",(k/4)+2); return 0 ; }
if(k%2==0){printf("2"); return 0 ; }
printf("1");

	return 0;
}

#include <stdio.h>
int n , k ;
int main(void) {
scanf("%d%d",&n,&k);
if (k > (n*2)) k= k/2;
if(k%4==0){printf("%d",(k/4)+2); return 0 ; }
if(k%2==0){printf("2"); return 0 ; }
printf("1");

	return 0;
}

#include<stdio.h>
int n,k;
int rec(int n)
{
    if(n==0)
        return 1;
    if(n%2==0)
    {
        int p=rec(n/2);
        return p*p;
    }
    if(n%2==1)
    {
        int q=rec(n/2);
        return 2*q*q;
    }
}
int main()
{
    scanf("%d %d",&n,&k);
    int l,i,a,v,x,ans;

    while(1)
    {
    a=k;
    l=0;
    while(a>0)
    {
        a=a/2;
        l++;
    }
    v=l;
    x=rec(l-1);
    k=k-x;

    if(k==0)
    {
        ans=v;
        break;
    }
    }
    printf("%d",ans);
}

#include<stdio.h>
#include<math.h>
int main()
{
	long long int n,k;
	scanf("%lld%lld",&n,&k);
	if(k%2!=0){
		printf("1\n");
		return 0;
	}

	long long int c=pow(2,n-1);
	if(k>c)
		k=k-c;
	long long int count=0;
	long long int no=2;
	long long int i=2;
	while(no<=k)
	{

		no=pow(2,i);
		count++;
		i++;
	}
	printf("%lld\n",count+1);
	return 0;
}

#include<stdio.h>
int main()
{
int n,i;
long long int k;
scanf("%d%lld",&n,&k);

if(k&01)
	printf("1");
else
	for(i=2;;i++)
	{	k=k>>1;
		if(k&1)
			break;
	}
printf("%d",i);

return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
   long long int n,position,i,check;
    scanf("%I64d%I64d",&n,&position);
    double a,k,b,f;
    k=position;

    for(i=0; i<n*n; i++)
    {
        f=log((2*k)/(2*i-1))/log(2);
        check=f;
        if(check==f)
        {
            break;
        }
    }
    printf("%I64d\n",check);;
    return 0;
}

#include <stdio.h>

int n;
long long k;

int main() {
  scanf("%d %I64d", &n, &k);
  int ans = 0;
  while (k%2==1 && ++ans)
    k = k >> 1;
  printf("%d\n", --ans);
}

#include <stdio.h>

int n;
long long k;

int main() {
  scanf("%d %I64d", &n, &k);
  int ans = 0;
  while (k > 0 && ++ans)
    k = k >> 1;
  printf("%d\n", ans);
}

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

int main()
{ int n = 0;
  long long k = 0;

  scanf("%d %l64d", &n, &k);
  if (k%2 !=0)
  {
      printf( "1");
  }
 else
 {
     long long a = pow(2,n);
     int z = n;
     long long a1 = a/4;
     long long a2 = 0;
   while (a!=k)
   { if (a>k)
     {
         a1 = a;
        a = a/2;

        if(a==k)
       {
           printf("%d",z);
       }
       else
       {
           z--;

       }
     }
       else
       {
          k=a1-k;
       }

   }
   }
return 0;
 }

#include<stdio.h>
#include<math.h>
int main()
{
	int n,ans;
	long long int k,i,j,num,den;
	scanf("%d%lld",&n,&k);
	for(i=1;i<=n;i++)
	{
		num= k+pow(2,i-1);
		den= pow(2,i);
		ans=num%den;
		if(ans==0)
		{
			printf("%lld\n",i);
			break;
		}
	}
	return 0;
}

#include <stdio.h>
#include <math.h>
long int Binary(long int start,long int end,long int x,long int n){
    if (start==end){
        return 1;
    }
    long int mid = (start+end)/2;
    if (mid==x){
        return n;
    }
    if (mid>x){
        return Binary(start,mid-1,x,n-1);
    }
    else{
        return Binary(mid+1,end,x,n-1);
    }
}
int main(){
    long int n,k;
    scanf("%ld %ld",&n,&k);
    long int end = pow(2,n)-1;
    long int ans=Binary(0,end-1,k-1,n);
    printf("%ld\n",ans);
    return 0;
}

#include<stdio.h>
int main()
{
    int n,k,x,y,i;
    scanf("%d%d",&n,&k);
    for(i=1;i<=n;i++){
        x=pow(2,i);
        y=pow(2,i-1);
        if(k%x==y){
            printf("%d",i);
            return 0;
        }

    }
}

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

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int result=1;
    int x=1;
    for(int i=1;i<a;i++){
        x=x*2;
    }
    while(b!=x){
        if(b>(x)){
            b=b-x;
            if(b==0){

            }
        }
        x=(x-1)/2+1;
    }
    int i=1;
    while(result!=x){
        result*=2;
        i++;
    }
    printf("%d\n",i);
    return 0;
}

#include <stdio.h>
int main(void) {
    long long unsigned int n, k;
    scanf("%I64u %I64u", &n, &k);
    for(int i = 1; i <= 50; i++) {
        if(k % (1 << i) == 1 << (i - 1)) {
            printf("%d", i);
            return 0;
        }
    }
    return 0;
}

#include<stdio.h>
int main()
{
    long long int n,k,i,a=0,cnt=0;
    scanf("%lld %lld",&n,&k);

    if(k%4==1){
        printf("1");
        return 0;
    }
    else if(k%4==2){
        printf("2");
        return 0;
    }
    else if(k%4==3){
        printf("1");
        return 0;
    }
    else if(k%4==0){

        for(i=4;;i=i*2){
            cnt++;
            if(k==i){
                printf("%lld",cnt+2);
                return 0;
            }
            else if(i>k){
                break;
            }
        }
    }
    printf("%lld",(k/4)%2!=0?3:4);
    return 0;
}

#include<stdio.h>
#include<math.h>
void f(long long t,long long n,long long k)
{
    if(n==1)printf("1\n");
    else{
    if(k==t/2+1)printf("%I64d\n",n);
    else if(k<t/2+1) f(t/2,n-1,k);
    else if(k>t/2+1) f(t/2,n-1,t+2-k);
    }
}
int main()
{
    long long n,k,t;
    scanf("%I64d%I64d",&n,&k);
    t=pow(2,n)-1;
    f(t,n,k);
    return 0;
}

#include<stdio.h>
#include<math.h>
void f(long long n,long long t,long long k)
{
    if(n==1)printf("1\n");
    else{
    if(k==n/2+1)printf("%I64d\n",t);
    else if(k<n/2+1) f(n/2,t-1,k);
    else if(k>n/2+1) f(n/2,t-1,n+2-k);
    }
}
int main()
{
    long long n,k,t;
    scanf("%I64d%I64d",&n,&k);
    t=pow(2,n)-1;
    f(t,n,k);
    return 0;
}

#include<stdio.h>
#include <math.h>
int main() {
	int n;
	int k, mid;

	scanf("%d %d", &n, &k);
	mid = pow((int)2, (int)n - 1);
	while (k != mid) {
		n--;
		if (k > mid) mid +=(int) pow(2, n-1);
		else mid -= (int) pow(2, n - 1);
	}
	printf("%d", n);
	return 0;
}

#include<stdio.h>
#include <math.h>
int main() {
	int n;
	long k, mid;

	//freopen("input.txt", "r", stdin);
	scanf("%d %d", &n, &k);
	mid = (int) pow(2, n - 1);
	while (k != mid) {
		n--;
		if (k > mid) mid += (int)pow(2, n - 1);
		else mid -= (int)pow(2, n - 1);
	}
	printf("%d", n);
	return 0;
}

#include<stdio.h>
#include <math.h>
int main() {
	int n;
	long k, mid;

	//freopen("input.txt", "r", stdin);
	scanf("%d %d", &n, &k);
	mid = pow((int)2, (int)n - 1);
	while (k != mid) {
		n--;
		if (k > mid) mid += (int)pow(2, n - 1);
		else mid -= (int)pow(2, n - 1);
	}
	printf("%d", n);
	return 0;
}

#include<stdio.h>
#include<math.h>
main()
{
	int n,k,i;
    long long int m,r;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)
	{
		m=k+pow(2,i-1);
		r=pow(2,i);
	if(m%r==0)
	{
		printf("%d",i);
		return 0;
	}

}
}

#include<stdio.h>
#include<math.h>
main()
{
	int n,k,i,m,r;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)
	{
		m=k+pow(2,i-1);
		r=pow(2,i);
	if(m%r==0)
	{
		printf("%d",i);
		return 0;
	}

}
}

#include<stdio.h>
int main()
{
	int n,i,c=0;
	char s[100];
	long long int j=0;
	scanf("%d",&n);
	scanf("%s",s);
	while(s[i]!='\0')
		j=j*10+(int)(s[i++])-48;
	while(j>0)
	{

		if(j%2==0)
		c++;
		else
			break;
		j>>=1;
	}
	printf("%d\n",c+1);
	return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	int n,i=0,po,t,p;
	char s[100];
	long long int j=0;
	scanf("%d",&n);
	scanf("%s",s);
	while(s[i]!='\0')
	{
		po=i;
		t=10;
		p=1;
		while(po>0)
		{
			if(p&1)
			p*=t;
			t*=t;
			po>>=1;
		}
		j+=((int)(s[i])-48)*p;
		i++;
		printf("%lld\n",j);
	}
	printf("%lld",j);
	return 0;
}

#include<stdio.h>
int main()
{
   int n, k, sum = 1, i;
   scanf("%d %d", &n, &k);
   for(i = 1; i < n; i++)
   sum = sum * 2 + 1;
   while(1)
   {
      if(k > (sum - 1) / 2 + 1)
      {
         k -= (sum - 1) / 2 + 1;
         sum = (sum - 1) / 2;
      }
      else if(k < (sum - 1) / 2 + 1)
      {
        sum = (sum - 1) / 2;
      }
      else
      break;
      n--;
   }
   printf("%d\n", n);
   return 0;
}

#include<stdio.h>
int main()
{
int n,k,c=1;
scanf("%d%d",&n,&k);
if(k%2==1)
printf("1");
else
{
c=1;
while(k!=0 && k%2==0)
{
c++;
k=k/2;
}

printf("%d",c);

}
return 0;
}

#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
	long long int b;
	int a;
	while(~scanf("%d%I64d",&a,&b))
	{
		if(b>pow(2,a-1))
		b=b-pow(2,a-1);
				if(b%4==0)
		{
			printf("%I64d\n",(b/4)+2);
		}
		else
		{
			if(b%4==1)
			printf("1\n");
			if(b%4==2)
			printf("2\n");
			if(b%4==3)
			printf("1\n");
		}
	}
	return 0;
}

#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
	long long int b;
	int a;
	while(~scanf("%d%I64d",&a,&b))
	{
		if(b%4==0&&b<=pow(2,a-1))
		{
			printf("%I64d\n",(b/4)+2);
		}
		else
		{
			if(b%4==1)
			printf("1\n");
			if(b%4==2)
			printf("2\n");
			if(b%4==3)
			printf("1\n");
			if(b%4==0)
			printf("%I64d\n",(b/4));
		}
	}
	return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    int n,k,sum;
    while(scanf("%d%d",&n,&k)!=EOF)
    {
        while(n>0)
        {
            sum=pow(2,n-1);
            if(sum==k)
            {
                printf("%d\n",n);
                break;
            }
            else
            {
                n-=1;
                if(k>sum)k%=sum;
            }
        }
    }
    return 0;
}

#include<stdio.h>
#include<math.h>

int f(int n, int k)
{
  long x = (long)(pow(2.0, (double)(n-1)));
  if(x==k)
    return n;
  else if(x > k)
    return f(n-1, k);
  else
    return f(n-1, k-x);
}

int main(void)
{
  int n, k;
  scanf("%d %d", &n, &k);
  printf("%d\n", f(n, k));
  return 0;
}

#include<stdio.h>
#include<math.h>

int f(int n, long k)
{
  long x = (long)(pow(2.0, (double)(n-1)));
  if(x==k)
    return n;
  else if(x > k)
    return f(n-1, k);
  else
    return f(n-1, k-x);
}

int main(void)
{
  int n;
  long k;
  scanf("%d %ld", &n, &k);
  printf("%d\n", f(n, k));
  return 0;
}

#include<stdio.h>
#include<math.h>

int f(int n, int k)
{
  int x = (int)(pow(2.0, (double)(n-1)));
  if(x==k)
    return n;
  else if(x > k)
    return f(n-1, k);
  else
    return f(n-1, k-x);
}

int main(void)
{
  int n, k;
  scanf("%d %d", &n, &k);
  printf("%d\n", f(n, k));
  return 0;
}

//Created by Pratik Mandlecha

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
	int n;
	long long int k,c=0;
	scanf("%d%lld",&n,&k);
	while(k>0)
	{
		if((k%2)==0) c++;
		k=k/2;
	}
	printf("%lld",c+1);

	return 0;
}

//Created by Pratik Mandlecha

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	if((k%2)==1) printf("1");
	else
	{
		int c=0;
		while(k>0)
		{
			if((k%2)==0) c++;
			k/=2;
		}
		printf("%d",c+1);
	}

	return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
	long long int n,k;
	scanf("%lld%lld",&n,&k);
	if((k%2)==1) printf("1");
	else
	{
		int c=0;
		while(k>0)
		{
			if((k%2)==0) c++;
			k/=2;
		}
		printf("%d",c+1);
	}

	return 0;
}

#include<stdio.h>
int main(){
	long n,k;
	int i;
	scanf("%ld %ld",&n,&k);
	for(i=1;i<=n;i++){
		if(k%2==1){
			printf("%d\n",i);
			break;
		}
		else
			k=k/2;
	}
	return 0;
}

#include<stdio.h>
int main(){
	long n,k;
	int i;
	scanf("%ld %ld",&n,&k);
	for(i=1;i<=n;i++){
		if(k%2==1)
			printf("%d\n",i);
		else
			k=k/2;
	}
	return 0;
}


Your search for Heidi is over – you finally found her at a library, dressed up as a human. In fact, she has spent so much time there that she now runs the place! Her job is to buy books and keep them at the library so that people can borrow and read them. There are n different books, numbered 1 through n.We will look at the library's operation during n consecutive days. Heidi knows in advance that on the i-th day (1 ≤ i ≤ n) precisely one person will come to the library, request to borrow the book ai, read it in a few hours, and return the book later on the same day.Heidi desperately wants to please all her guests, so she will make sure to always have the book ai available in the library on the i-th day. During the night before the i-th day, she has the option of going to the bookstore (which operates at nights to avoid competition with the library) and buying any book for the price of 1 CHF. Of course, if she already has a book at the library, she does not need to buy it again. Initially, the library contains no books.There is a problem, though. The capacity of the library is k – this means that at any time, there can be at most k books at the library. If buying a new book would cause Heidi to have more than k books, she must first get rid of some book that she already has, in order to make room for the new book. If she later needs a book that she got rid of, she will need to buy that book again.You are given k and the sequence of requests for books a1, a2, ..., an. What is the minimum cost (in CHF) of buying new books to satisfy all the requests?

The first line of input will contain two integers n and k (1 ≤ n, k ≤ 80). The second line will contain n integers a1, a2, ..., an (1 ≤ ai ≤ n) – the sequence of book requests.

On a single line print the minimum cost of buying books at the store so as to satisfy all requests.

NoteIn the first test case, Heidi is able to keep all books forever. Therefore, she only needs to buy the book 1 before the first day and the book 2 before the second day.In the second test case, she can only keep one book at a time. Therefore she will need to buy new books on the first, second and fourth day.In the third test case, before buying book 3 on the third day, she must decide which of the books 1 and 2 she should get rid of. Of course, she should keep the book 1, which will be requested on the fourth day.

#include<stdio.h>
int main(){
    int i,j,n,m,k,stock[81]={0},temp=0,count=0,ans = 0, a[81],check[81]={0};
    scanf("%d %d",&n ,&k);
    for(j=1;j<=n;j++)
        scanf("%d",&a[j]);
    stock[a[1]]++;
    ans++;
    count++;
    for(j=2;j<=n;j++){
        if(stock[a[j]] == 1) continue;
        if(count == k){
            for(i=0; i<81; i++)
                check[i] = 0;
            temp = count;
            for(i=j+1; i<=n; i++){
                if(temp == 1){
                    for(m=1; m<81; m++)
                        if(check[m] == 0 && stock[m] == 1){
                            stock[m] = 0;
                            count--;
                            break;
                        }
                    break;
                }
                if(stock[a[i]] == 1 && check[a[i]] == 0){
                    temp--;
                    check[a[i]] = 1;
                }
            }

                for(m=1; m<81; m++)
                    if(check[m] == 0 && stock[m] == 1){
                        stock[m] = 0;
                        count--;
                    }

        }
        stock[a[j]] = 1;
        count++;
        ans++;
        /*printf("%d\t",ans);
        for(i=0; i<81;i++)
            if(stock[i]) printf("%d ",i);
        printf("\n");*/
    }
    printf("%d\n",ans);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k))
    {
        int a[100],i,vis[100],money=0;
        memset(vis,0,sizeof(vis));
        for(i=0;i<n;i++)
            {
                scanf("%d",&a[i]);
                vis[a[i]]++;
            }
        int booknum=0,exit[100],flag=0;
        memset(exit,0,sizeof(exit));
        for(i=0;i<n;i++)
        {
            //printf("i=%d\n",i);
            if(exit[a[i]]==1&flag==0)
            {
                vis[a[i]]--;
                flag=1;
                if(!vis[a[i]])
                    booknum--;
            }
            if(booknum<k&vis[a[i]]==1&exit[a[i]]==0&flag==0)
            {
                money++;
                exit[a[i]]=1;
                //printf("money1=%d booknum=%d\n",money,booknum);
                flag=1;
                vis[a[i]]--;
            }
            if(booknum<k&vis[a[i]]>1&exit[a[i]]==0&flag==0)
            {
                money++;
                booknum++;
                exit[a[i]]=1;
                //printf("money2=%d booknum=%d\n",money,booknum);
                flag=1;
                vis[a[i]]--;
            }
           if(booknum==k&exit[a[i]]==0&flag==0)
            {
                int j,exit1[100],b[100],k=-1;
                memset(exit1,0,sizeof(exit1));
                if(i+1==n)
                {
                    money++;
                    break;
                }
                for(j=i+1;j<n;j++)
                {
                    if(exit[a[j]]==1&exit1[a[j]]==0)
                    {
                        b[++k]=a[j];
                        exit1[a[j]]=1;
                    }
                }
                //printf("%d\n",b[k]);
                if(vis[a[i]]==1)
                    booknum--;
                money++;
               //printf("money3=%d booknum=%d\n",money,booknum);
                exit[b[k]]=0;
                exit[a[i]]=1;
                vis[a[i]]--;
                flag=1;
            }
            flag=0;
        }
        printf("%d\n",money);
    }
    return 0;
}

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

int main()
{
    int n=0,i=0,j=0,book[81]={0},max=0,now[81]={0},time[81]={0},money=0,number=0,de=0,k=0,chose=0;
    scanf("%d %d",&n,&max);
    for(i=0;i<n;i++)
        scanf("%d",&book[i]);
    for(i=0;i<n;i++)
    {
        if(now[book[i]]==0 && number<max)
        {
            now[book[i]]=1;
            money++;
            number++;
        }
        else if(now[book[i]]==0 && number==max)
        {
            for(j=0;j<81;j++)
                time[j]=0;
            for(j=i;j<n;j++)
            {
                if(now[book[j]]==1 && time[book[j]]==0)
                {
                    time[book[j]]=1;
                    de=book[j];
                }
            }
            for(j=0;j<81;j++)
            {
                chose=0;
                if(now[j]==1)
                {
                    //but=now[j];
                    for(k=i;k<n;k++)
                    {
                        if(j==book[k])
                            chose=1;
                    }
                    if(chose==0)
                        de=j;
                }

            }
            now[de]=0;
            now[book[i]]=1;
            money++;
        }
    }
    printf("%d\n",money);
    return 0;
}

#include<stdio.h>
int main(){
    int i,j,n,m,k,stock[81]={0},temp=0,count=0,ans = 0, a[81],check[81]={0};
    scanf("%d %d",&n ,&k);
    for(j=1;j<=n;j++)
        scanf("%d",&a[j]);
    stock[a[1]]++;
    ans++;
    count++;
    for(j=2;j<=n;j++){
        if(stock[a[j]] == 1) continue;
        if(count == k){
            for(i=0; i<81; i++)
                check[i] = 0;
            temp = count;
            for(i=j+1; i<=n; i++){
                if(temp == 1){
                    for(m=1; m<81; m++)
                        if(check[m] == 0 && stock[m]){
                            stock[m] = 0;
                            count--;
                            break;
                        }
                    break;
                }
                if(stock[a[i]] == 1 && check[a[i]] == 0){
                    temp--;
                    check[a[i]] = 1;
                }
            }
            if(temp!=1){
                for(m=1; m<81; m++)
                    if(check[m] == 0 && stock[m]){
                        stock[m] = 0;
                        count--;
                        break;
                    }
            }
        }
        stock[a[j]]++;
        count++;
        ans++;
        /*printf("%d\t",ans);
        for(i=0; i<81;i++)
            if(stock[i]) printf("%d ",i);
        printf("\n");*/
    }
    printf("%d\n",ans);
    return 0;
}

#include<stdio.h>
int main(){
    int i,j,n,m,k,stock[81]={0},temp=0,count=0,ans = 0, a[81],check[81]={0};
    scanf("%d %d",&n ,&k);
    for(j=1;j<=n;j++)
        scanf("%d",&a[j]);
    stock[a[1]]++;
    ans++;
    count++;
    for(j=2;j<=n;j++){
        if(stock[a[j]] == 1) continue;
        if(count == k){
            for(i=0; i<81; i++)
                check[i] = 0;
            temp = count;
            for(i=j+1; i<=n; i++){
                if(temp == 1){
                    for(m=1; m<81; m++)
                        if(check[m] == 0 && stock[m]){
                            stock[m] = 0;
                            count--;
                            break;
                        }
                    break;
                }
                if(stock[a[i]] == 1){
                    temp--;
                    check[a[i]] = 1;
                }
            }
            if(temp!=1){
                for(m=1; m<81; m++)
                    if(check[m] == 0 && stock[m]){
                        stock[m] = 0;
                        count--;
                        break;
                    }
            }
        }
        stock[a[j]]++;
        count++;
        ans++;
        /* for(i=0; i<3;i++)
            printf("%d ",stock[i]);
        printf("\n");*/
    }
    printf("%d\n",ans);
    return 0;
}

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

int main()
{
    int n=0,i=0,j=0,book[81]={0},max=0,now[81]={0},money=0,number=0,de=0;
    scanf("%d %d",&n,&max);
    for(i=0;i<n;i++)
    {
        scanf("%d",&book[i]);
        if(now[book[i]]==0 && number<max)
        {
            now[book[i]]=1;
            money++;
            number++;
        }
        else if(now[book[i]]==0 && number==max)
        {
            for(j=i;j<n;j++)
            {
                if(now[book[j]]==1)
                    de=book[j];
            }
            now[de]=0;
            now[book[i]]=1;
            money++;
        }
    }
    printf("%d\n",money);
    return 0;
}

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

int main()
{
    int n=0,i=0,j=0,book[81]={0},max=0,now[81]={0},time[81]={0},money=0,number=0,de=0,k=0,chose=0;
    scanf("%d %d",&n,&max);
    for(i=0;i<n;i++)
        scanf("%d",&book[i]);
    for(i=0;i<n;i++)
    {
        if(now[book[i]]==0 && number<max)
        {
            now[book[i]]=1;
            money++;
            number++;
        }
        else if(now[book[i]]==0 && number==max)
        {
            for(j=0;j<81;j++)
                time[j]=0;
            for(j=i;j<n;j++)
            {
                if(now[book[j]]==1 && time[book[j]]==0)
                {
                    time[book[j]]=1;
                    de=book[j];
                }
            }
            for(j=0;j<11;j++)
            {
                chose=0;
                if(now[j]==1)
                {
                    //but=now[j];
                    for(k=i;k<n;k++)
                    {
                        if(j==book[k])
                            chose=1;
                    }
                    if(chose==0)
                        de=j;
                }

            }
            now[de]=0;
            now[book[i]]=1;
            money++;
        }
    }
    printf("%d\n",money);
    return 0;
}

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

int main()
{
    int n=0,i=0,j=0,book[81]={0},max=0,now[81]={0},money=0,number=0,de=0,k=0,chose=0;
    scanf("%d %d",&n,&max);
    for(i=0;i<n;i++)
        scanf("%d",&book[i]);
    for(i=0;i<n;i++)
    {
        if(now[book[i]]==0 && number<max)
        {
            now[book[i]]=1;
            money++;
            number++;
        }
        else if(now[book[i]]==0 && number==max)
        {
            for(j=i;j<n;j++)
            {
                if(now[book[j]]==1)
                    de=book[j];
            }
            for(j=0;j<81;j++)
            {
                chose=0;
                if(now[j]==1)
                {
                    //but=now[j];
                    for(k=i;k<n;k++)
                    {
                        if(j==book[k])
                            chose=1;
                    }
                    if(chose==0)
                        de=j;
                }

            }
            now[de]=0;
            now[book[i]]=1;
            money++;
        }
    }
    printf("%d\n",money);
    return 0;
}

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

int main()
{
    int n=0,i=0,j=0,book[81]={0},max=0,now[81]={0},money=0,number=0,de=0;
    scanf("%d %d",&n,&max);
    for(i=0;i<n;i++)
        scanf("%d",&book[i]);
    for(i=0;i<n;i++)
    {
        if(now[book[i]]==0 && number<max)
        {
            now[book[i]]=1;
            money++;
            number++;
        }
        else if(now[book[i]]==0 && number==max)
        {
            for(j=i;j<n;j++)
            {
                if(now[book[j]]==1)
                    de=book[j];
            }
            now[de]=0;
            now[book[i]]=1;
            money++;
        }
    }
    printf("%d\n",money);
    return 0;
}