L, M, N = map(int, input().split()) # 贪心策略:1円 -> 5円兑换 M += N // 25 # 贪心策略:5円 -> 10円兑换 L += M // 4 # 输出最终无法继续兑换的硬币总数 print(L % 10 + M % 4 + N % 25)