#include<stdio.h>
#include<math.h>
#define max(a,b)(a>b?a:b)
//int a[100010];

  int main()
{
  long long s,c,a;
  scanf("%lld %lld",&s,&c);
  if((c / 2) < s)
    a = c / 2;
  else
  {
    a = s;
    c = c - s * 2;
    a = a + c / 4;
  }

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