#! ruby # yukicoder My Practice # author: Leonardone @ NEETSDKASU count = 0 1000.times do |i| n, k = gets.split.map(&:to_i) if k >= n - 1 count += 1 elsif n % (k + 1) != 1 count += 1 end end puts count =begin 後方から Lose S G S G S G S 1 K 1 K 1 K 1 (1+K)*d+1==N Win G S G S G S 1 K 1 K 1 X(1~K) (1+K)*d+1+X==N N K Win 4 2 G 5 2 S 5 3 G 6 2 S 6 3 S 6 4 G 7 2 G 7 3 S 7 4 S 7 5 G N=2 K>=3 S G 1 2 N=3 K>=2 S G 12 3 N=4 K=2 S G S 1 23 4 N=4 K>=3 S G 123 4 N=5 K=2 S G S G 1 2 34 5 N=5 K=3 S G S 1 234 5 N=5 K>=4 1234 5 N=6 K=2 S G S G 12 3 45 6 N=6 K=3 S G S G 1 2 345 6 N=6 K=4 S G S 1 2345 6 N=6 K>=5 S G 12345 6 N=7 K=2 S G S G S 1 23 4 56 7 N=7 K=3 S G S G 12 3 456 7 N=7 K=4 S G S G 1 2 3456 7 N=7 K=5 S G S 1 23456 7 N=7 K>=6 S G 123456 7 N=8 K=2 S G S G S G 1 2 34 5 67 8 N=8 K=3 S G S G 123 4 567 8 N=8 K=4 S G S G 12 3 4567 8 =end