#![allow(dead_code, unused_imports, unused_macros, non_snake_case)] use std::collections::btree_map::VacantEntry; fn main() { let mut input = Input::new(); let H = input.read::(); let W = input.read::(); let LA = input.read::(); let LB = input.read::(); let KA = input.read::(); let KB = input.read::(); let mut ans = INF; for count_hpunch in 0 ..= H { let hattacked = H.min(count_hpunch * LA); let mut ac = W; let mut wa = -1; while ac - wa > 1 { let wj = (ac + wa) / 2; let vattacked = W.min(wj * LB); let rem = H * W - hattacked * vattacked; if rem <= KA * count_hpunch + KB * wj { ac = wj; } else { wa = wj; } } let vattacked = W.min(ac * LB); if H * W <= hattacked * vattacked + count_hpunch * KA + ac * KB { ans = ans.min(count_hpunch + ac); } } println!("{}", ans); } type Int = i64; const MOD: Int = 1_000_000_007; const INF: Int = 1_000_000_000_000_000_000; const YESNO: [&'static str; 2] = ["Yes", "No"]; pub struct Input { words: std::collections::VecDeque, } impl Input { pub fn new() -> Self { use std::io::prelude::*; let mut stdin = std::io::stdin(); let mut input = String::new(); stdin.read_to_string(&mut input).unwrap(); let words = input.split_ascii_whitespace().map(str::to_string).collect(); Self { words } } pub fn read(&mut self) -> T { let res = self.words.pop_front().unwrap().parse(); if let Ok(r) = res { r } else { panic!("read() failed") } } } fn yes() { println!("{}", YESNO[0]); } fn no() { println!("{}", YESNO[1]); } fn yesno(c: bool) { println!("{}", if c { YESNO[0] } else { YESNO[1] }); }