/*
Initialize the SDK first, and then run it one by one;
Pay attention to the changes in the I, j, and k ranges;
Reference Daniel
Generating
Function)-TankyWoo
*/
# Include <iostream> using namespace std; int a [10005], B [10005]; int main () {int num1, num2, num3; while (cin> num1> num2> num3) {if (num1 = 0 & num2 = 0 & num3 = 0) {break ;} int sum = num1 * 1 + num2 * 2 + num3 * 5; for (int I = 0; I <= sum; I ++) // expression initialization {a [I] = B [I] = 0 ;}for (int I = 0; I <= num1; I ++) {a [I] = 1 ;}for (int I = 0; I <= num1; I ++) for (int j = 0; j <= num2 * 2; j + = 2) {B [j + I] + = a [I] ;}for (int I = 0; I <= num1 * 1 + num2 * 2; I ++) {a [I] = B [I]; B [I] = 0;} for (int I = 0; I <= num1 * 1 + num2 * 2; I ++) for (int j = 0; j <= num3 * 5; j + = 5) {B [j + I] + = a [I] ;}for (int I = 0; I <= sum; I ++) {a [I] = B [I];} int p = 0; for (int I = 0; I <= sum; I ++) {if (! A [I]) {cout <I <endl; p = 1; break ;}} if (! P) {cout <sum + 1 <endl ;}}}