fun main(){ val (a, b, n, m) = readLine()!!.split(" ").map{it.toLong()} println(with(Math.min(a,b)){this+(a-this)/(n+1)+(b-this)/(m+1)}) }