n=gets.to_i a=[2,2] (2..2e3).map{|i|a<<(a[i-1]+a[i-2]<<1)%1000} p a[n<4?n:n%600+600]-~n%2