Playing with Paper

CodeForces - 527A