ural 1044. Simple DP