#include int main(void) { long long int i, P, N, K, win, lose, turn; scanf("%lld", &P); turn = 1; win = 0; lose = 0; for(i = 0;i < P;i++){ scanf("%lld%lld", &N, &K); if(N % (K + 1) == 1){ if(turn == 1)turn = 0; else turn = 1; } else{ if(turn == 1)win++; } } printf("%lld\n", win); return 0; }