import sys def find_sum_row(buf): sum_row = [0, 0, 0] for i in range(len(buf)): row = buf[i].split() for m in row: sum_row[i] += int(m) return sum_row def find_sum_col(buf): sum_col = [0, 0, 0] for i in range(len(buf)): for j in range(len(buf)): sum_col[i] += int(buf[j].split()[i]) for i in range(len(sum_col)): if sum_col[i] != 15: return i buf = [] while True: line = sys.stdin.readline().strip('\n') if line: buf.append(line) else: break if buf: sum_row = find_sum_row(buf) for i in range(len(sum_row)): if sum_row[i] != 15: row = i diff = 15 - sum_row[i] col = find_sum_col(buf) print(diff)