#include using namespace std; int buy_ice_box(int n, int *box){ int cost = 0; int free = 0; for (int i = 0; i < n; i++){ int ice = box[i]; if (free > 0){ free -= 1; } else { cost += 1; } if (ice == 2){ free += 2; } else if (ice == 1){ free += 1; } } return cost; } int buy_ice(int k, int *box){ int cost = 0; int free = 0; for (int i = 0; i < k; i++){ int ice = box[i]; if (free > 0){ free -= 1; } else { cost += 1; } if (ice == 2){ free += 2; } else if (ice == 1){ free += 1; } } return cost; } int main(){ int n, k; cin >> n >> k; int box[n]; int cost_sum = 0; int cost_box = buy_ice_box(n, box); cost_sum += (k / n) * cost_box; cost_sum += buy_ice(k % n, box); cout << cost_sum << endl; return 0; }