output_description: Print the minimum possible value of S_{max} - S_{min}.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      H W
attempt: #!/usr/bin/env python3
  # -*- coding: utf-8 -*-
  """
  Created on 2019/3/24
  Solved on 2019/3/
  @author: shinjisu
  """
  
  
  # ABC 062 C - Chocolate Bar
  def getIntList():
      return [int(x) for x in input().split()]
  
  
  def zeros(n):
      return [0] * n
  
  
  def zeros2(n, m):
      return [zeros(m) for i in range(n)]  # obsoleted zeros((n, m))で代替
  
  
  ALPHABET = [chr(i + ord("a")) for i in range(26)]
  DIGIT = [chr(i + ord("0")) for i in range(10)]
  N1097 = 10**9 + 7
  INF = 10**18
  
  
  class Debug:
      def __init__(self):
          self.debug = True
  
      def off(self):
          self.debug = False
  
      def dmp(self, x, cmt=""):
          if self.debug:
              if cmt != "":
                  print(cmt, ":  ", end="")
              print(x)
          return x
  
  
  def divideStraight3(leng, other):
      long = (leng + 2) // 3
      short = leng // 3
      return long * other, short * other
  
  
  def prob():
      d = Debug()
      d.off()
      H, W = getIntList()
      d.dmp((H, W), "H, W")
  
      # 縦か横の分割
      large1 = (H + 2) // 3 * W
      small1 = H // 3 * W
      large2 = (W + 2) // 3 * H
      small2 = W // 3 * H
      if large1 - small1 < large2 - small2:
          large, small = large1, small1
      else:
          large, small = large2, small2
      d.dmp((large, small), "large, small")
      cand = large - small
  
      # 縦及び横の分割
      area = H * W
      d.dmp((area), "area")
      #    for i in range(area//large,  area//small+1):
      for i in range(max(1, min(H, W) // 3), (max(H, W) + 1) // 2):
          # d.dmp((i), 'i')
          div1 = i * W
          div2 = (H - i) * (W // 2)
          div3 = (H - i) * ((W + 1) // 2)
          # d.dmp((div1, div2, div3), 'div1, div2, div3')
          cand0 = max(div1, div2, div3) - min(div1, div2, div3)
          # d.dmp((cand0), 'cand0')
          cand = min(cand, cand0)
          div1 = i * H
          div2 = (W - i) * (H // 2)
          div3 = (W - i) * ((H + 1) // 2)
          # d.dmp((div1, div2, div3), 'div1, div2, div3')
          cand0 = max(div1, div2, div3) - min(div1, div2, div3)
          # d.dmp((cand0), 'cand0')
          cand = min(cand, cand0)
          # d.dmp((cand), 'cand')
      return cand
  
  
  ans = prob()
  if ans is None:
      pass
  elif type(ans) == tuple and ans[0] == 1:  # 1,ans
      for elm in ans[1]:
          print(elm)
  else:
      print(ans)
  
problem_description: Statement
  
  There is a bar of chocolate with a height of H blocks and a width of W blocks.
  Snuke is dividing this bar into exactly three pieces. He can only cut the bar
  along borders of blocks, and the shape of each piece must be a rectangle.
  
  Snuke is trying to divide the bar as evenly as possible. More specifically, he
  is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the
  number of blocks contained) of the largest piece, and S_{min} is the area of
  the smallest piece. Find the minimum possible value of S_{max} - S_{min}.
samples: [{"input": "3 5", "output": "0\n    \n\nIn the division below, S_{max} - S_{min} = 5 - 5 = 0.\n\n![2a9b2ef47b750c0b7ba3e865d4fb4203.png](https://atcoder.jp/img/arc074/2a9b2ef47b750c0b7ba3e865d4fb4203.png)\n\n* * *"}, {"input": "4 5", "output": "2\n    \n\nIn the division below, S_{max} - S_{min} = 8 - 6 = 2.\n\n![a42aae7aaaadc4640ac5cdf88684d913.png](https://atcoder.jp/img/arc074/a42aae7aaaadc4640ac5cdf88684d913.png)\n\n* * *"}, {"input": "5 5", "output": "4\n    \n\nIn the division below, S_{max} - S_{min} = 10 - 6 = 4.\n\n![eb0ad0cb3185b7ae418e21c472ff7f26.png](https://atcoder.jp/img/arc074/eb0ad0cb3185b7ae418e21c472ff7f26.png)\n\n* * *"}, {"input": "100000 2", "output": "1\n    \n\n* * *"}, {"input": "100000 100000", "output": "50000"}]