# -*- coding:utf-8 -*- if __name__ == "__main__": win_num = 0 for i in xrange(1000): n,k = map(int,raw_input().split()) if n % (k+1) == 1: win_num += 1 else: break print win_num