Problem:
 Score : 300 points    Problem Statement Snuke loves puzzles.  Today, he is working on a puzzle using S - and c -shaped pieces.
In this puzzle, you can combine two c -shaped pieces into one S -shaped piece, as shown in the figure below:     Snuke decided to create as many Scc groups as possible by putting together one S -shaped piece and two c -shaped pieces.  Find the maximum number of Scc groups that can be created when Snuke has N  S -shaped pieces and M  c -shaped pieces.      Constraints  1 ≤ N,M ≤ 10^{12}         Input The input is given from Standard Input in the following format:  N  M       Output Print the answer.        Sample Input 1 1 6      Sample Output 1 2  Two Scc groups can be created as follows:   Combine two c -shaped pieces into one S -shaped piece  Create two Scc groups, each from one S -shaped piece and two c -shaped pieces        Sample Input 2 12345 678901      Sample Output 2 175897

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())

    a = min(N, M // 2)
    M -= 2 * a
    b = M // 4
    ans = a + b
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())

    ans = min((2 * N + M) // 4, M // 2)
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
n,m=map(int,input().split())

ans=0

if m-2*n>=0:
    m-=2*n
    ans+=n + (m//4)
    print(ans)
else:
    ans+=m//2
    print(ans)
    exit(0)

Solution (Python):
s,c=map(int,input().split())

cnt=0
p=min(s,c//2)
s-=p
c-=2*p
cnt+=p
q=0
if c<2:
    print(cnt)

else:
    q=c//4
    cnt+=q
    print(cnt)

Solution (Python):
n, m = map(int, input().split())
print(m//2 if 2*n > m else n + (m - 2*n)//4)

Solution (Python):
s,c = map(int,input().split())
if s >= c//2:
    print(c//2)
else:
    c -= s*2
    ans = s
    ans += c//4
    print(ans)

Solution (Python):
s,c=map(int,input().split())
ans=0
if s*2>=c:
  ans=c//2
else:
  ans=s+(c-s*2)//4
print(ans)

Solution (Python):
n, m = map(int, input().split())

if n * 2 <= m:
    m -= n * 2
    print(n + m // 4)
else:
    print(m // 2)

Solution (Python):
n, m = map(int, input().split())

print(m // 2 if m <= 2 * n else n + (m - 2 * n) // 4)

Solution (Python):
N,M = map(int,input().split())

def solve(N,M):
  
  if M < N * 2:
    return M // 2
  
  M -= N * 2
  
  ans = N + (M // 4)
  return ans

print(solve(N,M))

Solution (Python):
N, M = map(int, input().split())
if N * 2 > M:
    print(M // 2)
else:
    print(N + (M - 2 * N) // 4)

Solution (Python):
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *

from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction



mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]








n,m=l()
if(m<2*n):
    print(m//2)
elif(m==2*n):
    print(n)
else:
    print(n+(m-2*n)//4)

Solution (Python):
N,M = map(int,input().split())

ans = 0

if M <= 2*N:
    ans += M // 2
    print(ans)
    exit()

ans += N
M -= N*2

ans += M//4

print(ans)

Solution (Python):
N, M = map(int, input().split())
if N * 2 <= M:
    print(N + (M - N * 2) // 4)
else:
    print(M // 2)

Solution (Python):
N, M = map(int, input().split())

ans = 0
x = max(0, (M-2*N) // 4)
r = min(10, M//2)
for i in range(max(0, x-r), x+r):
    tmp = min(N+i, (M-2*i)//2)
    ans = max(ans, tmp)

print(ans)

Solution (Python):
n,m = list(map(int,input().split()))
if 2*n <= m:
    print(n+(m-2*n)//4)
else:
    print(m//2)

Solution (Python):
n, m = map(int, input().split())
if 2 * n >= m:
    print(m // 2)
else:
    t = m - 2 * n
    print(n + t // 4)

Solution (Python):
def main():
    N, M = map(int, input().split())

    ans = 0

    Scc_pair_count = min(N, M // 2)
    N -= Scc_pair_count
    M -= Scc_pair_count * 2
    ans += Scc_pair_count

    if N == 0:
        ans += M // 4

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
S,c = list(map(int,input().split()))
if S >= c//2:
    print(c//2)
    exit()
ans = S
c -= 2*S
ans += c//4
print(ans)

Solution (Python):
N, M = map(int, input().split())

ans = 0
if N * 2 <= M:
    ans += N
    M -= N * 2
    ans += M // 4
    print(ans)
else:
    ans += M//2
    print(ans)

Solution (Python):
def solve():
  n, m = map(int, input().split())
  if m//2 <= n:
    print(m//2)
  else:
    ans = 0
    ans += n
    m = m-n*2
    ans += m//4
    print(ans)
  return 0
 
if __name__ == "__main__":
  solve()

Solution (Python):
n, m = map(int, input().split())

cnt = min(n, m // 2)
print(cnt + (m - cnt * 2) // 4)

Solution (Python):
n, m = map(int, input().split())

ans = 0
if 2*n > m:
    ans += m//2
    m = m%2
else:
    ans += n
    m -= 2*n
ans+=m//4
print(ans)

Solution (Python):
n,m = map(int, input().split())

if n > (m+n)/3:
    print(m//2)
    exit()

ans = n
m -= 2*n
ans += m//4
print(ans)

Solution (Python):
n,m = map(int, input().split())

if n > (m+n)/3:
    print(m//2)
    exit()
if m > 10000000000:
    print(m//4)
    exit()

while n <= (n+m)/3:
    n += 1
    m -= 2

print(n-1)

Solution (Python):
N,M = map(int, input().split())

ans = 0
if N<M:
    ans = N
    M = max(0, M-2*N)
    ans = ans + M//4
    print(ans)
else:
    print(M//2)

Solution (Python):
n,m=map(int,input().split())
cnt_s=n
cnt_c=m
ans=0
if cnt_s>cnt_c:
  ans=cnt_c//2
  print(ans)
elif cnt_s<=cnt_c:
  ans+=min(n,cnt_c//2)
  cnt_c-=2*min(n,cnt_c//2)
  ans+=cnt_c//4
  print(ans)

Solution (Python):
import sys
from collections import Counter
from collections import deque
import math
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,m=mp()

if 2*n>=m:
    print(m//2)
    exit()
print(n+math.ceil((m-2*n)//4))

Solution (Python):
n, m = map(int, input().split())

if m < 2:
    print(0)
    exit()

ans = 0
tmp = min(n, m // 2)
ans += tmp
n -= tmp
m -= tmp * 2

ans += m // 4

print(ans)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

Scc = min(N, M // 2)
N = N - Scc
M = M - Scc * 2
if N == 0:
    ans = Scc + M // 4
else:
    ans = Scc
print(ans)

Solution (Python):
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor



dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n, m = map(int, input().split())
if m <= 2*n:
    print(m//2)
else:
    print(n+math.ceil((m-2*n)//4))

Solution (Python):
n,m=map(int,input().split()) 
if 2*n<=m: 
    print(n+(m-2*n)//4) 
else:
    print(m//2)

Solution (Python):
import math
n, m = map(int, input().split())

if m <= 2*n:
    print(m//2)
elif 2*n < m:
    print(n + math.ceil((m- 2*n)//4))

Solution (Python):
N, M = map(int, input().split())
if N >= M/2:
  ans = M//2
else:
  ans = int((2*N + M)//4)
  
print(ans)

Solution (Python):
n, m = map(int, input().split())
if n >= m // 2:
    print(m // 2)
else:
    print((n + m // 2) // 2)

Solution (Python):
n,m = map(int, input().split())

ans = 0
M = m//2
ans += min(n,M)
if min(n,M) == n:
  m -= n*2
  ans += m//4
print(ans)

Solution (Python):
import sys
N,M = map(int,input().split())

if N*2 >= M: 
  print(M//2)
  sys.exit()


ans = N
M = M -2*N
ans += M//4
print(ans)

Solution (Python):
S, C = map(int, input().split())

if S>=C//2:
    print(C//2)
else:
    ans = S
    C -= S*2
    ans += C//4
    print(ans)

Solution (Python):
N,M = map(int,input().split())
if M<2*N:
    cnt = M//2
else:
    cnt = N
    k = M-2*N
    cnt += k//4
print(cnt)

Solution (Python):
N,M = map(int, input().split())

def f(x):
    if M >= 2*x and N+(M-2*x)//2 >= x:
        return True
    return False

l = 0
r = 10**12
while r-l > 1:
    m = (l+r)//2
    if f(m):
        l = m
    else:
        r = m

if f(r):
    print(r)
else:
    print(l)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())

    res = 0
    if 2 * n <= m:
        res += n
        m -= n * 2
        res += m // 4
    else:
        res += m // 2

    print(res)


if __name__ == '__main__':
    resolve()

Solution (Python):
S,C = map(int,input().split())
ans = min(S,C//2)
C -= ans*2
ans += C//4
print(ans)

Solution (Python):
def solve():
    N, M = map(int, input().split())
    if M<2*N:
        return M//2
    return N+(M-2*N)//4
print(solve())

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))

def resolve():
    N,M=pin()
    
    t=M//2
    if t<N:
        print(t)
        return
    M-=N*2
    ans=N
    ans+=M//4
    print(ans)

resolve()

Solution (Python):
n,m = map(int,input().split())
if n>m:
    print(m//2)
else:
    if n*2>m:
        print(m//2)
    else:
        cnt = 0
        m -= n*2
        cnt += n
        if m>=4:
            cnt+=m//4
        print(cnt)

Solution (Python):
s,c = map(int,input().split())
ans = 0
if c >= 2*s:
  ans += s
  c -= 2*s
else:
  print(c//2)
  exit()
ans += c//4
print(ans)

Solution (Python):
n,m = map(int,input().split())
ans = 0
if 2*n>m:
  ans += m//2
else:
  ans += n
  m -= 2*n
  ans += m//4
  
print(ans)

Solution (Python):
def main():
    N, M = map(int, input().split())
    if M <= N * 2:
        print(M//2)
        return
    remain = M - N*2
    ans = N
    ans += remain // 4
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
n,m = map(int, input().split())
if n*2 > m:
    print(m//2)
else:
    a = (m-n*2)//4
    print(n + a)

Solution (Python):
n,m=[int(_) for _ in input().split()]

ans=min(n,m//2)

m-=ans*2

ans += m//4
print(ans)

Solution (Python):
n, m = map(int, input().split())
if 2 * n > m:
  print(m // 2)
else:
  print((m - 2 * n) // 4 + n)

Solution (Python):
n, m = map(int, input().split())
if m <= 2 * n:
    print(m // 2)
else:
    print(n + (m - 2 * n) // 4)

Solution (Python):
N, M = map(int, input().split())

S = N
c = M // 2

print(min((S + c) // 2, c))

Solution (Python):
import sys

N, M = map(int, sys.stdin.readline().strip().split())

if N >= M // 2:
    print(M // 2)
else:
    ans = N
    r = M - N*2
    ans += r // 4
    print(ans)

Solution (Python):
n, m = map(int, input().split())
if n >= m//2:
    print(m//2)
else:
    print(n+(m-2*n)//4)

Solution (Python):
n, m = map(int, input().split())

q = m // 2

if n >= q:
    print(q)
else:
    m -= 2*n
    m //= 4
    print(n+m)

Solution (Python):
s,c = map(int,input().split(" "))
count = 0
if s == 0:
    print(c // 3)
else:
    count += min(s,c // 2)
    if s < c // 2:
        c -= s * 2
        count += c // 4
print(count)

Solution (Python):
import sys
import os

def file_input():
    f = open('ARC069/input.txt', 'r')
    sys.stdin = f

def main():
    
    N,M=map(int, input().split())

    if N*2>=M:
        print(str(M//2))
    else:
        M-=N*2
        print(str(N+M//4))

if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
N, M = map(int, input().split()) 

def detection(R, L):
    
    if R-L <= 1:
        return L
    mid = (R+L)//2
    if mid > N:
        num_s = mid - N
        num_c = M - num_s*2
    else:
        num_s = mid
        num_c = M
    if num_c < mid*2:
        R = mid
    else:
        L = mid
    return detection(R,L)

def main():
   right = N+M
   left = -1
   ans = detection(right, left)
   print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())
print(min(N, M//2)+max(0, (M-2*N)//4))

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,m = iim()
if 2*n > m:
    print(m//2)
else:
    print(n+(m-2*n)//4)

Solution (Python):
def solve():
    n, m = map(int, input().split())

    if 2*n <= m:
        return n + (m-2*n)//4
    else:
        return m//2

    

print(solve())

Solution (Python):
import fractions
import sys
from functools import reduce

input = sys.stdin.readline


def main():
    n, m = input_list()
    if n >= m // 2:
        print(m//2)
    else:
        c = (m-(2*n))//4
        print(n+c)


def input_list():
    return list(map(int, input().split()))


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


if __name__ == "__main__":
    main()

Solution (Python):
N, M = map(int, input().split())

ans = 0
if 2 * N == M:
    ans = (2 * N + M) // 4
elif 2 * N > M:
    ans = M // 2
else:
    ans = N
    ans += (M - 2 * N) // 4
print(ans)

Solution (Python):
n,m=map(int,input().split())
print(n+(m-n*2)//4 if m>n*2 else m//2)

Solution (Python):
n, m = map(int, input().split())

if m <= 2 * n:
  ans = m // 2
else:
  ans = n + (m - 2 * n) // 4

print(ans)

Solution (Python):
import sys


def input(): return sys.stdin.readline().strip()


def resolve():
    n, m = map(int, input().split())
    cnt = 0
    if 2*n <= m:
        cnt += n
        m -= n * 2
        cnt += m // 4
    else:
        cnt += m // 2
    print(cnt)
resolve()

Solution (Python):
N, M = map(int, input().split())

if M >= 2*N:
    M -= 2*N
    print(N + M//4)
else:
    print(M//2)

Solution (Python):
n,m = tuple(map(int,input().split()))

if m-2*n>0:
  rest = m-2*n
  print(n+rest//4)
else:
  print(m//2)

Solution (Python):
N,M=map(int,input().split())
ans = 0
if M >= 2 * N:
    ans = N
    M -= N * 2
    ans += M // 4
    
else:
    ans = M //2
print(ans)

Solution (Python):
N, M = map(int,input().split())
ans = min(N,M//2)
N -= ans
M -= ans*2
if M >= 2:
    ans += M//4
print(ans)

Solution (Python):
n,m = map(int,input().split())
cnt = 0
if m // 2 >= n:
    cnt += n
    m -= n*2
else:
    cnt += m//2
    n -= m//2
    m -= m


cnt += m//4

print(cnt)

Solution (Python):
N,M=map(int, input().split())

ans1=min(N, M//2)
resN=N-ans1
resM=M-ans1*2
if resM<2:
    print(ans1)
else:
    
    ans2=resM//4
    print(ans1+ans2)

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right


from functools import reduce
from pprint import pprint

INF = float("inf")

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n,m = RI()

ans = 0
if (2*n)<=m:
    ans += n
    ans += ( m - (2*n) )//4
elif m<(2*n):
    ans += m//2
else:
    print("E")
    exit()
print(ans)

Solution (Python):
from sys import exit
n,m=map(int, input().split())
c_rem=0
if m//2 <= n:
    print(m//2)
else:
    c_rem = m//2 - n
    print(n+c_rem//2)

Solution (Python):
N, M = map(int, input().split())

ans = 0
k = min(N, M // 2)
ans += k
M -= 2 * k
ans += M // 4
print(ans)

Solution (Python):
import sys
from itertools import permutations

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    if N >= M // 2: print(M // 2)
    else:
        leftC = M - N * 2
        print(N + leftC // 4)

    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
def main():
    N, M = (int(i) for i in input().split())
    if N >= M//2:
        print(M//2)
    else:
        print(N + (M - 2*N)//4)


if __name__ == '__main__':
    main()

Solution (Python):
n,m = map(int, input().split())
cnt = 0
if m//2 >= n:
  cnt += n
  m -= n*2
  print(cnt+m//4)
else:
  print(m//2)

Solution (Python):
n,m=map(int,input().split())
s=(2*n+m)//4
if (s+1)*4<=2*n+m:
  s+=1
print(min(m//2,s))

Solution (Python):
n, m = map(int, input().split())
Scc = min(n, m//2)
cccc = (m-Scc*2)//4
print(Scc+cccc)

Solution (Python):
n,m=map(int,input().split())
ans=0
if(2*n<=m):
    ans+=n
    m-=2*n
    ans+=m//4
else:
    ans+=m//2
print(ans)

Solution (Python):
N, M = map(int, input().split())
print(min(N+(M-N*2)//4, M//2))

Solution (Python):
N, M = map(int, input().split())
M = M//2

if N>=M:
    print(M)
else:
    print((N+M)//2)

Solution (Python):
n, m = map(int, input().split())

if n > m//2:
    print(m//2)
else:
    print(n + (m-2*n)//4)

Solution (Python):
n, m = map(int, input().split())
x = min(n, m//2)
y = (m-x*2)//4
print(x+y)

Solution (Python):
import sys
input = sys.stdin.readline

n, m = [int(x) for x in input().split()]
ans = 0

if 2*n <= m:
    ans += n
    m -= 2*n
    ans += m // 4

else:
    ans += m // 2

print(ans)

Solution (Python):
N,M = map(int,input().split())

if 2*N > M:
    print(M//2)
else:
    M -= 2*N
    print(N+M//4)

Solution (Python):
n, m = map(int, input().split())
if n >= m // 2:
    print(m // 2)
else:
    print(n + (m - 2 * n) // 4)

Solution (Python):
s,c=map(int,input().split())
if s > c//2:
   print(c//2)
   exit()
else:
   c-=s*2
s+=c//4
print(s)

Solution (Python):

"""
Created on Wed May 13 12:32:15 2020

@author: shinba
"""
import sys

n,m = map(int,input().split())

if n >= int(m/2):
    print(int(m/2))
    sys.exit()
else:
    m -= 2*n
    print(n+int(m/4))

Solution (Python):
n, m = map(int,input().split())
i = (m-2*n)//4
if i < 0:
    print(m//2)
else:
    print(n+i)

Solution (Python):
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))



def main():
    s, c = ns()

    if c % 2:
        c -= 1

    if s >= c // 2:
        ans = c // 2
    else:
        x = (c - 2 * s) // 2
        ans = (c - x) // 2

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())

if N * 2 < M:
    ans = N + (M - 2 * N) // 4
else:
    ans = min(N, M // 2)
print(ans)

Solution (Python):


n, m = map(int, input().split())

if n * 2 >= m:
    ans = m // 2
else:
    ans = n + (m - n * 2) // 4
print(ans)

Solution (Python):
n, m = map(int, input().split())
cnt = 0
if 2*n <= m:
    m -= n*2
    cnt += n
    m //= 4
    cnt += m
else:
    cnt = m//2
print(cnt)

Solution (Python):
N, M = map(int, input().split())
if 2*N >= M:
    print(M//2)
else:
    print((2*N+M)//4)

Solution (Python):
S,C = map(int,input().split())
ans = min(S,C//2)
C -= 2*ans
S = C//2
ans += S//2

print(ans)

Solution (Python):
s,c=map(int,input().split())
ans=min(s,c//2)
s-=ans
c-=2*ans

if c:
    ans+=c//4
print(ans)

Solution (Python):
n,m = map(int,input().split())

if n*2>=m:
    print(m//2)
else:
    tmp=m-n*2
    print(n+tmp//4)

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    N, M = map(int, readline().split())
    if M//2<=N:
        ans = M//2
    else:
        ans = N + (M-N*2)//4
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
n, m = list(map(int, input().split()))

if m >= n * 2:
	x = m - 2 * n
	print(n + x // 4)
    
else:
  print(m // 2)

Solution (Python):
n,m=map(int,input().split())

if n*2 >= m:
 print(m//2)
else:
 print(n+((m-2*n)//4))

Solution (Python):
N, M = map(int, input().split())

ans = 0



if N > M/2:
    ans += M//2
    N -= M//2
    M = M % 2
    print(ans)
    exit(0)



ans += N
M -= N*2
N = 0


ans += M//4
print(ans)

Solution (Python):
n, m = map(int, input().split())

ans = 0

tmp = n * 2

if m <= tmp:
    print(m//2)
    exit()
    
ans += n

m -= tmp

ans += m//4

print(ans)

Solution (Python):
n, m = map(int, input().split())
s = n
c = m//2
if s>c:
    print(c)
else:
    print((s+c)//2)

Solution (Python):
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


N, M = readnums()

'''
N:M = 1:2が理想
N + x: M -2x = 1:2
2N+2x = M-2x
M-2N=4x
'''

if M >= N * 2:
    x = (M - 2 * N) // 4
    print(N + x)
else:
    print(M // 2)

Solution (Python):
def main():
    n, m = map(int, input().split())
    answer = min(n, m // 2)
    m -= 2 * answer
    answer += m // 4
    print(answer)


if __name__ == '__main__':
    main()

Solution (Python):




n, m = map(int,input().split())


if n >= 2 * m:
    ans = int(m / 2)
else:
    if n < m:
        ans = n + int(max(0, (m - n * 2)) / 4)
    else:
        ans = int(m / 2)


print(ans)

Solution (Python):
def main():
    ans = 0
    n,m = map(int, input().split())
    p = m//2
    if p >= n:
        ans += n + (p-n)//2
    else:
        ans += p
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
def myAnswer(N:int,M:int) -> int:
   if(2 * N <= M):
      counter = N
      M -= 2*N
      counter += M//4
   else:
      counter = M//2
   return counter

def modelAnswer():
   return
def main():
   N,M = map(int,input().split())
   print(myAnswer(N,M))

if __name__ == '__main__':
   main()

Solution (Python):
N,M = map(int,input().split())

if 2*N == M:
    print(N)
    exit()
elif 2*N > M:
    print(M//2)
    exit()
else:
    rem = M-2*N
    SCCset = rem//4
    print(N+SCCset)
    exit()

Solution (Python):
N, M = map(int,input().split())

if N*2 > M:
  print(M//2)
else:
  print(N + (M-N*2)//4)

Solution (Python):
n,m = map(int, input().split())
ans = 0
if m >= 2 * n: 
    ans += n
    m -= 2 * n
    ans += m // 4
else: ans += m // 2
print(ans)

Solution (Python):
N, M = map(int,input().split())
if M < 2*N:
  print(M//2)
else:
  print(N + (M-N*2)//4)

Solution (Python):
n,m = map(int,input().split())
if m//2 <= n:
    print(m//2)
else:
    a = m - 2*n
    print(a//4+n)

Solution (Python):
n, m = map(int, input().split())

ans = 0
res = 0

if n >=  (m//4) * 2:
    print((m//4) * 2)
else:
    ans += n
    res = m - 2*n
    ans += (res//4)
    print(ans)

Solution (Python):
N, M = map(int, input().split())
print(N + (M - 2*N)//4 if N < M//2 else M // 2)

Solution (Python):
n , m = map(int,input().split())
ans = 0
if m >= n*2:
    ans += n
    m -= n*2
    ans += m//4
elif m < n*2:
    ans += m//2
print(ans)

Solution (Python):
n, m = map(int, input().split())
print((min(n*2,m)+m)//4)

Solution (Python):
n,m =  map(int,input().split())
if n >= m//2:
    ans = min(n,m//2)
else:
    ans = n
    m -= 2*n
    ans += m//4
print(ans)

Solution (Python):
import sys

n, m = map(int, input().split())

if m // 2 <= n:
    print(m // 2)
    sys.exit()
else:
    cnt = n
    m -= n * 2
    cnt += m // 4

print(cnt)

Solution (Python):
n,m=map(int,input().split())
m2=m//2
if n>=m2:
    print(m2)
else:
    ans=n+(m-2*n)//4
    print(ans)

Solution (Python):
n, m = map(int,input().split())

if m - 2 * n >= 0:
    ans = n + (m-2*n)//4
    print(ans)
else:
    print(m//2)

Solution (Python):
N, M = map(int, input().split())
print(min(M // 2, (2 * N + M) // 4))

Solution (Python):
N, M = map(int, input().split())
def solve():
    ans = min((N*2+M)//4, M//2)
    return ans
print(solve())

Solution (Python):
s,c = map(int,input().split())

if s*2 <= c:
    print((2*s+c)//4)

else:
    print(int(c/2))

Solution (Python):
N, M = map(int, input().split())
if N >= M // 2:
  print(M//2)
else:
  amari_c = M - 2 * N
  ans = N + amari_c // 4
  print(ans)

Solution (Python):
n,m=map(int,input().split())
if n==m//2:
  print(m//2)
  exit()
if n>m//2:
  print(m//2)
  exit()
ans=0
ans+=n
m-=2*n
ans+=m//4
print(ans)

Solution (Python):
N, M = map(int, input().split())

if 2 * N >= M:
    print(M // 2)
else:
    d = M - 2 * N
    d //= 4
    print(N + d)

Solution (Python):
n,m  = map(int,input().split())
if n >= m//2:
    ans = (m//2)
else:
    ans = n+ max(0,m-n*2)//4
    
print(ans)

Solution (Python):
N, M = map(int, input().split())

if N >= M//2:
    print(M//2)
else:
    M -= 2*N
    print(N+(M//4))

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
m //= 2
if n > m:
    print(m)
else:
    print((n+m)//2)

Solution (Python):
import sys
input = sys.stdin.buffer.readline

def main():
    s,c = map(int,input().split())

    if c//2 <= s:
        print(c//2)
    else:
        rest = c-2*s
        print(s+rest//4)

if __name__ == "__main__":
    main()

Solution (Python):


from sys import stdin

n, m = map(int, stdin.readline().rstrip().split())
ans = 0

if n * 2 < m:
    ans += n
    m = m - n * 2
    ans += m // 4
else:
    ans += m // 2

print(ans)

Solution (Python):
n, m = map(int, input().split())
if n >= m // 2:
  ans = m // 2
else:
  ans = n
  rest = m - n * 2
  ans += rest // 4
print(ans)

Solution (Python):
n,m=map(int,input().split())
if m<2*n:
    print(m//2)
else:
    print(n+(m-2*n)//4)

Solution (Python):
N, M = map(int, input().split())
if 2*N <= M:
    ans = N
    M -= 2*N
    ans += M//4
else:
    ans = M//2
print(ans)

Solution (Python):

n,m = map(int,input().split())
ans = 0

if 2*n <= m:
    ans = n
    m -= 2*n
    ans += m//4
    print(ans)
else:
    ans = m // 2
    print(ans)

Solution (Python):
n, m = map(int, input().split())

if 2 * n >= m:
    print(min(n, m//2))
else:
    print(max(n, n + (m - 2 * n)//4))

Solution (Python):
def resolve():

    N,M=map(int,input().split())
    cnt=0
    if N*2>=M:
        print(M//2)
    else:
        cnt+=N
        M-=N*2
        cnt+=M//4
        print(cnt)


resolve()

Solution (Python):
def main(n: int, m: int):
    ans = 0
    
    ans += min(n, m // 2)
    m -= ans * 2

    ans += m // 4

    print(ans)


if __name__ == "__main__":
    n, m = map(int, input().split())

    main(n, m)

Solution (Python):
N, M= map(float, input().split())
if N > round(M/2):
	print(round(M/2))
else:
	c=N+(M-N*2)//4
	print(int(c))

Solution (Python):
S,C=map(int,input().split())
scc=0

if 2*S<=C:
    scc+=S
    C-=S*2
    scc+=C//4
else:
    scc=C//2
    
print(scc)

Solution (Python):
N, M = map(int, input().split())

if(2*N <= M):
    m = M-2*N
    print(N+m//4)
else:
    print(M//2)

Solution (Python):
n, m = map(int, input().split())


if m - (n*2) < 0:
    ans = m // 2
else:
    
    tmp_Scc = n

    
    tmp_amari = m - (n*2)

    
    tmp_Scc_2 = tmp_amari // 4

    ans = tmp_Scc + tmp_Scc_2

print(ans)

Solution (Python):

N,M=map(int,input().split())
ans=min(N,M//2)
if N<(M//2):
    ans+=((M//2-N)*2+(M%2))//4
print(ans)

Solution (Python):
s, c = map(int, input().split())

if 2*s >= c:
    print(c // 2)
    exit()
g = s
c -= s * 2
print(g + c//4)

Solution (Python):

n, m = map(int, input().split())

ans = 0

if 2 * n >= m:
    print(min(n, m // 2))
else:
    ans += n
    m -= 2 * n
    ans += m // 4
    print(ans)

Solution (Python):
base = input().split()
s = int(base[0])
c = int(base[1])
cnt = 0
if (s*2)<c:
    cnt+=s
    c-=s*2
    cnt+=c//4
else:
    cnt+=c//2
print(cnt)

Solution (Python):
n,m=map(int,input().split())
if n<m:
            ans=n+(m-n*2)//4
            print(ans)
elif 2*n>=m:
            ans=m//2
            print(ans)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n, m = MAP()
ans = (n * 2 + m) // 4
if ans > m // 2:
    ans = m // 2
print(ans)

Solution (Python):
n,m = map(int,input().split())
if(2*n >= m):
    print(m//2)
else:
    m -= 2*n
    print(n + (m//4))

Solution (Python):
N,M  = map(int, input().split())



if M <= 2*N: 
    print(M//2)
else:
    cnt = N
    M -= 2*N
    print(cnt+M//4)