#include <stdio.h> int main() { int one, two, three, four, five, six; int num = 0; while (scanf(“%d%d%d%d%d%d”, &one, &two, &three, &four, &five, &six) == 6) { if (one == 0 && two == 0 && three == 0 && four == 0 && five == 0 && six == 0) { break; } num = six; num += five; if (one > five * 11) { one -= five * 11; } else { one = 0; } num += four; if (two > four * 5) { two -= four * 5; } else { if (one > four * 5 * 4 – two * 4) { one -= four * 5 * 4 – two * 4; } else { one = 0; } two = 0; } num += three / 4; three = three % 4; if (three == 1) { if (two > 5) { two -= 5; if (one > 7) { one -= 7; } else { one = 0; } } else { if (one > 27 – two * 4) { one -= 27 – two * 4; } else { one = 0; } two = 0; } ++num; } if (three == 2) { if (two > 3) { two -= 3; if (one > 6) { one -= 6; } else { one = 0; } } else { if (one > 18 – two * 4) { one -= 18 – two * 4; } else { one = 0; } two = 0; } ++num; } if (three == 3) { if (two > 1) { two -= 1; if (one > 5) { one -= 5; } else { one = 0; } } else { if (one > 9 – two * 4) { one -= 9 – two * 4; } else { one = 0; } two = 0; } ++num; } num += two / 9; two = two % 9; if (two) { if (one > 36 – two * 4) { one -= 36 – two * 4; } else { one = 0; } ++num; } num += one / 36; if (one % 36) { ++num; } printf(“%d\n”, num); } return 0; }