m, d, total = [int(v) for v in input().split(" ")] first = m + 10 * d c_list = [ i + (total-i) * 10 for i in range(total+1)] ans = -1 for i in c_list: if first > i: ans = first - i break print(ans)