Fast solution to 164