Case 1: 0
Case 2: 1
Case 3: impossible
Case 4: 7
Case 5: impossible
