Shortest solution I made on SPOJ. :) One liner in Ruby