#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: u32 = 1_000_000_007;
const INF: i64 = std::i64::MAX;

pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

use std::cmp::Ordering;

/// Equivalent to std::lowerbound and std::upperbound in c++
pub trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    // 配列a内のv以上の最小のindex
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
    // 配列a内のvより大きいの最小のindex
    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}

fn swap(a: usize, b: usize, sv: &mut [char], tv: &mut [char]) {
	let tmp = sv[a];
	sv[a] = tv[b];
	tv[b] = tmp;
}

fn solve() {
	let n = read!(i64);
	let mut sum = 0;
	let mut v = vec![];
	if n==1 {
		println!("{}", 1);
		return;
	}
	for i in 2..((n as f64).sqrt() as i64+1) {
		if n%i==0 {
			sum+=2;
			v.push(i);
			v.push(n%i);
		}
	}
	if sum==0 {
		println!("{}", n);
		return;
	}
	let mi = v[0];
	let mut flag = true;
	for &i in &v {
		if i%mi!=0 {flag=false;}
	}
	if !flag {println!("{}", 1);}
	else{ println!("{}", mi);}

}

fn run() {
    solve();
}


#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        $(writeln!(stderr(), "{} = {:?}", stringify!($arg), $arg).unwrap());*
    };
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn solve(N: i64, K: i64) -> i64 {
    let r = min(N + 1, K);
    let l = min(r, K / 2 + 1);
    r - l
}

fn main() {
    println!("{}", 0)
}

#[cfg(test)]
mod tests {
    use super::solve;

    #[test]
    fn tests() {
        assert_eq!(solve(8, 5), 2);
        assert_eq!(solve(8, 15), 1);
        assert_eq!(solve(7, 20), 0);
        assert_eq!(solve(1000000000000, 1000000000001), 500000000000);

        assert_eq!(solve(1, 1), 0);
        assert_eq!(solve(2, 3), 1);
    }
}


fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let s: Vec<char> = it.next().unwrap().chars().collect();
    let mut dp = vec![vec![0; n]; n];
    for len in 1..=n {
        for l in 0..=(n - len) {
            let r = l + len - 1;
            dp[l][r] = len;
            if l + 1 < n {
                dp[l][r] = dp[l + 1][r] + 1;
            }
            for k in (l + 1)..=r {
                if s[l] == s[k] {
                    dp[l][r] = std::cmp::min(dp[l][r], dp[l + 1][k - 1] + dp[k][r]);
                }
            }
        }
    }
    println!("{}", dp[0][n - 1]);
}

fn main() {
    run();
}


// This code is licensed under the terms of Apache-2.0 <http://www.apache.org/licenses/LICENSE-2.0> or MIT License <https://opensource.org/licenses/MIT>, at your choice.

use crate::comprog_lib::scanner::Scanner;
use std::cmp::min;
use std::io::{self, Read, Write};
pub fn solve<R: Read, W: Write>(read: R, out: &mut W) -> io::Result<()> {
	let mut sc = Scanner::from(read);
	let n = sc.usize();
	let s = sc.token();
	let mut next = vec![[n; 26]; n + 1];
	for i in (0..n).rev() {
		next[i] = next[i + 1].clone();
		next[i][(s[i] - b'a') as usize] = i;
	}
	let mut dp = vec![vec![std::i32::MAX; n + 1]; n + 1];
	for i in 0..=n {
		dp[i][i] = 0;
	}
	for len in 1..=n {
		for l in 0..=n - len {
			let r = l + len;
			dp[l][r] = (0..26)
				.map(|a| {
					let mut sum = 0;
					let mut k = l as isize - 1;
					while k < r as isize {
						let nk = min(next[(k + 1) as usize][a], r);
						sum += dp[(k + 1) as usize][nk];
						k = nk as isize;
					}
					sum
				})
				.min()
				.unwrap() + 1;
		}
	}
	let ans = dp[0][n];
	writeln!(out, "{}", ans)?;
	Ok(())
}
fn main() {
	let stdin = io::stdin();
	let mut stdout = io::BufWriter::new(io::stdout());
	solve(stdin.lock(), &mut stdout).unwrap_or_else(|e| {
		drop(stdout);
		writeln!(io::stderr(), "{}", e).ok();
		std::process::exit(1);
	});
}
mod comprog_lib {
	// comprog_lib-0.1.0
	pub mod scan_buf {
		use std::io::{self, Read};
		#[derive(Debug, Clone)]
		pub struct ScanBuf {
			buf: Vec<u8>,
			pos: usize,
			end: usize,
		}
		#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
		pub struct ScanRange(pub usize, pub usize);
		impl ScanRange {
			pub fn slice(self, buf: &ScanBuf) -> &[u8] {
				&buf.buf[self.0..self.1]
			}
		}
		impl ScanBuf {
			pub fn new(initial_capacity: usize) -> Self {
				ScanBuf { buf: vec![0; initial_capacity], pos: 0, end: 0 }
			}
			pub fn scan<R: Read, P: FnMut(u8) -> bool>(
				&mut self,
				mut reader: R,
				mut pred: P,
			) -> io::Result<ScanRange> {
				let start = self.pos;
				loop {
					if self.pos >= self.end {
						if self.pos >= self.buf.len() {
							let new_len = std::cmp::max(self.buf.len(), 1) * 2;
							self.buf.resize(new_len, 0);
						}
						self.end += match reader.read(&mut self.buf[self.pos..]) {
							Ok(0) => return Ok(ScanRange(start, self.pos)),
							Ok(n) => n,
							Err(ref e) if e.kind() == io::ErrorKind::Interrupted => 0,
							Err(e) => return Err(e),
						};
					}
					assert!(self.end <= self.buf.len());
					while self.pos < self.end {
						if pred(self.buf[self.pos]) {
							return Ok(ScanRange(start, self.pos));
						}
						self.pos += 1;
					}
				}
			}
		}
	}
	pub mod scanner {
		use crate::comprog_lib::scan_buf::{ScanBuf, ScanRange};
		use std::io::Read;
		#[derive(Debug, Clone)]
		pub struct Scanner<R> {
			pub reader: R,
			pub buf: ScanBuf,
		}
		impl<R: Read> From<R> for Scanner<R> {
			fn from(r: R) -> Self {
				Scanner { reader: r, buf: ScanBuf::new(8192) }
			}
		}
		impl<R: Read> Scanner<R> {
			pub fn scan<P: FnMut(u8) -> bool>(&mut self, pred: P) -> ScanRange {
				self.buf.scan(&mut self.reader, pred).unwrap()
			}
			fn digits(&mut self) -> (bool, &[u8]) {
				self.scan(|b| b' ' < b);
				let mut negative = false;
				self.scan(|b| b != b'-' || std::mem::replace(&mut negative, true));
				let digits = self.scan(|b| b < b'0' || b'9' < b);
				(negative, digits.slice(&self.buf))
			}
			pub fn token_range(&mut self) -> ScanRange {
				self.scan(|b| b' ' < b);
				self.scan(|b| b <= b' ')
			}
			pub fn token(&mut self) -> Vec<u8> {
				self.token_range().slice(&self.buf).to_owned()
			}
		}
		macro_rules! impl_scan_int { ($($name:ident),*) => { impl<R: Read> Scanner<R> { $(       #[allow(unused)] pub fn $name(&mut self) -> $name { let (neg, digits) = self.digits(); if !neg { digits.iter().fold($name::default(), |x, b| x * 10 + $name::from(b - b'0')) } else { digits.iter().fold($name::default(), |x, b| x * 10 - $name::from(b - b'0')) } } )* } } }
		impl_scan_int!(u32, i32, u64, i64, usize);
	}
}
// Module comprog_lib contains code from comprog_lib <https://github.com/pcpthm/comprog_lib> licensed under Apache-2.0 OR MIT
// Built by comprog-0.1.0 <https://github.com/pcpthm/comprog_tools>


use std::io;
use std::cmp;

fn main() {
    let n = read_one::<usize>();
    let an = read::<usize>();
    let mut ans = 100_000_000;

    for i in 0..n { // i + 1 : x_th
        let mut tmp = 0;
        for j in 0..n { // a_th
            tmp += (an[j] as isize) * ((i as isize - j as isize).abs()) * 2; // x -> a
            tmp += (an[j] * j * 2) as isize; // a -> ground
            tmp += (2 * i) as isize; // g -> x
        }
        ans = cmp::min(ans, tmp);
    }
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}


use std::io;

fn main() {
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer)
        .expect("Failed to read line");

    let num_letters = buffer.trim().parse::<i32>().expect("parse error");
    if num_letters == 0 {
        println!("0");
        return;
    }

    buffer.clear();
    io::stdin().read_line(&mut buffer)
        .expect("Failed to read line");
    let splitted: Vec<&str> = buffer.trim().split('W').collect();

    for sub in &splitted {
        if sub.len() != 0 {
            print!("{} ", sub.len());
        }
    }
    println!();
}


//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: u64,
        a: u64,
        b: u64,
        p: u64,
        q: u64,
    }
    let z = n / (a * b);
    let x = n / a - z;
    let y = n / b - z;
    let ans = p * x + q * y + std::cmp::max(p, q) * z;
    println!("{}", ans);
}

fn main() {
    run();
}


macro_rules! read_line {
    ($v:ident) => {
        let mut temp = String::new();
        std::io::stdin().read_line(&mut temp).unwrap();
        let $v = temp;
    };
    (var, $t:ty, $($v:ident), *) => {
        read_line!(input_line);
        let mut iter = parse_token!($t, input_line);
        $(
            let $v = iter.next().unwrap();
        )*
    };
    (vec, $t:ty, $v:ident) => {
        read_line!(input_line);
        let iter = parse_token!($t, input_line);
        let $v: Vec<$t> = iter.collect();
    };
    ($($v:ident; $t:ty), *) => {
        read_line!(input_line);
        let mut iter = input_line.split_whitespace();
        $(
            let $v: $t = iter.next().unwrap().parse().unwrap();
        )*
    };
}

macro_rules! parse_token {
    ($t:ty, $e:expr) => {
        $e.split_whitespace().map(|x| x.parse::<$t>().unwrap());
    };
}

fn main() {
    read_line!(month; usize, start_weekday; usize);
    let days = match month {
        1 | 3 | 5 | 7 | 8 | 10 | 12 => 31,
        4 | 6 | 9 | 11 => 30,
        2 => 28, // Assume that the year is non-leap.
        _ => 0
    };
    let days_first_column = 7 - start_weekday + 1;
    let days_remaining = days - days_first_column;
    let columns = (days_remaining as f64 / 7.0) as usize + 1;
    println!("{}", columns);
}


  let mut buffer = String::new();
  std::io::stdin().read_line(&mut buffer).expect("Failed");

  let mut num = buffer.trim().parse::<i64>().unwrap();
  let mut bills = 0;

  while num > 0 {
    if num >= 100 {
      num -= 100;
      bills += 1;
    }
    else if num >= 20 {
      num -= 20;
      bills += 1;
    }
    else if num >= 10 {
      num -= 10;
      bills += 1;
    }
    else if num >= 5 {
      num -= 5;
      bills += 1;
    }
    else if num >= 1 {
      num -= 1;
      bills += 1;
    }
  }

  println!("{}", bills);


fn main() {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Err");

    let summ: u64 = buffer.trim().parse().unwrap();

    println!("{}", foo(summ));

}

fn foo(summ: u64) -> u64 {
    if summ < 5 {return summ;}
    else if summ < 10 {return summ/5 + foo(summ - 5*(summ/5));}
    else if summ < 20 {return summ/10 + foo(summ - 10*(summ/10));}
    else if summ < 50 {return summ/20 + foo(summ - 20*(summ/20));}
    else if summ < 100 {return summ/50 + foo(summ - 50*(summ/50));}
    else {return summ/100 + foo(summ - 100*(summ/100));}
}


use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let mut n: i32 = input.trim().parse().unwrap();

    // 1, 5, 10, 20,  100
    let mut counter = 0;
    while n > 1 {
        if n < 5 {
            counter = counter + n;
            n = 0;
        } else {
            if n >= 100 {
                counter = counter + n / 100;
                n = n % 100;
            } else if n >= 20 {
                counter = counter + n / 20;
                n = n % 20;
            } else if n >= 10 {
                counter = counter + n / 10;
                n = n % 10;
            } else if n >= 5 {
                counter = counter + n / 5;
                n = n % 5;
            }
        }
    }

    println!("{}", counter);
}


fn main() {
   let mut s = String::new();
   std::io::stdin().read_line(&mut s).unwrap();
   let ints:Vec<i32> = s.split_whitespace().map(|x| x.parse().unwrap()).collect();
   let (n,m)=(ints[0], ints[1]);
   if n < m {
       println!("-1");
   } else {
      for i in (0..n/2).rev() {
           let j = n-i*2;
           if (i+j)%m == 0 {
             println!("{}", i+j);
             break;
           }
      }
   }
}


struct Scan {
    buffer: std::collections::VecDeque<String>
}

impl Scan {
    fn new() -> Scan {
        Scan { buffer: std::collections::VecDeque::new() }
    }

    fn next<T: std::str::FromStr>(&mut self)-> T {
        loop {
            if let Some(token) = self.buffer.pop_front() {
                break token.parse::<T>().ok().unwrap();
            }
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).expect("Fail to read");
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }

}

fn _main() {
    let mut scan = Scan::new();
    // e.g: 3 -> 3 + (2*(2-1)+1) + 1
    // e.g: 4 -> 4 + 3 + 2 + 1 =
    let n: isize = scan.next();
    let mut result: isize = n + 1;
    let mut i = n-1;
    while i >= 2 {
        result += i*(n-i) + 1;
        i -= 1;
    }
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(1<<23).spawn(_main).unwrap().join().unwrap();
}


use std::io::*;
use std::str::FromStr;

fn main() {
    let stdin = stdin();
    let mut sc = Scanner::new(stdin.lock());
    let k = sc.next::<u32>();
    let n = sc.next::<u32>();
    let s = sc.next::<u32>();
    let p = sc.next::<u32>();

    for i in 0..10000 + 1 {
        if n <= s * ((i * p) / k) {
            println!("{}", i);
            break;
        }
    }
}

pub struct Scanner<B> {
    reader: B,
    buffer: Vec<String>,
}

impl<B: BufRead> Scanner<B> {
    pub fn new(reader: B) -> Self {
        Self {
            reader,
            buffer: Vec::new(),
        }
    }

    pub fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: ::std::fmt::Debug,
    {
        if let Some(front) = self.buffer.pop() {
            front.parse::<T>().expect(&front)
        } else {
            let mut input = String::new();
            self.reader.read_line(&mut input).expect("Line not read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
            self.next()
        }
    }
}


use std::io::{self, BufRead};

type Point = (i32, i32);
type Seg = (Point, Point);

fn cm(base: &Point, a: &Point, b: &Point) -> i32 {
    let debug = false;
    if debug { println!("base {:?}, a {:?}, b {:?}", base, a, b) }
    return (a.0 - base.0)*(b.1 - base.1) - (a.1 - base.1)*(b.0 - base.0);
}

fn intersect(a: &Seg, b: &Seg) -> bool {
    let b0 = cm(&a.0, &a.1, &b.0);
    let b1 = cm(&a.0, &a.1, &b.1);
    if b0 == 0 || b1 == 0 { return true }
    let a0 = cm(&b.0, &b.1, &a.0);
    let a1 = cm(&b.0, &b.1, &a.1);
    if a0 == 0 || a1 == 0 { return true }
    return ((a0 > 0 && a1 < 0) || (a0 < 0 && a1 > 0))
        && ((b0 > 0 && b1 < 0) || (b0 < 0 && b1 > 0));
}

fn main() {
    let debug = false;
    let stdin: io::Stdin = io::stdin();
    let mut lines: io::Lines<io::StdinLock> = stdin.lock().lines();

    let next_line = lines.next()
        .unwrap() // Option<Result> { Some(Result), None }
        .unwrap(); // Result<String, io::Error> { Ok(String), Err(io::Error) }

    let square_a: Vec<_> = next_line
        .trim()
        .split(' ')
        .map(|n| {
            n.parse::<i32>().unwrap()
        })
        .collect();

    let next_line = lines.next()
        .unwrap() // Option<Result> { Some(Result), None }
        .unwrap(); // Result<String, io::Error> { Ok(String), Err(io::Error) }

    let square_b: Vec<_> = next_line
        .trim()
        .split(' ')
        .map(|n| {
            n.parse::<i32>().unwrap()
        })
        .collect();

    // any a inside b
    if debug { println!("\n\n a inside b ?? \n\n") }
    for a_i in 0..4 {
        let a = (square_a[2*a_i], square_a[2*a_i+1]);
        let mut left = false;
        let mut right = false;
        if debug { println!("POINT a choosen") }
        for i in 0..4 {
            let base = (square_b[2*i], square_b[2*i+1]);
            let j = (i+1) % 4;
            let b = (square_b[2*j], square_b[2*j+1]);
            if debug { println!("-------------------") }
            let cmv = cm(&base, &b, &a);
            if debug { println!("cmv {}", cmv) }
            if cmv > 0 { left = true; }
            if cmv < 0 { right = true; }
        }
        if !left || !right {
            println!("YES");
            return;
        }
    }

    // any b inside a
    if debug { println!("\n\n b inside a ?? \n\n") }
    for b_i in 0..4 {
        let b = (square_b[2*b_i], square_b[2*b_i+1]);
        let mut left = false;
        let mut right = false;
        if debug { println!("POINT b choosen") }
        for i in 0..4 {
            let base = (square_a[2*i], square_a[2*i+1]);
            let j = (i+1) % 4;
            let a = (square_a[2*j], square_a[2*j+1]);
            if debug { println!("-------------------") }
            let cmv = cm(&base, &a, &b);
            if debug { println!("cmv {}", cmv) }
            if cmv > 0 { left = true; }
            if cmv < 0 { right = true; }
        }
        if !left || !right {
            println!("YES");
            return;
        }
    }

    // check intersect
    for a_i in 0..4 {
        let a_a = (square_a[2*a_i], square_a[2*a_i+1]);
        let a_j = (a_i + 1) % 4;
        let a_b = (square_a[2*a_j], square_a[2*a_j+1]);
        let seg_a = (a_a, a_b);

        for i in 0..4 {
            let b_a = (square_b[2*i], square_b[2*i+1]);
            let j = (i+1) % 4;
            let b_b = (square_b[2*j], square_b[2*j+1]);
            let seg_b = (b_a, b_b);
            if intersect(&seg_a, &seg_b) {
                println!("YES");
                return;
            }
        }
    }

    println!("NO");
}


se std::io::{self, BufRead};

type Point = (i32, i32);
type Seg = (Point, Point);

fn cm(base: &Point, a: &Point, b: &Point) -> i32 {
    let debug = false;
    if debug { println!("base {:?}, a {:?}, b {:?}", base, a, b) }
    return (a.0 - base.0)*(b.1 - base.1) - (a.1 - base.1)*(b.0 - base.0);
}

fn inx(a: i32, b: i32, x: i32) -> bool {
    return (b >= a && x >= a && x <= b) || (b <= a && x <= a && x >= b);
}

fn ins(pa: &Point, pb: &Point, px: &Point) -> bool {
    return inx(pa.0, pb.0, px.0) && inx(pa.1, pb.1, px.1);
}

fn intersect(a: &Seg, b: &Seg) -> bool {
    let b0 = cm(&a.0, &a.1, &b.0);
    if b0 == 0 && ins(&a.0, &a.1, &b.0) { return true; }
    let b1 = cm(&a.0, &a.1, &b.1);
    if b1 == 0 && ins(&a.0, &a.1, &b.1) { return true; }
    let a0 = cm(&b.0, &b.1, &a.0);
    if a0 == 0 && ins(&b.0, &b.1, &a.0) { return true; }
    let a1 = cm(&b.0, &b.1, &a.1);
    if a1 == 0 && ins(&b.0, &b.1, &a.1) { return true; }
    return ((a0 > 0 && a1 < 0) || (a0 < 0 && a1 > 0))
        && ((b0 > 0 && b1 < 0) || (b0 < 0 && b1 > 0));
}

fn main() {
    let debug = false;
    let stdin: io::Stdin = io::stdin();
    let mut lines: io::Lines<io::StdinLock> = stdin.lock().lines();

    let next_line = lines.next()
        .unwrap() // Option<Result> { Some(Result), None }
        .unwrap(); // Result<String, io::Error> { Ok(String), Err(io::Error) }

    let square_a: Vec<_> = next_line
        .trim()
        .split(' ')
        .map(|n| {
            n.parse::<i32>().unwrap()
        })
        .collect();

    let next_line = lines.next()
        .unwrap() // Option<Result> { Some(Result), None }
        .unwrap(); // Result<String, io::Error> { Ok(String), Err(io::Error) }

    let square_b: Vec<_> = next_line
        .trim()
        .split(' ')
        .map(|n| {
            n.parse::<i32>().unwrap()
        })
        .collect();

    // any a inside b
    for a_i in 0..4 {
        let a = (square_a[2*a_i], square_a[2*a_i+1]);
        let mut left = false;
        let mut right = false;
        for i in 0..4 {
            let base = (square_b[2*i], square_b[2*i+1]);
            let j = (i+1) % 4;
            let b = (square_b[2*j], square_b[2*j+1]);
            let cmv = cm(&base, &b, &a);
            if cmv > 0 { left = true; }
            if cmv < 0 { right = true; }
        }
        if !left || !right {
            println!("YES");
            return;
        }
    }

    // any b inside a
    for b_i in 0..4 {
        let b = (square_b[2*b_i], square_b[2*b_i+1]);
        let mut left = false;
        let mut right = false;
        for i in 0..4 {
            let base = (square_a[2*i], square_a[2*i+1]);
            let j = (i+1) % 4;
            let a = (square_a[2*j], square_a[2*j+1]);
            let cmv = cm(&base, &a, &b);
            if cmv > 0 { left = true; }
            if cmv < 0 { right = true; }
        }
        if !left || !right {
            println!("YES");
            return;
        }
    }

    // check intersect
    for a_i in 0..4 {
        let a_a = (square_a[2*a_i], square_a[2*a_i+1]);
        let a_j = (a_i + 1) % 4;
        let a_b = (square_a[2*a_j], square_a[2*a_j+1]);
        let seg_a = (a_a, a_b);

        for i in 0..4 {
            let b_a = (square_b[2*i], square_b[2*i+1]);
            let j = (i+1) % 4;
            let b_b = (square_b[2*j], square_b[2*j+1]);
            let seg_b = (b_a, b_b);
            if intersect(&seg_a, &seg_b) {
                println!("YES");
                return;
            }
        }
    }

    println!("NO");
}


use std::io;

fn main() -> std::io::Result<()> {
    let stdin = io::stdin();
    let mut input = String::new();
    stdin.read_line(&mut input)?;
    print!("{}", match hq9plus(input) {
        true => "YES",
        false => "NO"
    }.to_string());
    Ok(())
}

fn hq9plus(input: String) ->  bool {
    input.trim().chars().filter(|&c|
        c == 'H' || c == 'Q' || c == '9' || c == '+'
    ).collect::<String>().len() > 0
}
#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test() {
        assert_eq!(hq9plus("Hi!".to_string()), true);
        assert_eq!(hq9plus("Codeforces".to_string()), false);

    }
}


use std::io;
fn main() {
    let data = read();
    let mut c = 0;
    for val in data.chars(){
        if val == 'H' || val == 'Q' || val == '9' || val == '+'{
            println!("YES");
            c = 1;
            break;
        }
    }
    if c==0{
        println!("NO");
    }
}
fn read() -> String{
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    input.trim().parse::<String>().unwrap()
}


use std::str::FromStr;

fn read_str() -> String {
    let mut buffer: String = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Error");
    buffer.trim().to_string()
}

fn main() {
    for instruction in read_str().chars() {
        if "HQ9+".contains(instruction) {
            println!("YES");
            std::process::exit(0);
        }
    }
    println!("NO");
}


use std::io;

macro_rules! readln {
    () => {{
        use std::io;
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.trim().to_string()
    }};
    ( $t:ty ) => {{
        let input = readln!();
        input.parse::<$t>().unwrap()
    }};
    ( $( $t:ty ),+ ) => {{
        let input = readln!();
        let mut input = input.split_whitespace();
        (
            $(
                input.next().unwrap().parse::<$t>().unwrap(),
            )+
        )
    }}
}

fn main() {
    let num = readln!(i64);

    println!("{}", if num % 2 != 0 {
        let mut div = 3;
        while num % div != 0 {
            div += 1;
        }
        1 + (num - div) / 2
    } else {
        num / 2
    });
}


use std::io;

macro_rules! readln {
    () => {{
        use std::io;
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.trim().to_string()
    }};
    ( $t:ty ) => {{
        let input = readln!();
        input.parse::<$t>().unwrap()
    }};
    ( $( $t:ty ),+ ) => {{
        let input = readln!();
        let mut input = input.split_whitespace();
        (
            $(
                input.next().unwrap().parse::<$t>().unwrap(),
            )+
        )
    }}
}

fn main() {
    let num = readln!(i64);

    println!("{}", if num % 2 != 0 {
        let mut div = 3;
        let end = (num as f64).sqrt() as i64 + 1;
        while div <= end && num % div != 0 {
            div += 1;
        }
        1 + (num - div) / 2
    } else {
        num / 2
    });
}


use std::io;

fn main() {
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer).expect("err");
    let n:i32 = buffer.trim().parse().unwrap();
    for i in 2..= n {
        if n%i==0 {
            println!("{}", n/i); break;
        }
    }
}


use std::io;

fn main() {
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer).expect("err");
    let n:i64 = buffer.trim().parse().unwrap();
    for i in 2..= n {
        if n%i==0 {
            println!("{}", n/i); break;
        }
    }
}


use std::io;

fn main() {
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer).expect("err");
    let mut n:i64 = buffer.trim().parse().unwrap();
    let mut counter:i64 = 0;
    while n != 0 {
        for i in 2..= n {
            if n%i==0 {
                if i == 2 {
                    counter+=n/i; n = 0; break;
                }
                n -= i; counter+=1; break;
            }
        }
    }
    println!("{}", counter);
}


use std::io;
use std::str;

pub struct Scanner<R> {
    reader: R,
    buffer: Vec<String>,
}

impl<R: io::BufRead> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self {
            reader,
            buffer: vec![],
        }
    }

    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            self.reader.read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn get_mpf(n: u64) -> u64 {
    for d in 2..=n {
        if n % d == 0 {
            return d;
        }
    }
    n
}

fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {
    let n: u64 = scan.token();
    let mpf = get_mpf(n);
    let ans = n / mpf;
    writeln!(out, "{}", ans).ok();
}

fn main() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = Scanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());
    solve(&mut scan, &mut out);
}


use std::io;
use std::str;

pub struct Scanner<R> {
    reader: R,
    buffer: Vec<String>,
}

impl<R: io::BufRead> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self {
            reader,
            buffer: vec![],
        }
    }

    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            self.reader.read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn get_mpf(n: u64) -> u64 {
    for d in 2..=n {
        if n % d == 0 {
            return d;
        }
    }
    n
}

fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {
    let n: u64 = scan.token();
    let mpf = get_mpf(n);
    let ans;
    if mpf % 2 != 0 {
        if n == mpf {
            ans = 1;
        } else {
            ans = 1 + (n - mpf) / get_mpf(n - mpf);
        }
    } else {
        ans = n / mpf;
    }
    writeln!(out, "{}", ans).ok();
}

fn main() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = Scanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());
    solve(&mut scan, &mut out);
}


#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_labels)]

use std::cmp::*;
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::io::*;
use std::str::FromStr;
use std::char::*;
macro_rules! debug {($($a:expr),*) => {eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::f64;

fn min<T: PartialOrd>(a:T, b:T) -> T {
    if a < b { a }
    else { b }
}

fn max<T: PartialOrd>(a:T, b:T) -> T {
    if a < b { b }
    else { a }
}

const MAX:i64 = 1000000009;
const INF:i64 = std::i64::MAX;
const MOD:i64 = 1e9 as i64 + 7;

struct Graph {
    e: Vec<Vec<usize>>,
    v: Vec<usize>,
    u: Vec<usize>,
    f: Vec<bool>,
    c: i64,
    flag: bool,
    vc: Vec<i64>,
}

impl Graph {
    fn new(n:usize) -> Self {
        Graph {
            e: vec![vec![];n],
            v: vec![],
            u: vec![n;n],
            f: vec![false;n],
            c: 0,
            flag: true,
            vc: vec![0;n],
        }
    }

    fn dfs(&mut self, crt: usize) {
        self.f[crt] = true;
        self.c = self.e[crt].len() as i64;
        if self.c != 2 {
            self.flag = false;
        }

        for i in 0..self.e[crt].len() {
            let v = self.e[crt][i];
            if self.f[v] { continue; }
            self.dfs(v);
        }
    }
}

fn binary_search(s: &Vec<i64>, v:i64) -> usize {
    let mut left = 0;
    let mut right = s.len();

    while right-left > 1 {
        let mid = (right+left)/2;
        //debug!(left,mid,right,s[mid]);
        if s[mid] < v { left = mid; }
        else { right = mid; }
    }
    left
}

fn neighbors(tree: &BTreeSet<usize>, val: usize) -> (Option<&usize>, Option<&usize>) {
    use std::ops::Bound::*;

    let mut before = tree.range((Unbounded, Excluded(val)));
    let mut after = tree.range((Excluded(val), Unbounded));

    (before.next_back(), after.next())
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

const MAX_A:i64 = 1e16 as i64;

fn gcd(a:i64, b:i64) -> i64 {
    if b==0 {return a;}
    gcd(b, a%b)
}

struct BIT {
    n: usize,
    bit: Vec<i64>,
}

impl BIT {
    fn new(n:usize) -> BIT {
        BIT {
            n,
            bit: vec![0;n+1],
        }
    }

    fn add(&mut self, a:usize, w:i64) {
        let mut x = a;
        while x <= self.n {
            self.bit[x] += w;
            x += (x as i64 & -(x as i64)) as usize;
        }
    }

    fn sum(&self, a:usize) -> i64 {
        let mut ret = 0;
        let mut x = a as i64;
        while x > 0 {
            ret += self.bit[x as usize];
            x -= x & -x;
        }
        ret
    }
}

fn prime_factor(n: i64) -> BTreeMap<i64,i64> {
    let mut n = n;
    let mut map = BTreeMap::new();
    let mut i = 2;
    while i*i <= n {
        while n%i == 0 {
            let count = map.entry(i).or_insert(0);
            *count += 1;
            n /= i;
        }
        i += 1;
    }
    if n!=1 { map.insert(n,1); }
    map
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }

    input! {
        n: i64,
    }

    let fac = prime_factor(n);
    let d = *fac.iter().next().unwrap().0;
    //debug!(d);
    puts!("{}\n", n/d);
}

/*

n から最小の素数の約数を引いていく、何回操作ができるか。

34, 32, 30, 28, .., 2, 0
31, 0
6, 4, 2, 0
10, 8, 6, 4,

約数列挙、最小の素数見つける、それで割る？

*


#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_labels)]

use std::cmp::*;
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::io::*;
use std::str::FromStr;
use std::char::*;
macro_rules! debug {($($a:expr),*) => {eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::f64;

fn min<T: PartialOrd>(a:T, b:T) -> T {
    if a < b { a }
    else { b }
}

fn max<T: PartialOrd>(a:T, b:T) -> T {
    if a < b { b }
    else { a }
}

const MAX:i64 = 1000000009;
const INF:i64 = std::i64::MAX;
const MOD:i64 = 1e9 as i64 + 7;

struct Graph {
    e: Vec<Vec<usize>>,
    v: Vec<usize>,
    u: Vec<usize>,
    f: Vec<bool>,
    c: i64,
    flag: bool,
    vc: Vec<i64>,
}

impl Graph {
    fn new(n:usize) -> Self {
        Graph {
            e: vec![vec![];n],
            v: vec![],
            u: vec![n;n],
            f: vec![false;n],
            c: 0,
            flag: true,
            vc: vec![0;n],
        }
    }

    fn dfs(&mut self, crt: usize) {
        self.f[crt] = true;
        self.c = self.e[crt].len() as i64;
        if self.c != 2 {
            self.flag = false;
        }

        for i in 0..self.e[crt].len() {
            let v = self.e[crt][i];
            if self.f[v] { continue; }
            self.dfs(v);
        }
    }
}

fn binary_search(s: &Vec<i64>, v:i64) -> usize {
    let mut left = 0;
    let mut right = s.len();

    while right-left > 1 {
        let mid = (right+left)/2;
        //debug!(left,mid,right,s[mid]);
        if s[mid] < v { left = mid; }
        else { right = mid; }
    }
    left
}

fn neighbors(tree: &BTreeSet<usize>, val: usize) -> (Option<&usize>, Option<&usize>) {
    use std::ops::Bound::*;

    let mut before = tree.range((Unbounded, Excluded(val)));
    let mut after = tree.range((Excluded(val), Unbounded));

    (before.next_back(), after.next())
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

const MAX_A:i64 = 1e16 as i64;

fn gcd(a:i64, b:i64) -> i64 {
    if b==0 {return a;}
    gcd(b, a%b)
}

struct BIT {
    n: usize,
    bit: Vec<i64>,
}

impl BIT {
    fn new(n:usize) -> BIT {
        BIT {
            n,
            bit: vec![0;n+1],
        }
    }

    fn add(&mut self, a:usize, w:i64) {
        let mut x = a;
        while x <= self.n {
            self.bit[x] += w;
            x += (x as i64 & -(x as i64)) as usize;
        }
    }

    fn sum(&self, a:usize) -> i64 {
        let mut ret = 0;
        let mut x = a as i64;
        while x > 0 {
            ret += self.bit[x as usize];
            x -= x & -x;
        }
        ret
    }
}

fn prime_factor(n: i64) -> BTreeMap<i64,i64> {
    let mut n = n;
    let mut map = BTreeMap::new();
    let mut i = 2;
    while i*i <= n {
        while n%i == 0 {
            let count = map.entry(i).or_insert(0);
            *count += 1;
            n /= i;
        }
        i += 1;
    }
    if n!=1 { map.insert(n,1); }
    map
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }

    input! {
        n: i64,
    }

    let fac = prime_factor(n);
    let d = *fac.iter().next().unwrap().0;
    //debug!(d);
    puts!("{}\n", n/d);
}

/*

n から最小の素数の約数を引いていく、何回操作ができるか。

34, 32, 30, 28, .., 2, 0
31, 0
6, 4, 2, 0
10, 8, 6, 4,

約数列挙、最小の素数見つける、それで割る？

*/


use std::io;

fn main() {
    let mut guess = String::new();

    io::stdin()
        .read_line(&mut guess)
        .expect("Failed to read line");

    let mut bills:u32 = 0;
    let mut n= guess.trim().parse::<i32>().unwrap();

    while n > 0 {
        if (n % 100) == 0 {
            n = n - 100;
            bills+=1;
        }
        else if (n % 20) == 0
        {
            n = n - 20;
            bills+=1;
        }
        else if (n % 10) == 0
        {
            n = n - 5;
            bills+=1;
        }
        else if (n % 100) == 0
        {
            n = n - 5;
            bills+=1;
        }
        else
        {
            n = n - 1;
            bills+=1;
        }
    }
    print!("{}",bills);
}


fn main() {
    let mut reader = scanner::TokenReader::new();
    let (a, b) = (reader.next::<u32>(), reader.next::<u32>());
    let prob = (6 - std::cmp::max(a, b)) + 1;
    let (a, b) = if 6 % prob == 0 {
        (1, 6 / prob)
    } else {
        (prob, 6)
    };
    println!("{}/{}", a, b);
}

// ---------- Begin Scanner ----------
#[allow(dead_code)]
mod scanner {
    use std::fmt::Debug;
    use std::str::FromStr;

    pub struct TokenReader {
        reader: std::io::Stdin,
        tokens: Vec<String>,
        index: usize,
    }

    impl TokenReader {
        pub fn new() -> Self {
            Self {
                reader: std::io::stdin(),
                tokens: Vec::new(),
                index: 0,
            }
        }

        pub fn next<T>(&mut self) -> T
        where
            T: FromStr,
            T::Err: Debug,
        {
            if self.index >= self.tokens.len() {
                self.load_next_line();
            }
            self.index += 1;
            self.tokens[self.index - 1].parse().unwrap()
        }

        pub fn vector<T>(&mut self) -> Vec<T>
        where
            T: FromStr,
            T::Err: Debug,
        {
            if self.index >= self.tokens.len() {
                self.load_next_line();
            }
            self.index = self.tokens.len();
            self.tokens.iter().map(|tok| tok.parse().unwrap()).collect()
        }

        pub fn load_next_line(&mut self) {
            let mut line = String::new();
            self.reader.read_line(&mut line).unwrap();

            self.tokens = line.split_whitespace().map(String::from).collect();
            self.index = 0;
        }
    }
}
// ---------- End Scanner ----------


use std::io;

fn read_line() -> String {
    let mut input_line = String::new();
    io::stdin().read_line(&mut input_line).unwrap();
    return String::from(input_line.trim());
}

fn read_line_vec() -> Vec<u8> {
    return read_line().split(' ')
        .map(|s| s.parse().unwrap())
        .collect();
}

fn read_line_pair() -> (u8, u8) {
    let vec = read_line_vec();
    return (vec[0], vec[1]);
}

fn main() {
    let (a, b) = read_line_pair();
    let c = 6 - std::cmp::max(a, b) + 1;
    match c {
        2 => println!("1/3"),
        3 => println!("1/2"),
        4 => println!("2/3"),
        _ => println!("{}/6", c)
    }
}


macro_rules! input {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

const MOD: i64 = 1000000007;

// assume a, b positive
fn gcd(a: i64, b: i64) -> (i64, i64, i64) {
    if b == 0 {
        (1, 0, a)
    }
    else {
        let (x, y, d) = gcd(b, a%b); // xb + y(a-qb) = d   where q = a/b
        (y, x-y*(a/b), d)
    }
}

fn factorial_mod(a: i64) -> i64 {
    if a == 0 {
        1
    }
    else {
        a * factorial_mod(a-1) % MOD
    }
}

fn binomial_mod(n: i64, k: i64) -> i64 {
    let a = factorial_mod(k);
    let b = factorial_mod(n-k);
    let (inv_a, _, _) = gcd(a, MOD);
    let (inv_b, _, _) = gcd(b, MOD);
    let result = factorial_mod(n) * inv_a % MOD * inv_b % MOD;
    if result < 0 { result + MOD } else { result }
}

fn main() {
    let stdin = std::io::stdin();
    let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
    let mut next = move || -> String{
        bytes
            .by_ref()
            .map(|r|r.unwrap() as char)
            .skip_while(|c|c.is_whitespace())
            .take_while(|c|!c.is_whitespace())
            .collect()
    };
    input! {next,
        n: i64,
        m: i64,
        k: i64,
    }
    println!("{}", binomial_mod(n-1,2*k)*binomial_mod(m-1,2*k) % MOD);
    // println!("{:?}", matches);

    // println!("{}", result);
}


// Vicfred
// https://codeforces.com/problemset/problem/546/C

use std::io;
use std::collections::HashSet;
use std::collections::VecDeque;

#[derive(Debug,PartialEq,Eq,PartialOrd,Ord,Hash)]
struct Pair(i64, i64);

fn main() {
    let mut n = String::new();

    io::stdin()
        .read_line(&mut n)
        .unwrap();

    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let mut a: VecDeque<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    a.pop_front();

    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let mut b: VecDeque<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    b.pop_front();

    let mut ans = 0;

    while !a.is_empty() && !b.is_empty() {
        ans += 1;

        println!("{:?}", a);
        println!("{:?}", b);

        let x = a.pop_front().unwrap();
        let y = b.pop_front().unwrap();

        states.insert(Pair(x,y));

        if x > y {
            a.push_back(y);
            a.push_back(x);
        } else {
            b.push_back(x);
            b.push_back(y);
        }
        if ans > 1000 {
            println!("-1");
            return;
        }
    }

    let winner = if a.is_empty() {2} else {1};

    println!("{} {}", ans, winner);
}


// Vicfred
// https://codeforces.com/problemset/problem/546/C

use std::io;
use std::collections::HashSet;
use std::collections::VecDeque;

#[derive(Debug,PartialEq,Eq,PartialOrd,Ord,Hash)]
struct Pair(i64, i64);

fn main() {
    let mut n = String::new();

    io::stdin()
        .read_line(&mut n)
        .unwrap();

    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let mut a: VecDeque<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    a.pop_front();

    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let mut b: VecDeque<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    b.pop_front();

    let mut ans = 0;

    while !a.is_empty() && !b.is_empty() {
        ans += 1;

        println!("{:?}", a);
        println!("{:?}", b);

        let x = a.pop_front().unwrap();
        let y = b.pop_front().unwrap();

        if x > y {
            a.push_back(y);
            a.push_back(x);
        } else {
            b.push_back(x);
            b.push_back(y);
        }
        if ans > 1000 {
            println!("-1");
            return;
        }
    }

    let winner = if a.is_empty() {2} else {1};

    println!("{} {}", ans, winner);
}


// Vicfred
// https://codeforces.com/problemset/problem/546/C

use std::io;
use std::collections::HashSet;
use std::collections::VecDeque;

#[derive(Debug,PartialEq,Eq,PartialOrd,Ord,Hash)]
struct Pair(i64, i64);

fn main() {
    let mut n = String::new();

    io::stdin()
        .read_line(&mut n)
        .unwrap();

    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let mut a: VecDeque<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    a.pop_front();

    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let mut b: VecDeque<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    b.pop_front();

    let mut ans = 0;
    let mut impossible = false;

    let mut states = HashSet::new();

    states.insert(Pair(1,2));

    while !a.is_empty() && !b.is_empty() {
        ans += 1;

        let x = a.pop_front().unwrap();
        let y = b.pop_front().unwrap();

        match states.get(&Pair(x,y)) {
            None => states.insert(Pair(x,y)),
            _ => {
                impossible = true;
                break;
            }
        };

        if x > y {
            a.push_back(y);
            a.push_back(x);
        } else {
            b.push_back(x);
            b.push_back(y);
        }
    }

    if impossible {
        println!("-1");
        return;
    }

    let winner = if a.is_empty() {2} else {1};

    println!("{} {}", ans, winner);
}


use std::collections::HashSet;
use std::collections::VecDeque;

struct Scan {
    buffer: std::collections::VecDeque<String>,
}

impl Scan {
    fn new() -> Scan {
        Scan {
            buffer: VecDeque::new(),
        }
    }

    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop_front() {
                break token.parse::<T>().ok().unwrap();
            }
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).expect("Fail to read");
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }

    fn next_n<T: std::str::FromStr>(&mut self, n: usize) -> VecDeque<T> {
        (0..n).map(|_| self.next::<T>()).collect()
    }
}

fn get_state(card1: &VecDeque<usize>, card2: &VecDeque<usize>) -> (usize, usize) {
    let mut r1 = 0usize;
    let mut r2 = 0usize;
    for item in card1.iter() {
        r1 |= 1 << *item;
    }
    for item in card2.iter() {
        r2 |= 1 << *item;
    }
    return (r1, r2);
}

fn _main() {
    let mut scan = Scan::new();
    let mut visited: HashSet<(usize, usize)> = HashSet::new();
    let _n: usize = scan.next();
    let k1: usize = scan.next();
    let mut card1: VecDeque<usize> = scan.next_n(k1);
    let k2: usize = scan.next();
    let mut card2: VecDeque<usize> = scan.next_n(k2);
    let mut wars = 0usize;
    while !card1.is_empty() && !card2.is_empty() {
        let state = get_state(&card1, &card2);
        if visited.contains(&state) {
            break;
        }
        visited.insert(state);
        let first = card1.pop_front().unwrap();
        let second = card2.pop_front().unwrap();
        if first > second {
            card1.push_back(second);
            card1.push_back(first);
        } else {
            card2.push_back(first);
            card2.push_back(second);
        }
        wars += 1;
    }
    if !card1.is_empty() && !card2.is_empty() {
        println!("-1");
    } else {
        println!("{} {}", wars, if card1.is_empty() { 2 } else { 1 });
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(1 << 23)
        .spawn(_main)
        .unwrap()
        .join()
        .unwrap();
}


fn solve(n: u16, ln: &[u16]) -> &str {
    let mut i = 0;
    while ln[i] <= n {
        if n % ln[i] == 0 {
            return "YES";
        }
        i += 1;
    }
    "NO"
}

fn main() {
    let n: u16 = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim().parse().unwrap()
    };

    let lucky_numbers = [4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777];
    print!("{}", solve(n, &lucky_numbers));
}


use std::io::*;

fn read<T: std::str::FromStr>(i: &mut StdinLock) -> T {
    let mut s = String::new();
    i.by_ref().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn string_lucky(s: &String) -> bool {
    for c in s.as_str().chars() {
        match c {
            '4' | '7' => (),
            _ => return false,
        }
    }

    true
}

fn is_lucky_number_with_4(val: u64) -> bool {
    let mut remain: u64 = val;
    loop {
        if remain % 4 != 0 {
            return false;
        }

        remain = remain / 4;
        if remain != 1 {
            break;
        }
    }

    true
}

fn is_lucky_number_with_7(val: u64) -> bool {
    let mut remain: u64 = val;
    loop {
        if remain % 7 != 0 {
            return false;
        }

        remain = remain / 7;
        if remain != 1 {
            break;
        }
    }

    true
}

fn main() {
    // initialize stdin
    let sin = std::io::stdin();
    let mut sin = sin.lock();
    let sin = &mut sin;

    let input: String = read(sin);

    if string_lucky(&input) {
        println!("YES");
        return;
    }

    let val: u64 = input.parse().unwrap();

    if is_lucky_number_with_4(val) {
        println!("YES");
        return;
    }

    if is_lucky_number_with_7(val) {
        println!("YES");
        return;
    }

    println!("NO");
}


use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s = s.trim().to_string();
    let mut ans = String::from("YES");
    for c in s.chars() {
        if c != '4' && c != '7' {
            ans = String::from("NO");
        }
    }
    println!("{}", ans);
}


use std::io::{Read, Write, stdin, stdout};
pub struct Scanner<U: Sized + Read> {
    pub buffer: Vec<String>,
    pub reader: U,
}
impl<U: Sized + Read> Scanner<U> {
    pub fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            self.reader.read_to_string(&mut input).expect("Failed read");
            self.buffer = input.lines().rev().map(String::from).collect();
        }
    }

    pub fn new(reader: U) -> Self {
        return Scanner {
            buffer: vec![],
            reader,
        };
    }
}

pub fn solution_of_p122a(input: &mut Read, out: &mut Write) {
    let mut scanner = Scanner::new(input);
    let num = scanner.next::<String>().parse::<usize>().unwrap();
    let lucky_nums = vec![4, 7, 44, 47, 74, 77, 444, 447, 474, 744, 747, 774, 777];
    if is_almose_lucky(num, lucky_nums) {
        write!(out, "YES").ok();
    } else {
        write!(out, "NO").ok();
    }
}

fn is_almose_lucky(num: usize, arr: Vec<usize>) -> bool {
    if arr.contains(&num) {
        return true;
    }
    for item in &arr {
        if num % (*item) == 0 {
            return true;
        }
    }
    return false;
}

fn main() {
    solution_of_p122a(&mut stdin(), &mut stdout());
}


//spnauti-rusT {{{
use std::io::*; use std::str::{self,*}; use std::fmt::Debug;
#[allow(unused_imports)] use std::cmp::Ordering::{self,*};
#[allow(unused_imports)] use std::ops::{self,*};
#[allow(unused_imports)] use std::iter::{self,*};
#[allow(unused_imports)] use std::collections::*;
#[allow(unused_imports)] use std::cell::*;
#[allow(unused_macros)] macro_rules! m {
	($c:tt,$x:expr,$y:expr) => {{
		let b=$y; let a=&mut$x; if b$c*a {*a=b; true} else {false}
	}};
}
#[allow(unused_macros)] macro_rules! l {
	($($v:ident),+ =$e:expr) => {$(let$v=$e;)+};
	($($v:ident),+:$t:ty=$e:expr) => {$(let$v:$t=$e;)+};
	(mut $($v:ident),+ =$e:expr) => {$(let mut$v=$e;)+};
	(mut $($v:ident),+:$t:ty=$e:expr) => {$(let mut$v:$t=$e;)+};
}
#[allow(unused_macros)] macro_rules! rep { {[$c:expr]$($s:tt)+} => {for _ in 0..$c {$($s)+}} }
#[allow(dead_code)] fn reader() -> WordReaderC { WordReaderC::new() }
#[allow(dead_code)] fn writer() -> BufWriter<Stdout> { BufWriter::new(stdout()) }
struct WordReaderC {buf: Vec<u8>, pos: usize, q: std::io::StdinLock<'static>}//'
#[allow(dead_code)] impl WordReaderC {
	fn new() -> Self {
		let r = unsafe {&*Box::into_raw(Box::new(stdin()))};
		Self { q: r.lock(), buf: Vec::new(), pos: 0 }
	}
	fn next_line(&mut self) -> bool {
		self.buf.clear(); self.pos = 0;
		self.q.read_until(b'\n', &mut self.buf).unwrap_or(0) > 0
	}
	fn is_ws(c: u8) -> bool {
		c == b' ' || c == b'\r' || c == b'\n' || c == b'\t'
	}
	fn byte(&mut self) -> Option<u8> {
		if self.pos == self.buf.len() { if !self.next_line() { return None; } }
		self.pos += 1; Some(self.buf[self.pos - 1])
	}
	fn vb(&mut self) -> Vec<u8> {
		let mut s = Vec::with_capacity(8);
		let mut f = false;
		loop {
			if let Some(c) = self.byte() {
				if !Self::is_ws(c) {
					s.push(c);
					f = true;
				} else if f { break; }
			} else { break; }
		}
		s
	}
	fn s(&mut self) -> String { String::from_utf8(self.vb()).expect("invalid utf8") }
	fn i(&mut self) ->    i32 { self.p() }
	fn l(&mut self) ->    i64 { self.p() }
	fn u(&mut self) ->  usize { self.p() }
	fn f(&mut self) ->    f64 { self.p() }
	fn vi(&mut self, n: usize) -> Vec<i32> { self.vp(n) }
	fn vl(&mut self, n: usize) -> Vec<i64> { self.vp(n) }
	fn vu(&mut self, n: usize) -> Vec<usize> { self.vp(n) }
	fn ii(&mut self, n: usize) -> impl Iterator<Item=i32> { self.ip(n).into_iter() }
	fn iu(&mut self, n: usize) -> impl Iterator<Item=usize> { self.ip(n).into_iter() }
	fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
		let w = self.vb(); str::from_utf8(w.as_ref()).unwrap().parse::<T>().unwrap()
	}
	fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
		(0..n).map(|_|self.p()).collect()
	}
	fn ip<T: FromStr>(&mut self, n: usize) -> impl Iterator<Item=T> where T::Err: Debug {
		self.vp(n).into_iter()
	}
}
//------------------- End rusT }}}

fn main() {
	let mut rin = reader();
	let mut rout = writer();

	let mut c0 = vec![1; 10];
	for x in rin.vb() {
		c0[(x - b'0') as usize] += 1;
	}
	let m = rin.u();
	let mut ns = 1;
	for &c in c0.iter() {
		ns *= c;
	}
	let encode = |a: &[usize]| -> usize {
		let mut res = 0;
		for i in 0..10 {
			res = res * c0[i] + a[i];
		}
		res
	};
	let decode = |a: &mut [usize], mut x: usize| {
		for i in (0..10).rev() {
			a[i] = x % c0[i];
			x /= c0[i];
		}
	};
	let mut dp = vec![vec![0; m]; ns];
	dp[0][0] = 1;
	for s in 0..ns {
		let mut a = vec![0; 10];
		decode(&mut a, s);
		let st = if s == 0 {1} else {0};
		for r in 0..m {
			let v = dp[s][r];
			if v == 0 { continue; }
			for i in st..10 {
				if a[i]+1 < c0[i] {
					a[i] += 1;
					let ss = encode(&a);
					dp[ss][(r * 10 + i) % m] += v;
					a[i] -= 1;
				}
			}
		}
	}
	let sol = dp[ns-1][0];
	writeln!(rout, "{}", sol).ok();
}


fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let mut n: u64 = it.next().unwrap().parse().unwrap();
    let m: usize = it.next().unwrap().parse().unwrap();
    let mut cnt = vec![0; 10];
    let mut len = 0;
    while n > 0 {
        let k = (n % 10) as usize;
        cnt[k] += 1;
        len += 1;
        n /= 10;
    }
    let mut now = std::collections::BTreeMap::new();
    now.insert((cnt, 0), 1u64);
    for p in 0..len {
        let mut next = std::collections::BTreeMap::new();
        for (k, v) in now.iter() {
            let (a, rem) = k.clone();
            for d in 0..10 {
                if a[d] > 0 && !(p == 0 && d == 0) {
                    let mut b = a.clone();
                    b[d] -= 1;
                    let r = (10 * rem + d) % m;
                    *next.entry((b, r)).or_insert(0u64) += *v;
                }
            }
        }
        now = next;
    }
    let mut ans = 0;
    for (k, v) in now.iter() {
        if k.1 == 0 {
            ans += *v;
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


fn main() {
    use std::io::prelude::*;
    use std::io;

    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();

    let a: Vec<i32> = input.split_whitespace().map(|x| x.parse().unwrap())
        .collect();

    let mut max_ans = 0;

    let modulo = |a, b| {
        if a < 0 {
            a % b + b
        } else {
            a % b
        }
    };
    let modsub = |a, b| {
        modulo(a - b, 14)
    };

    for (i, &ai) in a.iter().enumerate() {
        let q = ai / 14;
        let r = ai % 14;

        let mut ans = 0;
        let mut j = i + 1;
        for _ in 0..13 {
            let cnt = a[modulo(j, 14)] + q + if r < modsub(j, i) as i32 { 0 } else { 1 };
            if cnt % 2 == 0 {
                ans += cnt;
            }

            j += 1
        }

        if q % 2 == 0 {
            ans += q;
        }

        if max_ans < ans {
            max_ans = ans;
        }
    }

    println!("{}", max_ans);
}


use std::io;
use std::str::FromStr;
use std::num::ParseIntError;
use std::ops::Index;

struct RevBinary {
    data: Vec<bool>,
}

impl FromStr for RevBinary {
    type Err = ParseIntError;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        let i = s.parse::<u32>()?;

        Ok(RevBinary::new(i))
    }
}

impl Index<usize> for RevBinary {
    type Output = bool;

    fn index(&self, i: usize) -> &Self::Output {
        &self.data[self.data.len() - i - 1]
    }
}

impl RevBinary {
    fn new(x : u32) -> RevBinary {
        let mut y = x;
        let mut bin : Vec<bool> = Vec::new();
        while y != 0 {
           bin.push(if y % 2 == 1 { true } else { false });
           y /= 2;
        }
        RevBinary {
            data: bin,
        }
    }

    fn size(&self) -> usize {
        self.data.len()
    }
}

fn process_node(all: &Vec<RevBinary>, ind: Vec<usize>, depth: usize, k: u32) -> u32 {
    let mut result : u32 = ind.iter().take(k as usize).map(|&x| all[x].size() - depth).sum::<usize>() as u32;

    let mut new_ind0 : Vec<usize> = Vec::new();
    let mut new_ind1 : Vec<usize> = Vec::new();
    for i in ind.iter().filter(|&&x| all[x].size() > depth) {
        if all[*i][depth] {
            new_ind1.push(*i);
        } else {
            new_ind0.push(*i);
        }
    }
    if new_ind0.len() >= k as usize {
        result = result.min(process_node(&all, new_ind0, depth + 1, k));
    }
    if new_ind1.len() >= k as usize {
        result = result.min(process_node(&all, new_ind1, depth + 1, k));
    }
    result
}

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).expect("failed to read input");
    let mut input_iter = input.split_whitespace();
    let n = input_iter.next().unwrap().parse::<usize>().unwrap();
    let k = input_iter.next().unwrap().parse::<u32>().unwrap();
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer).expect("failed to read input");
    let a = buffer.split_whitespace().map(|x| x.parse::<RevBinary>().unwrap()).collect::<Vec<RevBinary>>();

    println!("{}", process_node(&a, (0..n).collect::<Vec<usize>>(), 0, k));
}


#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      k: usize,
      mut aa: [usize; n],
    }
    aa.sort();

    let mut ans: u64 = 1 << 60;
    for t in 0..n+1 {
        let mut temp = 0;
        let mut ok = 0;

        for i in 0..n {
            let mut a = aa[i];
            let mut cnt = 0;
            if a < t {
                continue;
            }

            while a > t {
                a/=2;
                cnt += 1;
            }
            if t == a {
                temp += cnt;
                ok += 1;
                if ok == k {
                    break;
                }
            }
        }

        if ok == k {
            ans = min(ans, temp);
        }
    }
    puts!("{}\n", ans);
}


use std::io;

fn shift_count(mut from: i32, to: i32) -> i32 {
    let mut cnt = 0;
    while from > to {
        cnt += 1;
        from /= 2;
    }
    cnt
}

fn normalize(id: usize, input: &Vec<i32>) -> Vec<i32> {
    let norm_val = input[id];
    let mut normalized: Vec<i32> = input
        .iter()
        .map(|x| {
            if x < &norm_val {
                20000000
            } else {
                shift_count(*x, norm_val)
            }
        })
        .collect();

    normalized.sort_unstable();
    normalized
}

fn cost(normalized: &Vec<i32>, cnt: u8) -> i32 {
    normalized
        .iter()
        .take(cnt as usize)
        .fold(0, |acc, x| acc + x)
}

fn main() {
    let mut inp = String::new();
    io::stdin().read_line(&mut inp).unwrap();
    let line: Vec<u8> = inp
        .split_whitespace()
        .map(|x| x.trim().parse().unwrap())
        .collect();
    let (n, k) = (line[0], line[1]);

    inp.clear();
    io::stdin().read_line(&mut inp).unwrap();

    let input: Vec<i32> = inp
        .split_whitespace()
        .map(|x| x.trim().parse::<i32>().unwrap())
        .collect();

    let mut norm_matrix: Vec<Vec<i32>> = Vec::with_capacity(input.len());

    let mut min_cost = std::i32::MAX;
    for i in 0..n {
        let norm = normalize(i as usize, &input);
        let c = cost(&norm, k);
        if c < min_cost {
            min_cost = c;
        }

        norm_matrix.push(norm);
    }

    println!("{}", min_cost);
}


#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(dead_code)]

use std::char::*;
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::FromStr;

macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::f64;

fn min<T: PartialOrd>(a:T, b:T) -> T {
    if a < b { a }
    else { b }
}

fn max<T: PartialOrd>(a:T, b:T) -> T {
    if a < b { b }
    else { a }
}

use std::hash::Hash;
fn inc<T: Hash+Ord>(map:&mut BTreeMap<T,i64>, key:T) {
    let count = map.entry(key).or_insert(0);
    *count += 1;
}

fn digit(ch: char) -> i64 {
    return (ch as u8 - b'0') as i64
}

const MAX:usize = 30;
const INF:i64 = std::i64::MAX;
const MOD:i64 = 1e9 as i64 + 7;

fn gcd(x:i64, y:i64) -> i64 {
    if y==0 { return x; }
    gcd(y, x%y)
}

fn main() {
    //let t:usize = read();

    //'outer: for _ in 0..t {
        let n:usize = read();
        let k:usize = read();
        let a:Vec<i64> = (0..n).map(|_| read()).collect();

        let mut map = HashMap::new();
        for i in 0..n {
            let mut b = a[i];
            let mut j = 0;
            while b != 0 {
                let v = map.entry(b).or_insert(vec![]);
                v.push(j);
                j += 1;
                b /= 2;
            }
        }
        //debug!(map);

        let mut ans = INF;
        let mut m = 1i64;
        while m < 1000000 {
            let v = map.entry(m).or_insert(vec![]);
            v.sort();
            if v.len() < k { m*=2; continue; }
            let mut cnt = 0i64;
            for i in 0..k {
                cnt += v[i];
            }
            ans = min(ans, cnt);
            m *= 2;
        }
        for i in 0..n {
            let v = map.entry(a[i]).or_insert(vec![]);
            v.sort();
            if v.len() < k { continue; }
            let mut cnt = 0i64;
            for j in 0..k {
                cnt += v[j];
            }
            ans = min(ans, cnt);
        }

        println!("{}", ans);

    //}
}

/*

*/


fn main() {
    let n: u32 = get_input().parse().unwrap();
    let days: Vec<u32> = get_input().split_ascii_whitespace().map(|v| v.parse().unwrap()).collect();
    let total: u32 = days.iter().sum();
    //println!("total is {}", total);
    let m =  {
        if total > n {
            n
        } else if total == n {
            n
        } else {
            n % total
        }
    };

    let mut c = 0;

    //println!("mod is {}", m);
    for i in 0..days.len() {
        //println!("c is {}", c);
        c += days[i];

        if c >= m {
            println!("{}", i+1);
            break;
        }
    }
}

fn get_input() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Failed");
    buffer.trim().to_owned()
}

fn get_input_usize() -> usize {
    get_input().parse().unwrap()
}


//spnauti-rusT {{{
use std::io::*; use std::str::{self,*}; use std::fmt::Debug;
#[allow(unused_imports)] use std::cmp::Ordering::{self,*};
#[allow(unused_imports)] use std::ops::{self,*};
#[allow(unused_imports)] use std::iter::{self,*};
#[allow(unused_imports)] use std::collections::*;
#[allow(unused_imports)] use std::cell::*;
#[allow(unused_macros)] macro_rules! min {
	($x:expr,$y:expr) => {{ let b=$y; let a=&mut$x; if b < *a {*a=b; true} else {false} }};
}
#[allow(unused_macros)] macro_rules! max {
	($x:expr,$y:expr) => {{ let b=$y; let a=&mut$x; if b > *a {*a=b; true} else {false} }};
}
#[allow(unused_macros)] macro_rules! l {
	($($v:ident),+ =$e:expr) => {$(let$v=$e;)+};
	($($v:ident),+:$t:ty=$e:expr) => {$(let$v:$t=$e;)+};
	(mut $($v:ident),+ =$e:expr) => {$(let mut$v=$e;)+};
	(mut $($v:ident),+:$t:ty=$e:expr) => {$(let mut$v:$t=$e;)+};
}
#[allow(unused_macros)] macro_rules! v {
	([$d:expr]$($s:tt)+) => {vec![v!($($s)+);$d]};
	([]) => {Vec::new()}; ([$e:expr]) => {Vec::with_capacity($e)}; (=$e:expr) => {$e};
}
#[allow(unused_macros)] macro_rules! rep { {[$c:expr]$($s:tt)+} => {for _ in 0..$c {$($s)+}} }
#[allow(dead_code)] fn reader() -> WordReaderC { WordReaderC::new() }
#[allow(dead_code)] fn writer() -> BufWriter<Stdout> { BufWriter::new(stdout()) }
struct WordReaderC {buf: Vec<u8>, pos: usize, q: std::io::StdinLock<'static>}//'
#[allow(dead_code)] impl WordReaderC {
	fn new() -> Self {
		let r = unsafe {&*Box::into_raw(Box::new(stdin()))};
		Self { q: r.lock(), buf: v!([]), pos: 0 }
	}
	fn next_line(&mut self) -> bool {
		self.buf.clear(); self.pos = 0;
		self.q.read_until(b'\n', &mut self.buf).unwrap_or(0) > 0
	}
	fn is_ws(c: u8) -> bool {
		c == b' ' || c == b'\r' || c == b'\n' || c == b'\t'
	}
	fn byte(&mut self) -> Option<u8> {
		if self.pos == self.buf.len() { if !self.next_line() { return None; } }
		self.pos += 1; Some(self.buf[self.pos - 1])
	}
	fn vb(&mut self) -> Vec<u8> {
		let mut s = v!([8]);
		let mut f = false;
		loop {
			if let Some(c) = self.byte() {
				if !Self::is_ws(c) {
					s.push(c);
					f = true;
				} else if f { break; }
			} else { break; }
		}
		s
	}
	fn board(&mut self, r: usize, c: Option<usize>) -> Vec<Vec<u8>> {
		let mut res = v!([r]);
		let c = c.unwrap_or(0);
		rep!{[r]
			let t = self.vb();
			assert!(c == 0 || t.len() == c);
			res.push(t);
		}
		res
	}
	fn framed_board(&mut self, r: usize, c: usize, f: u8) -> Vec<Vec<u8>> {
		let mut res = v!([r+2]);
		res.push( v!([c+2] = f) );
		rep!{[r]
			let mut t = self.vb();
			assert!(t.len() == c);
			t.reserve(2);
			t.insert(0,f);
			t.push(f);
			res.push(t);
		}
		res.push( v!([c+2] = f) );
		res
	}
	fn s(&mut self) -> String { String::from_utf8(self.vb()).expect("invalid utf8") }
	fn i(&mut self) ->    i32 { self.p() }
	fn l(&mut self) ->    i64 { self.p() }
	fn u(&mut self) ->  usize { self.p() }
	fn f(&mut self) ->    f64 { self.p() }
	fn vi(&mut self, n: usize) -> Vec<i32> { self.vp(n) }
	fn vl(&mut self, n: usize) -> Vec<i64> { self.vp(n) }
	fn vu(&mut self, n: usize) -> Vec<usize> { self.vp(n) }
	fn ii(&mut self, n: usize) -> impl Iterator<Item=i32> { self.ip(n).into_iter() }
	fn iu(&mut self, n: usize) -> impl Iterator<Item=usize> { self.ip(n).into_iter() }
	fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
		let w = self.vb(); str::from_utf8(w.as_ref()).unwrap().parse::<T>().unwrap()
	}
	fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
		(0..n).map(|_|self.p()).collect()
	}
	fn ip<T: FromStr>(&mut self, n: usize) -> impl Iterator<Item=T> where T::Err: Debug {
		self.vp(n).into_iter()
	}
	fn graph(&mut self, n: usize, m: usize) -> Vec<Vec<usize>> {
		let mut e = v!([n][]); rep!{[m] l!(a,b = self.u()-1); e[a].push(b); e[b].push(a); } e
	}
	fn graph_w<T: Copy+FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<(usize,T)>> where T::Err: Debug {
		let mut e = v!([n][]); rep!{[m] l!(a,b = self.u()-1); let c: T = self.p(); e[a].push((b,c)); e[b].push((a,c)); } e
	}
}
//------------------- End rusT }}}

fn main() {
	let mut rin = reader();
	let mut rout = writer();

	l!(n,m,i,j,a,b = rin.i());
	let mut sol = None;
	for &(x,y) in [(1,1), (1,m), (n,1), (n,m)].iter() {
		if (x - i) % a == 0 && (y - j) % b == 0 {
			let xx = (x - i).abs() / a;
			let yy = (y - j).abs() / b;
			let mx = xx > 0 || a < m;
			let my = yy > 0 || b < n;
			if (xx == 0 && yy == 0) || (mx && my && (xx ^ yy) & 1 == 0) {
				let res = xx.max(yy).min(sol.unwrap_or(1000000000));
				sol.replace(res);
			}
		}
	}
	if let Some(ans) = sol {
		writeln!(rout, "{}", ans).ok();
	} else {
		writeln!(rout, "Poor Inna and pony!").ok();
	}
}


#[allow(unused)] use std::io::*;
#[allow(unused)] use std::collections::*;
#[allow(unused)] use std::mem::*;
#[allow(unused)] use std::num::*;
#[allow(unused)] use std::cmp::*;
#[allow(unused)] macro_rules! scan { ($($x:ty), +) => {{
    let mut inp = String::new(); stdin().read_line(&mut inp).ok();
    let s = inp.split(' ').map(|x| x.trim()).filter(|x| x.len() != 0).collect();
    let mut cnt : usize = 0;
    fn next<T>(cnt: &mut usize, p: &Vec<&str>) -> T where T:std::str::FromStr
    { *cnt += 1; p[*cnt-1].parse().ok().unwrap() }
    ($(next::<$x>(&mut cnt, &s)), +)
    }}; }
#[allow(unused)] macro_rules! arr { ($n:expr, $T:ty) => {{
    let mut inp = String::new(); stdin().read_line(&mut inp).ok();
    let mut s = inp.split(' ').map(|x| x.trim()).filter(|x| x.len() != 0);
    let mut v = Vec::new(); v.reserve(($n) as usize);
    for st in s { v.push(st.parse::<$T>().unwrap()); } v
    }}; }

///////////////////////////////////////////////////////////////////////////////
fn main()
{
    let a = scan!(i32);
    let b = scan!(i32);
    let c = scan!(i32);
    println!("{}", max(max(max(a + b + c, a * b * c), (a + b) * c), a + b * c));
}


fn input() -> u8 {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

fn main() {
    let (a, b, c) = (input(), input(), input());
    println!(
        "{}",
        [
            a + b + c,
            a + b * c,
            a * b + c,
            a * b * c,
            (a + b) * c,
            a * (b + c)
        ]
        .iter()
        .max()
        .unwrap()
    );
}


use std::io;
use std::cmp::{min, max};

fn main() {
  let stdin = io::stdin();
  let mut s = String::new();
  stdin.read_line(&mut s).unwrap();
  let a: i32 = s.trim().parse().unwrap();
  let mut s = String::new();
  stdin.read_line(&mut s).unwrap();
  let b: i32 = s.trim().parse().unwrap();
  let mut s = String::new();
  stdin.read_line(&mut s).unwrap();
  let c: i32 = s.trim().parse().unwrap();

  let x = min(a, min(b, c));
  let z = max(a, max(b, c));
  let y = a + b + c - x - z;

  if x == 1 && y == 1 && z == 1 {
    println!("3");
  } else if x == 1 && y == 1 {
    println!("{}", 2*z);
  } else if x == 1 {
    println!("{}", (y+1)*z);
  } else {
    println!("{}", x*y*z);
  }
}


use std::io::*;

fn read<T: std::str::FromStr>(i: &mut StdinLock) -> T {
    let mut s = String::new();
    i.by_ref().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    // initialize stdin
    let sin = std::io::stdin();
    let mut sin = sin.lock();
    let sin = &mut sin;

    let a: i64 = read(sin);
    let b: i64 = read(sin);
    let c: i64 = read(sin);

    if b == 1 {
        let ans = if a <= c {
            if c == 1 {
                // a == b == c == 1
                a + b + c
            } else {
                (a + b) * c
            }
        } else {
            a * (b + c)
        };
        println!("{}", ans);
        return;
    }

    let pre_val = if a == 1 { a + b } else { a * b };
    let ans = if c == 1 { pre_val + c } else { pre_val * c };

    println!("{}", ans);
}


use std::io;

fn main() {
    let mut a = String::new();
    let mut b = String::new();
    let mut c = String::new();

    io::stdin()
        .read_line(&mut a)
        .unwrap();

    io::stdin()
        .read_line(&mut b)
        .unwrap();

    io::stdin()
        .read_line(&mut c)
        .unwrap();

    let a: i64 = a.trim().parse().unwrap();
    let b: i64 = b.trim().parse().unwrap();
    let c: i64 = c.trim().parse().unwrap();

    println!("{}",
             [
        (a+b)*c,
        a*b+c,
        a+b*c,
        a+b+c,
        a*b*c,
        a*(b+c)
    ]
    .iter()
    .max()
    .unwrap();
    );
}


use std::str::FromStr;

fn read_str() -> String {
    let mut buffer: String = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Error");
    buffer.trim().to_string()
}

fn read_int<T: FromStr>() -> T{
    read_str().parse::<T>().ok().expect("Error")
}

fn main() {
    let (a, b, c): (u8, u8, u8) = (read_int(), read_int(), read_int());

    if a == 1 {
        if c == 1 { println!("{}", a + b + c); }
        else { println!("{}", (a + b) * c); }
    }
    else if b == 1 {
        if a > c { println!("{}", a * (b + c)); }
        else { println!("{}", (a + b) * c); }
    }
    else if c == 1 { println!("{}", a * (b + c)); }
    else { println!("{}", a * b * c); }
}


use std::str::FromStr;

fn read_str() -> String {
    let mut buffer: String = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Error");
    buffer.trim().to_string()
}

fn read_int<T: FromStr>() -> T{
    read_str().parse::<T>().ok().expect("Error")
}

fn main() {
    let (a, b, c): (u16, u16, u16) = (read_int(), read_int(), read_int());

    if a + c == 2 { println!("{}", a + b + c); }
    else if b == 1 || c == 1 {
        if a < c { println!("{}", (a + b) * c); }
        else { println!("{}", a * (b + c)); }
    }
    else { println!("{}", a * b * c); }
}


use std::io;

fn main() {
	let mut k = String::new();
	io::stdin().read_line(&mut k).unwrap();
	let k: i32 = k.trim().parse().unwrap();

	let mut l = String::new();
	io::stdin().read_line(&mut l).unwrap();
	let l: i32 = l.trim().parse().unwrap();

	let mut m = String::new();
	io::stdin().read_line(&mut m).unwrap();
	let m: i32 = m.trim().parse().unwrap();

	let mut n = String::new();
	io::stdin().read_line(&mut n).unwrap();
	let n: i32 = n.trim().parse().unwrap();

	let mut d = String::new();
	io::stdin().read_line(&mut d).unwrap();
	let d: i32 = d.trim().parse().unwrap();

	let mut ans = 0;
	for i in 0..d {
		if i % k == 0 || i % l == 0 || i % m == 0 || i % n == 0 {
			ans += 1;
		}
	}

	println!("{}", ans);
}


use std::io;

fn main() {

    let mut d = String::new();
    let mut klmn: [String;4] = [String::new(), String::new(),String::new(),String::new()];

    io::stdin().read_line(&mut klmn[0]).unwrap();
    io::stdin().read_line(&mut klmn[1]).unwrap();
    io::stdin().read_line(&mut klmn[2]).unwrap();
    io::stdin().read_line(&mut klmn[3]).unwrap();
    io::stdin().read_line(&mut d).unwrap();

    let nd: i32 = d.trim().parse().unwrap();
    let mut k: [i32; 4] = [0,0,0,0];
    k[0] = klmn[0].trim().parse().unwrap();
    k[1] = klmn[1].trim().parse().unwrap();
    k[2] = klmn[2].trim().parse().unwrap();
    k[3] = klmn[3].trim().parse().unwrap();
    if k[0] == 1 || k[1] == 1 || k[2] == 1 ||k[3] == 1 {println!("{}",nd);return;}
    let mut count = 1;
    for i in 1..nd {
        if i % k[0] == 0 || i % k[1] == 0 || i % k[2] == 0 || i % k[3] == 0 {
            count = count + 1;
        }
    }
        println!("{}",count);
}

// fn count_primes(n: i32) -> i32 {
//     let mut count = 0
//     if n <= 1 { return 0; }
//     else if n == 2 { count++; }
//     else if n % 2 == 0{ return false; }
//     else {
//         let mut i = 1;
//         while i < sqrt(n){
//             i = i + 2;
//             if n % i == 0 {
//                 return false;
//             }
//         }
//         return true;
//     }
// }

// fn is_prime(n: i32) -> bool {
//     if n <= 1 { return false; }
//     else if n == 2 { return true; }
//     else if n % 2 == 0{ return false; }
//     else {
//         let mut i = 1;
//         while i < sqrt(n){
//             i = i + 2;
//             if n % i == 0 {
//                 return false;
//             }
//         }
//         return true;
//     }
// }


#[allow(unused_imports)]
use std::cmp::{min,max};
use std::io::{BufWriter, stdin, stdout, Write};

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>
}
impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scan = Scanner::default();
    let out = &mut BufWriter::new(stdout());

	let k = scan.next::<usize>();
	let l = scan.next::<usize>();
	let m = scan.next::<usize>();
	let n = scan.next::<usize>();
	let d = scan.next::<usize>();

    let res = (0..d).filter(|x| x % k == 0 || x % l == 0 || x % m == 0 || x % n == 0).count();
    writeln!(out, "{}", res).expect("fail");
}


#[warn(unused_variables)]
fn main() {
    let v = input_vec::<usize>(" ");
    let n = v[0];
    let d = v[1];

    let mut count = 0;
    let mut pu = true;
    let p = input_str();
    for n in p.split("1") {
        if n.chars().count() >= d {
            pu = false;
        }
    }

    if !pu {
        println!("-1")
    } else {
        let mut ci = 0;
        let mut cs = d;
        'a: loop {
            if ci + d >= n-1 {
                println!("{}", count+1);
                break 'a;
            }

            if p.chars().collect::<Vec<char>>()[ci + cs] != '0' {
                count += 1;
                ci += cs;
                cs = d;
            } else {
                cs -= 1;
            }
        }
    }

}

fn input_str() -> String {
    let mut buff = String::new();
    std::io::stdin().read_line(&mut buff).expect("Err");
    buff
}

fn input_<T>() -> T
where
    T: std::str::FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    input_str().trim().parse::<T>().expect("Err pars")
}

fn input_vec<T>(sep: &str) -> Vec<T>
where
    T: std::str::FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    input_str().trim().split(sep).map(|c| c.parse::<T>().expect("Err pars")).collect()
}

fn input_vec_chars() -> Vec<char> {
    input_str().trim().chars().collect()
}


use std::io;

fn gcd(mut u: u32, mut v: u32) -> u32 {
    if u == 0 {
        return v;
    }
    if v == 0 {
        return u;
    }

    let mut shift = 0;
    let mut aux : [u32; 2] = [(u | v), 1];
    while aux[0] & aux[1] == 0 {
        shift += 1;
        aux[1] <<= 1;
    }
    u >>= shift;
    v >>= shift;

    while u & 1 == 0 {
        u >>= 1;
    }

    loop {
        while v & 1 == 0 {
            v >>= 1;
        }

        if u > v {
            aux[0] = v;
            v = u;
            u = aux[0];
        }
        v -= u;

        if v == 0 {
            break;
        }
    }
    u << shift
}

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).expect("failed to read input");
    let mut input_iter = input.split_whitespace();
    let a = input_iter.next().unwrap().parse::<u32>().unwrap();
    let b = input_iter.next().unwrap().parse::<u32>().unwrap();

    let md = if a > b { a - b } else { b - a };
    let sqrt_md = (md as f64).sqrt() as u32 + 1;
    let mut lcm_min = 4 * a * b;
    let mut min_k = 0;
    let mut vec = Vec::new();
    for i in (1..=sqrt_md).filter(|x| md % x == 0) {
        vec.push(md / i);

        let mut k = a % i;
        if k != 0 {
            k = i - k;
        }

        let lcm = (a + k) * (b + k) / (i * gcd((a + k) / i, (b + k) / i));
        if lcm < lcm_min {
            lcm_min = lcm;
            min_k = k;
        }
    }
    if md != 0 {
        for i in vec {
            let mut k = a % i;
            if k != 0 {
                k = i - k;
            }

            let lcm = (a + k) * (b + k) / (i * gcd((a + k) / i, (b + k) / i));
            if lcm < lcm_min {
                lcm_min = lcm;
                min_k = k;
            }
        }
    }

    println!("{}", min_k);
}


use std::io;

fn gcd(mut u: u32, mut v: u32) -> u32 {
    if u == 0 {
        return v;
    }
    if v == 0 {
        return u;
    }

    let mut shift = 0;
    let mut aux : [u32; 2] = [(u | v), 1];
    while aux[0] & aux[1] == 0 {
        shift += 1;
        aux[1] <<= 1;
    }
    u >>= shift;
    v >>= shift;

    while u & 1 == 0 {
        u >>= 1;
    }

    loop {
        while v & 1 == 0 {
            v >>= 1;
        }

        if u > v {
            aux[0] = v;
            v = u;
            u = aux[0];
        }
        v -= u;

        if v == 0 {
            break;
        }
    }
    u << shift
}

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).expect("failed to read input");
    let mut input_iter = input.split_whitespace();
    let a = input_iter.next().unwrap().parse::<u32>().unwrap();
    let b = input_iter.next().unwrap().parse::<u32>().unwrap();

    let md = if a > b { a - b } else { b - a };
    let sqrt_md = (md as f64).sqrt() as u32 + 1;
    let mut lcm_min = 4 * a * b;
    let mut min_k = 0;
    let mut vec = Vec::new();
    for i in (1..=sqrt_md).filter(|x| md % x == 0) {
        vec.push(md / i);

        let mut k = a % i;
        if k != 0 {
            k = i - k;
        }

        let lcm = (a + k) * (b + k) / (i * gcd((a + k) / i, (b + k) / i));
        if lcm < lcm_min {
            lcm_min = lcm;
            min_k = k;
        }
    }
    for i in vec {
        let mut k = a % i;
        if k != 0 {
            k = i - k;
        }

        let lcm = (a + k) * (b + k) / (i * gcd((a + k) / i, (b + k) / i));
        if lcm < lcm_min {
            lcm_min = lcm;
            min_k = k;
        }
    }

    println!("{}", min_k);
}


use std::io;
use std::fs::File;
use std::cmp;

fn main() {
    let stdin = io::stdin();
    let buf :Box<io::BufRead> = if cfg!(feature = "intxt") {
        eprintln!("file mode");
        let file = File::open("in.txt").unwrap();
        Box::new(io::BufReader::new(file))
    } else {
        eprintln!("stdin mode");
        Box::new(stdin.lock())
    };
    let mut sc = Scanner::new(buf);

    let (p, y) :(usize, usize) = (sc.next(), sc.next());
    let mut a = vec![false; y+1];
    let mp = cmp::min(p, (y as f32).sqrt() as usize) + 1;

    for x in 2..mp {
        if a[x] {
            continue;
        }
        let mut n = 2*x;
        while n < a.len() {
            a[n] = true;
            n += x;
        }
    }
    for (i, &b) in a.iter().enumerate().rev() {
        if i <= p {
            break;
        }
        if !b {
            println!("{}", i);
            return;
        }
    }
    println!("{}", -1);
}

struct Scanner<B: io::BufRead> {
    reader: B,
    buffer: Vec<String>,
}

impl<B: io::BufRead> Scanner<B> {
    fn new(reader: B) -> Self {
        Self {
            reader,
            buffer: Vec::new(),
        }
    }

    fn next<T: std::str::FromStr>(&mut self) -> T
    where
        T::Err: std::fmt::Debug,
    {
        if let Some(s) = self.buffer.pop() {
            T::from_str(&s).unwrap()
        } else {
            let mut s = String::new();
            let r = self.reader.read_line(&mut s).unwrap();
            assert!(r > 0);
            self.buffer = s.split_whitespace().rev().map(String::from).collect();
            return self.next();
        }
    }
}


fn fix(balance: i64) -> i64 {
    if balance >= 0 {
        return balance;
    }

    let temp = balance * -1;
    let last_dig = temp % 10;
    let seclast_dig = (temp / 10) % 10;

    if last_dig > seclast_dig {
        balance / 10
    } else {
        (balance / 100) * 10 + last_dig
    }
}

fn main() {
    let balance: i64 = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim().parse().unwrap()
    };

    let balance = fix(balance);
    println!("{}", balance);
}


use std::io;
use std::str::FromStr;

fn get_num() -> isize {
    let mut input = String::new();

    io::stdin().read_line(&mut input).expect("");

    isize::from_str(input.trim()).unwrap()
}

fn main() {
    let n = get_num();

    println!(
        "{}",
        std::cmp::max(n, std::cmp::max(n / 10, n % 10 * 10 + n / 100 * 10))
    );
}


use std::io;
use std::str;

pub struct Scanner<R> {
    reader: R,
    buffer: Vec<String>,
}

impl<R: io::BufRead> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self {
            reader,
            buffer: vec![],
        }
    }

    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            self.reader.read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {
    let n: u64 = scan.token();
    let mut ans: u64;
    if n == 1 {
        ans = 1;
    } else if n == 2 {
        ans = 2;
    } else if n == 3 {
        ans = 6;
    } else {
        // pick n and n - 1, find another number coprime to both
        ans = n * (n - 1);
        for p in (1..(n - 1)).rev() {
            if gcd(n, p) == 1 && gcd(n - 1, p) == 1 {
                ans *= p;
                break;
            }
        }
    }
    writeln!(out, "{}", ans).ok();
}

fn main() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = Scanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());
    solve(&mut scan, &mut out);
}


use std::io::stdin;
use std::process::exit;

#[allow(dead_code)]
fn input_strs() -> Vec<char> {
    let mut st = String::new();
    match stdin().read_line(&mut st) {
        Ok(_) => st.chars().collect(),
        Err(_) => panic!("err"),
    }
}

#[allow(dead_code)]
fn input_ints() -> Vec<u64> {
    let mut st = String::new();
    match stdin().read_line(&mut st) {
        Ok(_) => st.split_whitespace().map(|s| s.parse().unwrap()).collect(),
        Err(_) => panic!("err"),
    }
}

fn solve() {
    let l = input_ints();
    let n = l[0] as u32;
    if n % 2 == 0 {
        println!("{}", (n / 2).pow(n / 2));
    } else {
        println!("{}", 0);
    }
}

fn main() {
    solve();
    exit(0);
}