def root a
	return a if @p[a] == a
	return (@p[a] = root(@p[a]))
end

def isSameSet a, b
	return root(a) == root(b)
end

def unite a, b
	@p[root(a)] = root(b)
end

@fib=[1,1]
n=0
def f n
	return if n >= 1010
	@fib.push @fib[-1]+@fib[-2]
	f n+1
end
f 1

while true
	arg=gets
	break if arg == nil
	v,d=arg.split(" ").map{|e|e.to_i}
	
	@nowFib = @fib[(2..v+1)]
	@nowFib=@nowFib.map{|e|e%1001}
	@nowFib.sort!
	@p=[]
	v.times{|t|@p.push t}
	(v-1).times{|t|
		unite(t+1, t) if (@nowFib[t+1]-@nowFib[t]) < d
	}
	p @p.uniq.count
end