update spoj  problem 4