Let's calculate how many tiles can be placed in height — ⌊kn⌋, and in width — ⌊km⌋. Then we can cover the entire area with \lfloor \frac{n}{k} \rfloor \times \lfloor \frac{m}{k} \rfloor tiles.