use std::io::{self, BufReader, Read, Stdin}; use std::str::FromStr; use std::string::String; #[derive(Debug)] pub struct Scanner { reader: BufReader, } fn scanner() -> Scanner { Scanner::new(io::stdin()) } impl Scanner { pub fn new(read: R) -> Scanner { Scanner { reader: BufReader::new(read), } } pub fn next_str(&mut self) -> Option { let mut buf = [0; 1]; let size = self.reader.read(&mut buf).unwrap(); if size == 0 { None {} } else { let first = self.skip_whitespace(&mut buf); if first.is_none() { return None {}; } let mut v = vec![buf[0]]; loop { let size = self.reader.read(&mut buf).unwrap(); if size == 0 || buf[0].is_ascii_whitespace() { break; } v.push(buf[0]); } Some(String::from_utf8(v).unwrap()) } } pub fn next_line(&mut self) -> Option { let mut buf = [0; 1]; let mut v: Vec = vec![]; let mut size = self.reader.read(&mut buf).unwrap(); if size == 0 { return None {}; } loop { if size == 0 || char::from(buf[0]) == '\n' { return Some(String::from_utf8(v).unwrap()); } v.push(buf[0]); size = self.reader.read(&mut buf).unwrap(); } } pub fn next_vec(&mut self, size: u32) -> Vec { let mut v: Vec = vec![]; for _ in 0..size { let token = self.next_str().unwrap(); v.push(S::from_str(&token).ok().unwrap()); } v } pub fn next_as(&mut self) -> Option { if let Some(s) = self.next_str() { if let Ok(v) = S::from_str(&s) { return Some(v); } } None {} } pub fn next_i32(&mut self) -> i32 { self.next_as::().unwrap() } pub fn next_i64(&mut self) -> i64 { self.next_as::().unwrap() } pub fn next_f32(&mut self) -> f32 { self.next_as::().unwrap() } pub fn next_f64(&mut self) -> f64 { self.next_as::().unwrap() } fn skip_whitespace(&mut self, mut buf: &mut [u8]) -> Option { loop { if !buf[0].is_ascii_whitespace() { return Some(buf[0]); } let size = self.reader.read(&mut buf).unwrap(); if size == 0 { return None {}; } } } } fn main() { let mut sc = scanner(); let a = sc.next_i32(); let b = sc.next_i32(); let c = sc.next_i32(); let d = sc.next_i32(); let dur = b + (31 - a); let ans = if c <= dur { 1 } else if d <= dur { 2 } else { 3 }; println!("{}", ans); }