Little Petya loves training spiders. Petya has a board *n* × *m* in size. Each cell of the board initially has a spider sitting on it. After one second Petya chooses a certain action for each spider, and all of them humbly perform its commands. There are 5 possible commands: to stay idle or to move from current cell to some of the four side-neighboring cells (that is, one command for each of the four possible directions). Petya gives the commands so that no spider leaves the field. It is allowed for spiders to pass through each other when they crawl towards each other in opposite directions. All spiders crawl simultaneously and several spiders may end up in one cell. Petya wants to know the maximum possible number of spider-free cells after one second.
The first line contains two space-separated integers *n* and *m* (1 ≤ *n*, *m* ≤ 40, *n*·*m* ≤ 40) — the board sizes.
1 1
0
2 3
4
4 1
2
4 2
5
4 3
8
4 4
12
1 40
26
1 1
0
1 2
1
1 3
2
1 4
2
1 5
3
1 6
4
1 7
4
1 8
5
1 9
6
1 10
6
1 11
7
1 12
8
1 13
8
1 14
9
1 15
10
1 16
10
1 17
11
1 18
12
1 19
12
1 20
13
1 21
14
1 22
14
1 23
15
1 24
16
1 25
16
1 26
17
1 27
18
1 28
18
1 29
19
1 30
20
1 31
20
1 32
21
1 33
22
1 34
22
1 35
23
1 36
24
1 37
24
1 38
25
1 39
26
1 40
26
2 1
1
2 2
2
2 3
4
2 4
5
2 5
7
2 6
8
2 7
10
2 8
11
2 9
13
2 10
14
2 11
16
2 12
17
2 13
19
2 14
20
2 15
22
2 16
23
2 17
25
2 18
26
2 19
28
2 20
29
3 1
2
3 2
4
3 3
6
3 4
8
3 5
11
3 6
13
3 7
15
3 8
17
3 9
20
3 10
22
3 11
24
3 12
26
3 13
29
4 1
2
4 2
5
4 3
8
4 4
12
4 5
14
4 6
17
4 7
21
4 8
24
4 9
26
4 10
30
5 1
3
5 2
7
5 3
11
5 4
14
5 5
18
5 6
22
5 7
26
5 8
29
6 1
4
6 2
8
6 3
13
6 4
17
6 5
22
6 6
26
7 1
4
7 2
10
7 3
15
7 4
21
7 5
26
8 1
5
8 2
11
8 3
17
8 4
24
8 5
29
9 1
6
9 2
13
9 3
20
9 4
26
10 1
6
10 2
14
10 3
22
10 4
30
11 1
7
11 2
16
11 3
24
12 1
8
12 2
17
12 3
26
13 1
8
13 2
19
13 3
29
14 1
9
14 2
20
15 1
10
15 2
22
16 1
10
16 2
23
17 1
11
17 2
25
18 1
12
18 2
26
19 1
12
19 2
28
20 1
13
20 2
29
21 1
14
22 1
14
23 1
15
24 1
16
25 1
16
26 1
17
27 1
18
28 1
18
29 1
19
30 1
20
31 1
20
32 1
21
33 1
22
34 1
22
35 1
23
36 1
24
37 1
24
38 1
25
39 1
26
40 1
26
#!/usr/bin/env python3

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

# Most efficient is gathering 5 spiders on one tile, forming a shape in the form of a + sign,
# with all spiders on the center tile and the other tiles empty.
# The + sign can tile the entire plane, by using knight moves between the center squares
# Let's generate all the coordinates of the center squares

def rotate_direction(direction):
  # Rotate a direction by 90 degrees
  (dx,dy) = direction
  return (-dy, dx)

def move(position, direction):
  # Move in a certain direction
  (x,y) = position
  (dx,dy) = direction
  return (x+dx, y+dy)

def generate_positions(start_position):
  # Generate the center positions of the + shapes, for a given starting position,
  # this is done by making a knights move each time, and we will move in an outward spiral fashion to cover the entire plane
  position = start_position
  positions = [position]
  direction = (2, 1)
  nr_steps = 1
  while (position[0] < (n+5)) or (position[1] < (m+5)): # I was too lazy to figure out what the exact bound should be; 5 will be enough
    # 1st side of the rectangular spiral:
    for i in range(nr_steps):
      position = move(position, direction)
      positions.append(position)
    direction = rotate_direction(direction)

    # 2nd side of the rectangular spiral:
    for i in range(nr_steps):
      position = move(position, direction)
      positions.append(position)
    direction = rotate_direction(direction)

    # The next (2) sides need to do a bit more knight moves, otherwise we will re-visit old positions
    nr_steps += 1

  return positions

def is_contained(position):
  # Checks whether a given position is contained in the (n,m) rectangle
  (x,y) = position
  return (x>= 0) and (y>=0) and (x < n) and (y < m)

def nr_cells_emptied(position):
  # Checks number of cells of the (n,m) rectangle that are emptied by gathering the maximum number of spiders at the given position
  if not is_contained(position):
    return 0

  to_check = [move(position, direction) for direction in [(-1,0), (1,0), (0,-1), (0,1)]]
  return len([pos for pos in to_check  if is_contained(pos)])

# Starting position is either in the corner of the rectangle, or one step removed:
answer = sum(nr_cells_emptied(pos) for pos in generate_positions((0,0)))
answer = max(answer, sum(nr_cells_emptied(pos) for pos in generate_positions((1,0))))

print(answer)
