output_description: Print the answer.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      N M
attempt: #
  # Written by NoKnowledgeGG @YlePhan
  # ('ω')
  #
  # import math
  # mod = 10**9+7
  # import itertools
  # import fractions
  # import numpy as np
  # mod = 10**4 + 7
  """def kiri(n,m):
    r_ = n / m
    if (r_ - (n // m)) > 0:
      return (n//m) + 1
    else:
      return (n//m)"""
  
  """ n! mod m 階乗
  mod = 1e9 + 7
  N = 10000000
  fac = [0] * N
  def ini():
    fac[0] = 1 % mod
    for i in range(1,N):
      fac[i] = fac[i-1] * i % mod"""
  
  """mod = 1e9+7
  N = 10000000
  pw = [0] * N
  def ini(c):
    pw[0] = 1 % mod
    for i in range(1,N):
      pw[i] = pw[i-1] * c % mod"""
  
  """
  def YEILD():
    yield 'one'
    yield 'two'
    yield 'three'
  generator = YEILD()
  print(next(generator))
  print(next(generator))
  print(next(generator))
  """
  """def gcd_(a,b):
    if b == 0:#結局はc,0の最大公約数はcなのに
      return a
    return gcd_(a,a % b) # a = p * b + q"""
  """def extgcd(a,b,x,y):
    d = a
    if b!=0:
      d = extgcd(b,a%b,y,x)
      y -= (a//b) * x
      print(x,y)
    else:
      x = 1
      y = 0
    return d"""
  
  
  def readInts():
      return list(map(int, input().split()))
  
  
  mod = 10**9 + 7
  
  
  def main():
      n, m = readInts()
      print(min(m // 2, (2 * n + m) // 4))
  
  
  if __name__ == "__main__":
      main()
  
problem_description: 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:
  
  ![9b0bd546db9f28b4093d417b8f274124.png](https://atcoder.jp/img/arc069/9b0bd546db9f28b4093d417b8f274124.png)
  
  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.
samples: [{"input": "1 6", "output": "2\n    \n\nTwo `Scc` groups can be created as follows:\n\n  * Combine two `c`-shaped pieces into one `S`-shaped piece\n  * Create two `Scc` groups, each from one `S`-shaped piece and two `c`-shaped pieces\n\n* * *"}, {"input": "12345 678901", "output": "175897"}]