use std::io::{read_to_string, stdin}; fn main() { let temp = read_to_string(stdin()).unwrap(); let mut iter = temp .split_ascii_whitespace() .map(|x| x.parse::().unwrap()); let n = iter.next().unwrap() as usize; let mut chems = (0..n) .map(|_| (iter.next().unwrap(), iter.next().unwrap())) .collect::>(); chems.sort_by_key(|x| x.1); let mut pin = chems[0].1; let mut cnt = 1; for (x, y) in chems { if x > pin { cnt += 1; pin = y; } } println!("{}", cnt); }