use std::io::Read; fn main() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let v: Vec = s.split_whitespace().flat_map(str::parse).collect(); let mut p = true; let a = v .chunks(2) .filter(|&v| { let q = p; p = (v[0] - 1) % (v[1] + 1) != 0; p ^ q }) .count(); println!("{}", a) }