SPOJ 6470: Finding the Kth Prime