Vasya lives in a round building, whose entrances are numbered sequentially by integers from 1 to n. Entrance n and entrance 1 are adjacent.Today Vasya got bored and decided to take a walk in the yard. Vasya lives in entrance a and he decided that during his walk he will move around the house b entrances in the direction of increasing numbers (in this order entrance n should be followed by entrance 1). The negative value of b corresponds to moving |b| entrances in the order of decreasing numbers (in this order entrance 1 is followed by entrance n). If b = 0, then Vasya prefers to walk beside his entrance.    Illustration for n = 6, a = 2, b =  - 5. Help Vasya to determine the number of the entrance, near which he will be at the end of his walk.

The single line of the input contains three space-separated integers n, a and b (1 ≤ n ≤ 100, 1 ≤ a ≤ n,  - 100 ≤ b ≤ 100) — the number of entrances at Vasya's place, the number of his entrance and the length of his walk, respectively.

Print a single integer k (1 ≤ k ≤ n) — the number of the entrance where Vasya will be at the end of his walk.

NoteThe first example is illustrated by the picture in the statements.

//spnauti-rust
use std::io::*;
use std::str::*;
use std::fmt::Debug;
#[allow(unused_imports)] use std::cmp::Ordering::*;
#[allow(unused_imports)] use std::collections::*;

#[allow(unused_macros)]
macro_rules! a {
    ($c: tt, $x: expr, $y: expr) => {{
        let b = $y; let a = &mut $x;
        if b $c *a { *a = b; true } else { false }
    }};
}
struct WordReader<'a> { it : SplitAsciiWhitespace<'a>, }
#[allow(dead_code)]
impl<'a> WordReader<'a> {
    fn new<T: Read>(b: &mut String, mut r: T) -> WordReader {
        b.clear();
        r.read_to_string(b).ok();
        WordReader { it: b.split_ascii_whitespace() }
    }
    fn from_stdin(b: &mut String) -> WordReader {
        WordReader::new(b, stdin())
    }
    fn sl(&mut self) ->  &str { self.it.next().unwrap() }
    fn bs(&mut self) -> &[u8] { self.sl().as_bytes()    }
    fn s(&mut self) -> String { String::from(self.sl()) }
    fn i(&mut self) ->    i32 { self.p()                }
    fn u(&mut self) ->  usize { self.p()                }
    fn vi(&mut self, n: usize) -> Vec<i32> {
        self.vp::<i32>(n)
    }
    fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
        self.sl().parse::<T>().unwrap()
    }
    fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
        (0..n).map(|_| self.p()).collect()
    }
}

#[allow(dead_code)]
fn build_counting_hashmap<K: Eq + std::hash::Hash, T>(i: T) -> HashMap<K,usize>
    where T: Iterator<Item = K> {
    let mut m = HashMap::new();
    for k in i {
        let n = 1 + if let Some(&n) = m.get(&k) { n } else { 0 };
        m.insert(k, n);
    }
    m
}

fn main() {
    let mut bin = String::new();
    let mut input = WordReader::from_stdin(&mut bin);

    let n = input.i();
    let a = input.i();
    let b = input.i();
    println!("{}", ((a - 1 + b) % n + n) % n + 1);
}

#[allow(unused_imports)]
use std::cmp::{max,min};
#[allow(unused_imports)]
use std::collections::{HashMap,HashSet,VecDeque};

#[allow(unused_macros)]
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(),
            )+
        )
    }}
}

#[allow(unused_macros)]
macro_rules! readvec {
    ( $t:ty ) => {{
        let input = readln!();
        let mut input = input.split_whitespace();
        let mut result = Vec::new();
        for elem in input {
            result.push(elem.parse::<$t>().unwrap());
        }
        result
    }}
}

fn main() {
  let (n,a,mut b) = readln!(i32,i32,i32);
  if b < 0 {
    b = -b;
    b %= n;
    b = (n-b)%n;
  }
  println!("{}",1+((a-1+b)%n));
}


Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees.Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≤ x, y. There is a tree in such a point, and it has x + y bananas. There are no trees nor bananas in other points. Now, Okabe draws a line with equation . Okabe can select a single rectangle with axis aligned sides with all points on or under the line and cut all the trees in all points that are inside or on the border of this rectangle and take their bananas. Okabe's rectangle can be degenerate; that is, it can be a line segment or even a point.Help Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely.Okabe is sure that the answer does not exceed 1018. You can trust him.

The first line of input contains two space-separated integers m and b (1 ≤ m ≤ 1000, 1 ≤ b ≤ 10000).

Print the maximum number of bananas Okabe can get from the trees he cuts.

Note  The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas.

fn main() {
    let mut l = String::new();
    std::io::stdin().read_line(&mut l).unwrap();
    let mut mb = l.split_whitespace().map(|s| s.parse::<u64>().unwrap());
    let m = mb.next().unwrap();
    let b = mb.next().unwrap();

    let answer: u64 = (0..(b+1)).into_iter().map(|height| {
        let width = m * (b - height);

        let height_sum = height * (height+1) / 2;
        let width_sum = width * (width+1) / 2;

        height_sum * (width+1) + width_sum * (height+1)
    }).max().unwrap();
    println!("{}", answer);
}

use std::io::stdin;

fn main() {
    let mut input = String::new();
    stdin().read_line(&mut input).unwrap();
    let mut input = input.split_whitespace().map(|k| k.parse::<u64>().unwrap());
    let m = input.next().unwrap();
    let b = input.next().unwrap();

    let ans = (0..(m * b + 1)).map(|x| {
        let y = b - (x + m - 1) / m;
        let tmp = (x + 1) * (y + 1) * (x + y) / 2 ;
        tmp
    }).max().unwrap();

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

#[allow(unused_imports)]
use std::cmp;
use std::fs::File;
use std::io::Read;

#[allow(dead_code)]
fn pow_speedy_with_mod(mut p: i64, mut q: i64, m: i64) -> i64 {
    p %= m;
    let mut r = p;
    let mut ret: i64 = 1;
    while q > 0 {
        ret *= if q % 2 == 1 { r } else { 1 };
        r *= r;
        r %= m;
        q /= 2;
        ret %= m;
    }
    return ret;
}

#[allow(dead_code)]
fn comb(n: usize, k: usize, m: i64, frac: &[i64], frac_inv: &[i64]) -> i64 {
    let mut ret = 1i64;
    if n < k {
        return 0;
    }
    ret *= frac[n] * frac_inv[n - k];
    ret %= m;
    ret *= frac_inv[k];
    ret %= m;
    ret
}

fn main() {
    let inputstatus = 1;

    let mut buf = String::new();
    let filename = "inputrust.txt";

    if inputstatus == 0 {
        let mut f = File::open(filename).expect("file not found");
        f.read_to_string(&mut buf)
            .expect("something went wrong reading the file");
    } else {
        std::io::stdin().read_to_string(&mut buf).unwrap();
    }

    let mut iter = buf.split_whitespace();

    let a: i64 = iter.next().unwrap().parse().unwrap();
    let mut b: i64 = iter.next().unwrap().parse().unwrap();
    let mut ans: i64 = 0;
    for i in 0..b + 1 {
        let x = a * i;
        ans = cmp::max(ans, (x + b) * (x + 1) * (b + 1) / 2);
        b -= 1;
    }
    println!("{}", ans);
    // let n = iter.next().unwrap().parse().unwrap();

    // println!("{}", n);
    // println!("{:?}", cum_num);
}

use std::io::stdin;

fn main() {
    let mut input = String::new();
    stdin().read_line(&mut input).unwrap();
    let mut input = input.split_whitespace().map(|k| k.parse::<u32>().unwrap());
    let m = input.next().unwrap();
    let b = input.next().unwrap();

    let ans = (0..(m * b + 1)).map(|x| {
        let y = b - (x + m - 1) / m;
        (x + 1) * (y + 1) / 2 * (x + y)
    }).max().unwrap();

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

use std::io::stdin;

fn main() {
    let mut input = String::new();
    stdin().read_line(&mut input).unwrap();
    let mut input = input.split_whitespace().map(|k| k.parse::<u32>().unwrap());
    let m = input.next().unwrap();
    let b = input.next().unwrap();

    let ans = (0..(m * b + 1)).map(|x| {
        let y = b - (x + m - 1) / m;
        let tmp = (x + 1) * (y + 1) * (x + y) / 2 ;
        tmp
    }).max().unwrap();

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


Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. For example, numbers 47, 7744, 474477 are super lucky and 4, 744, 467 are not.One day Petya came across a positive integer n. Help him to find the least super lucky number which is not less than n.

The only line contains a positive integer n (1 ≤ n ≤ 10100000). This number doesn't have leading zeroes.

Output the least super lucky number that is more than or equal to n.

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

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

    fn next_line(&self) -> String {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).expect("Fail to read");
        line
    }

    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 line = self.next_line();
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }

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

fn find(src: u64, num: u64, n4: usize, n7: usize, result: &mut u64) {
    if num > 10000000000 {
        return;
    }
    if n4 == n7 && num >= src && (num - src) < (*result - src) {
        *result = num;
    }
    find(src, num * 10 + 4, n4 + 1, n7, result);
    find(src, num * 10 + 7, n4, n7 + 1, result);
}

fn _main() {
    let mut scan = Scan::new();
    let n: u64 = scan.next();
    let mut result = std::u64::MAX;
    find(n, 0, 0, 0, &mut result);
    println!("{}", result);
}

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

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

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

    fn next_line(&self) -> String {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).expect("Fail to read");
        line
    }

    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 line = self.next_line();
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }

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

fn find(src: u64, num: u64, n4: usize, n7: usize, result: &mut u64) {
    if num > 1000000000 {
        return;
    }
    if n4 == n7 && num >= src && (num - src) < (*result - src) {
        *result = num;
    }
    find(src, num * 10 + 4, n4 + 1, n7, result);
    find(src, num * 10 + 7, n4, n7 + 1, result);
}

fn _main() {
    let mut scan = Scan::new();
    let n: u64 = scan.next();
    let mut result = std::u64::MAX;
    find(n, 0, 0, 0, &mut result);
    println!("{}", result);
}

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


The three friends, Kuro, Shiro, and Katie, met up again! It's time for a party...What the cats do when they unite? Right, they have a party. Since they wanted to have as much fun as possible, they invited all their friends. Now $$$n$$$ cats are at the party, sitting in a circle and eating soup. The rules are simple: anyone having finished their soup leaves the circle.Katie suddenly notices that whenever a cat leaves, the place where she was sitting becomes an empty space, which means the circle is divided into smaller continuous groups of cats sitting next to each other. At the moment Katie observes, there are $$$m$$$ cats who left the circle. This raises a question for Katie: what is the maximum possible number of groups the circle is divided into at the moment?Could you help her with this curiosity?You can see the examples and their descriptions with pictures in the "Note" section.

The only line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq n \leq 1000$$$, $$$0 \leq m \leq n$$$) — the initial number of cats at the party and the number of cats who left the circle at the moment Katie observes, respectively.

Print a single integer — the maximum number of groups of cats at the moment Katie observes.

NoteIn the first example, originally there are $$$7$$$ cats sitting as shown below, creating a single group:  At the observed moment, $$$4$$$ cats have left the table. Suppose the cats $$$2$$$, $$$3$$$, $$$5$$$ and $$$7$$$ have left, then there are $$$3$$$ groups remaining. It is possible to show that it is the maximum possible number of groups remaining.  In the second example, there are $$$6$$$ cats sitting as shown below:  At the observed moment, $$$2$$$ cats have left the table. Suppose the cats numbered $$$3$$$ and $$$6$$$ left, then there will be $$$2$$$ groups remaining ($$$\{1, 2\}$$$ and $$$\{4, 5\}$$$). It is impossible to have more than $$$2$$$ groups of cats remaining.  In the third example, no cats have left, so there is $$$1$$$ group consisting of all cats.In the fourth example, all cats have left the circle, so there are $$$0$$$ groups.

//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: usize,
        m: usize,
    }
    let ans = if n == m {
        0
    } else if m <= 1 {
        1
    } else if m <= n / 2 {
        m
    } else {
        n - m
    };
    println!("{}", ans);
}

fn main() {
    run();
}


Ehab is interested in the bitwise-xor operation and the special graphs. Mahmoud gave him a problem that combines both. He has a complete graph consisting of n vertices numbered from 0 to n - 1. For all 0 ≤ u < v < n, vertex u and vertex v are connected with an undirected edge that has weight  (where  is the bitwise-xor operation). Can you find the weight of the minimum spanning tree of that graph?You can read about complete graphs in https://en.wikipedia.org/wiki/Complete_graphYou can read about the minimum spanning tree in https://en.wikipedia.org/wiki/Minimum_spanning_treeThe weight of the minimum spanning tree is the sum of the weights on the edges included in it.

The only line contains an integer n (2 ≤ n ≤ 1012), the number of vertices in the graph.

The only line contains an integer x, the weight of the graph's minimum spanning tree.

NoteIn the first sample:  The weight of the minimum spanning tree is 1+2+1=4.

fn main() {
    let mut input = String::new();
    use std::io;
    use std::io::prelude::*;
    io::stdin().read_to_string(&mut input).unwrap();

    let n: u64 = input.trim().parse().unwrap();

    let bc = n.next_power_of_two().trailing_zeros();

    let mut cb = 1;
    let mut ans = 0;
    for _ in 0..bc {
        let t = cb * ((n - 1 + cb) / (cb << 1));
        ans += t;
        cb <<= 1;
    }

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

macro_rules! parse_line {
    ($t: ty) => ({
        let mut a_str = String::new();
        std::io::stdin().read_line(&mut a_str).expect("read error");
        let a_str = a_str.trim();
        a_str.parse::<$t>().expect("parse error")
    });
    ($($t: ty),+) => ({
        let mut a_str = String::new();
        std::io::stdin().read_line(&mut a_str).expect("read error");
        let mut a_iter = a_str.split_whitespace();
        (
            $(
            a_iter.next().unwrap().parse::<$t>().expect("parse error"),
            )+
        )
    })
}

macro_rules! parse_line_to_vec {
    ($t: ty) => {{
        let mut a_str = String::new();
        std::io::stdin().read_line(&mut a_str).expect("read error");
        (a_str
            .split_whitespace()
            .map(|x| x.parse::<$t>().unwrap())
            .collect::<Vec<$t>>())
    }};
}

fn solve() {
    let mut n = parse_line!(u64);
    let mut result = 0;
    let mut add = 1;
    while n > 1 {
        result += n / 2 * add;
        add *= 2;
        n = (n + 1) / 2;
    }
    println!("{}", result);
}

fn main() {
    let tests = 1; // parse_line!(usize);
    for _ in 0..tests {
        solve();
    }
}


Andrey received a postcard from Irina. It contained only the words "Hello, Andrey!", and a strange string consisting of lowercase Latin letters, snowflakes and candy canes. Andrey thought that this string is an encrypted message, and decided to decrypt it.Andrey noticed that snowflakes and candy canes always stand after the letters, so he supposed that the message was encrypted as follows. Candy cane means that the letter before it can be removed, or can be left. A snowflake means that the letter before it can be removed, left, or repeated several times.For example, consider the following string:   This string can encode the message «happynewyear». For this, candy canes and snowflakes should be used as follows:   candy cane 1: remove the letter w,  snowflake 1: repeat the letter p twice,  candy cane 2: leave the letter n,  snowflake 2: remove the letter w,  snowflake 3: leave the letter e.   Please note that the same string can encode different messages. For example, the string above can encode «hayewyar», «happpppynewwwwwyear», and other messages.Andrey knows that messages from Irina usually have a length of $$$k$$$ letters. Help him to find out if a given string can encode a message of $$$k$$$ letters, and if so, give an example of such a message.

The first line contains the string received in the postcard. The string consists only of lowercase Latin letters, as well as the characters «*» and «?», meaning snowflake and candy cone, respectively. These characters can only appear immediately after the letter. The length of the string does not exceed $$$200$$$. The second line contains an integer number $$$k$$$ ($$$1 \leq k \leq 200$$$), the required message length.

Print any message of length $$$k$$$ that the given string can encode, or «Impossible» if such a message does not exist.

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(),
            )+
        )
    }}
}

#[derive(Debug)]
enum Group {
    Sequence(String),
    Optional(char),
    Some(char)
}

impl Group {
    fn is_sequence(&self) -> bool {
        match self {
            Group::Sequence(_) => true,
            _ => false
        }
    }

    fn get_sequence_mut(&mut self) -> &mut String {
        match self {
            Group::Sequence(ref mut seq) => seq,
            _ => panic!("kdkjndjfndi")
        }
    }
}

fn get_min_len(groups: &Vec<Group>) -> usize {
    let mut result = 0;
    for group in groups {
        match group {
            Group::Sequence(seq) => result += seq.len(),
            _ => {}
        }
    }
    result
}

fn get_max_len(groups: &Vec<Group>) -> Option<usize> {
    let mut result = 0;
    for group in groups {
        match group {
            Group::Sequence(seq) => result += seq.len(),
            Group::Optional(_) => result += 1,
            Group::Some(_) => return None
        }
    }
    Some(result)
}

fn generate(groups: &Vec<Group>, min_len: usize, dest_len: usize) -> String {
    let mut result = String::new();
    let mut left = dest_len - min_len;
    for group in groups {
        match group {
            Group::Sequence(seq) => result.push_str(&seq.to_string()),
            Group::Optional(ch) if left > 0 => {
                result.push(*ch);
                left -= 1;
            },
            Group::Some(ch) if left > 0 => {
                let mut to_push = String::with_capacity(left);
                for _ in 0..left {
                    to_push.push(*ch);
                }
                result.push_str(&to_push.to_string());
                left = 0;
            },
            _ => {}
        }
    }

    result
}

fn main() {
    let msg = readln!();
    let msg: Vec<char> = msg.chars().collect();

    let mut groups = Vec::new();

    let mut index = 0;
    while index < msg.len() - 1 {
        let len = groups.len();
        if msg[index + 1] == '?' {
            groups.push(Group::Optional(msg[index]));
            index += 2;
        } else if msg[index + 1] == '*' {
            groups.push(Group::Some(msg[index]));
            index += 2;
        } else if len == 0 || !groups[len - 1].is_sequence() {
            let mut to_push = String::new();
            to_push.push(msg[index]);
            groups.push(Group::Sequence(to_push));
            index += 1;
        } else {
            groups[len - 1].get_sequence_mut().push(msg[index]);
            index += 1;
        }
    }
    if index == msg.len() - 1 {
        let len = groups.len();
        if len == 0 || !groups[len - 1].is_sequence() {
            let mut to_push = String::new();
            to_push.push(msg[index]);
            groups.push(Group::Sequence(to_push));
        } else {
            groups[len - 1].get_sequence_mut().push(msg[index]);
        }
    }

    let dest_len = readln!(usize);
    let min_len = get_min_len(&groups);
    if min_len > dest_len {
        println!("Impossible");
        return;
    } if let Some(max_len) = get_max_len(&groups) {
        if max_len < dest_len {
            println!("Impossible");
            return;
        }
    }

    println!("{}", generate(&groups, min_len, dest_len));
}

use std::io;

macro_rules! parse_line {
    ($($t: ty),+) => ({
        let mut a_str = String::new();
        io::stdin().read_line(&mut a_str).expect("read error");
        let mut a_iter = a_str.split_whitespace();
        (
            $(
            a_iter.next().unwrap().parse::<$t>().expect("parse error"),
            )+
        )
    })
}

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let s = s.trim().as_bytes();
    let (k,) = parse_line!(i32);
    let (mut min_l, mut max_l) = (0, 0);
    for c in s.iter() {
        if c==&b'?' || c==&b'*' {
            min_l -= 1;
        } else {
            min_l += 1;
            max_l += 1;
        }
    }
    if k < min_l || (k > max_l && !s.contains(&b'*')) {
        println!("Impossible");
    } else {
        let mut r = Vec::new();
        let mut d = k - min_l;
        let l = s.len();
        for i in 0..l {
            if i+1 < l && s[i+1] == b'?' {
                if d > 0 {
                    r.push(s[i]);
                    d -= 1;
                }
            } else if i+1 < l && s[i+1] == b'*' {
                while d > 0 {
                    r.push(s[i]);
                    d -= 1;
                }
            } else if s[i] != b'?' && s[i] != b'*' {
                r.push(s[i]);
            }
        }
        println!("{}", String::from_utf8(r).unwrap());
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[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 ) * } } ; }
#[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 , 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" ) } ; }
#[allow(dead_code)]
pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
    let out = stdout();
    let writer = BufWriter::new(out.lock());
    f(writer)
}
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) } ; }
#[allow(dead_code)]
fn main() {
    input!{
        s: chars,
        k: usize,
    }
    let mut ans = s;
    let mut candy = 0;
    let mut snow = 0;
    for &c in &ans {
        if c == '?' {
            candy += 1;
        } else if c == '*' {
            snow += 1;
        }
    }
    let length = ans.len() - (candy + snow);
    debug!(length);
    if length < k {
        if snow == 0 {
            println!("Impossible");
            return;
        }
        let mut done = false;
        let mut i = 0;
        while i < ans.len() {
            if ans[i] == '?' {
                ans.remove(i);
                i -= 1;
            } else if ans[i] == '*' {
                ans.remove(i);
                i -= 1;
                if !done {
                    let x = ans[i];
                    let insert_pos = i;
                    for _j in 0..k-length {
                        ans.insert(insert_pos, x);
                        i += 1;
                    }
                    done = true;
                }
            }
            i += 1;
        }
    } else {
        if length - k > candy + snow {
            println!("Impossible");
            return;
        }
        let mut del = length - k;
        let mut index = 0;
        debug!(del);
        while del > 0 {
            if ans[index] == '?' || ans[index] == '*' {
                ans.remove(index-1);
                ans.remove(index-1);
                index -= 2;
                del -= 1;
            }
            index += 1;
        }
        debug!(ans);
        debug!(length);
        while index < ans.len() {
            if ans[index] == '?' || ans[index] == '*' {
                ans.remove(index);
                index -= 1;
            }
            index += 1;
        }
    }
    let str_ans: String = ans.into_iter().collect();
    println!("{}", str_ans);
}


«One dragon. Two dragon. Three dragon», — the princess was counting. She had trouble falling asleep, and she got bored of counting lambs when she was nine.However, just counting dragons was boring as well, so she entertained herself at best she could. Tonight she imagined that all dragons were here to steal her, and she was fighting them off. Every k-th dragon got punched in the face with a frying pan. Every l-th dragon got his tail shut into the balcony door. Every m-th dragon got his paws trampled with sharp heels. Finally, she threatened every n-th dragon to call her mom, and he withdrew in panic.How many imaginary dragons suffered moral or physical damage tonight, if the princess counted a total of d dragons?

Input data contains integer numbers k, l, m, n and d, each number in a separate line (1 ≤ k, l, m, n ≤ 10, 1 ≤ d ≤ 105).

NoteIn the first case every first dragon got punched with a frying pan. Some of the dragons suffered from other reasons as well, but the pan alone would be enough.In the second case dragons 1, 7, 11, 13, 17, 19 and 23 escaped unharmed.

#[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 k = scan!(i32);
    let l = scan!(i32);
    let m = scan!(i32);
    let n = scan!(i32);
    let v = scan!(i32);
    let mut cnt = 0;
    for i in 1..v+1 {
        if i % k == 0 || i % l == 0 || i % m == 0 || i % n == 0 { cnt += 1; }
    }
    println!("{}", cnt);
}

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

fn main() {
    let k = input();
    let l = input();
    let m = input();
    let n = input();
    let objects = [k, l, m, n];
    let d = input(); // total number of dragons

    // true if hit
    let mut dragons: Vec<bool> = Vec::with_capacity(d as usize);
    for _ in 0..d {
        dragons.push(false)
    }

    for step in objects.iter() {
        let mut index = *step;
        while index <= d {
            dragons[(index - 1) as usize] = true;
            index += step;
        }
    }

    println!("{}", dragons.iter().filter(|&&a| a).count());
}

//spnauti-rust
struct WordReader {
    it : std::vec::IntoIter<String>,
}
#[allow(dead_code)]
impl WordReader {
    fn new<T : std::io::Read>(mut reader : T) -> WordReader {
        let mut s = String::new();
        reader.read_to_string(&mut s).unwrap();
        WordReader { it : s
            .split_ascii_whitespace()
            .map(String::from).collect::<Vec<_>>()
            .into_iter()
        }
    }
    fn from_stdin() -> WordReader {
        WordReader::new(std::io::stdin())
    }
    fn s(&mut self) -> String {
        self.it.next().unwrap()
    }
    fn ab(&mut self) -> Vec<u8> {
        self.it.next().unwrap().into_bytes()
    }
    fn i(&mut self) -> i32 {
        self.it.next().unwrap().parse().unwrap()
    }
}

fn main() {
    let mut input = WordReader::from_stdin();
    let mut a = [0; 4];
    for x in a.iter_mut() {
        *x = input.i();
    }
    let n = input.i();
    let sol = (1..n+1).filter(|x| a.iter().any(|y| x % y == 0)).count();
    println!("{}", sol);
}

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

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

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

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

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

    let x = vec![k, l, m, n];
    let ret = (1..d + 1).fold(0, |total, i| if x.iter().any(|&k| i % k == 0) {
        total + 1
    } else {
        total
    });
    println!("{:?}", ret);
}

#[allow(unused_imports)]
use std::cmp::{min,max};
use std::collections::{*};
use std::io::{BufWriter, stdin, stdout, Write};
const BITS: usize = 19;

#[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 scanner = Scanner::default();
    let arr: [u64;5] = [scanner.next(), scanner.next(), scanner.next(), scanner.next(), scanner.next()];
    print!["{}", (1..=arr[4]).filter(|x| x % arr[0] == 0 || x % arr[1] == 0 || x % arr[2] == 0 || x % arr[3] == 0).count()];
}

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

fn main() {
    let stdin = io::stdin();
    let mut iterator = stdin.lock().lines();
    let mut damaged = 0;

    let k: i64 = iterator
        .next().unwrap().unwrap().parse().unwrap_or(0);
    let l: i64 = iterator
        .next().unwrap().unwrap().parse().unwrap_or(0);
    let m: i64 = iterator
        .next().unwrap().unwrap().parse().unwrap_or(0);
    let n: i64 = iterator
        .next().unwrap().unwrap().parse().unwrap_or(0);
    let d: i64 = iterator
        .next().unwrap().unwrap().parse().unwrap_or(0);

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

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

// {{{ by shik

use std::io;

#[allow(dead_code)]
fn gets() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(unused_macros)]
macro_rules! R {
    ( $ty:ty, ... ) => {
        gets().split_whitespace().map(|x| x.parse::<$ty>().unwrap()).collect::<Vec<_>>()
    };
    ( $($ty:ty),* ) => {{
        let line = gets();
        let mut it = line.split_whitespace();
        ( $(it.next().unwrap().parse::<$ty>().unwrap(),)* )
    }}
}

#[allow(unused_macros)]
macro_rules! W {
    ( $x:expr ) => {{
        println!("{}", $x);
    }};
    ( $x:expr, $($xs:expr),* ) => {{
        print!("{} ", $x);
        W!($($xs),*);
    }}
}

#[allow(unused_macros)]
macro_rules! join {
    ($x:expr, $($xs:expr),*; $sep:expr) => { concat!($x, $($sep, $xs),*) }
}

#[allow(unused_macros)]
macro_rules! dump {
    ($($x:expr),*) => {
        eprintln!(join!($(concat!(stringify!($x), " = {:?}")),*; ", "), $($x),*);
    }
}

// }}}

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

fn lcm(a: u32, b:u32) -> u32 {
    a * b / gcd(a, b)
}

macro_rules! lcm {
    ( $x:expr ) => {{
        $x
    }};
    ( $x:expr, $($xs:expr),* ) => {{
        lcm($x, lcm!($($xs),*))
    }}
}

fn main() {
    let (k, ) = R!(u32);
    let (l, ) = R!(u32);
    let (m, ) = R!(u32);
    let (n, ) = R!(u32);
    let (d, ) = R!(u32);
    println!("{}",
        d/k + d/l + d/m + d/n
        - d/lcm!(k,l) - d/lcm!(k,m) - d/lcm!(k,n) - d/lcm!(l,m) - d/lcm!(l,n) - d/lcm!(m,n)
        + d/lcm!(k,l,m) + d/lcm!(k,l,n) + d/lcm!(k,m,n) + d/lcm!(l,m,n)
        - d/lcm!(k,l,m,n));
}

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 k: u32 = read(sin);
    let l: u32 = read(sin);
    let m: u32 = read(sin);
    let n: u32 = read(sin);
    let d: u32 = read(sin);

    let ans = (1..d + 1)
        .filter(|x| *x % k == 0 || *x % l == 0 || *x % m == 0 || *x % n == 0)
        .count();

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

// https://codeforces.com/problemset/problem/148/A
use std::io;

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

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

    let k: i64 = k.trim().parse().unwrap();

    let mut l = String::new();

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

    let l: i64 = l.trim().parse().unwrap();

    let mut m = String::new();

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

    let m: i64 = m.trim().parse().unwrap();

    let mut n = String::new();

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

    let n: i64 = n.trim().parse().unwrap();

    let mut d = String::new();

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

    let d: i64 = d.trim().parse().unwrap();

    let mut dragons = 0;

    for idx in 1..d+1 {
        if idx % k == 0
            || idx % l == 0
            || idx % m == 0
            || idx % n == 0 {
            dragons += 1;
        }
    }

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

use std::io::{self, prelude::*};

#[allow(unused_must_use)]
#[allow(unused_assignments)]
#[allow(unused_variables)]
fn solve<B: BufRead, W: Write>(mut scan: Scanner<B>, mut w: W) {
    let k = scan.token::<usize>();
    let l = scan.token::<usize>();
    let m = scan.token::<usize>();
    let n = scan.token::<usize>();
    let d = scan.token::<usize>();

    let mut arr = vec![false; d];

    for i in (0..d).skip(k-1).step_by(k) {
        arr[i] = true;
    }
    for i in (0..d).skip(l-1).step_by(l) {
        arr[i] = true;
    }
    for i in (0..d).skip(m-1).step_by(m) {
        arr[i] = true;
    }
    for i in (0..d).skip(n-1).step_by(n) {
        arr[i] = true;
    }

    let ans: usize = arr.iter().filter(|&e| *e).count();

    writeln!(w, "{}", ans);
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    let reader = Scanner::new(stdin.lock());
    let writer = io::BufWriter::new(stdout.lock());
    solve(reader, writer);
}
#[allow(dead_code)]
fn vector_to_str<T: ToString>(vector: &Vec<T>, separator: &str) -> String {
    use std::fmt::Write;
    let mut ans = String::new();
    for line in vector.iter() {
        write!(&mut ans, "{}{}", line.to_string(), separator).unwrap();
    }
    ans
}
#[allow(dead_code)]
fn matrix_to_str<T: ToString>(matrix: &Vec<Vec<T>>, separator: &str) -> String {
    use std::fmt::Write;
    let mut ans = String::new();
    for line in matrix.iter() {
        for elem in line.iter() {
            write!(&mut ans, "{}{}", elem.to_string(), separator).unwrap();
        }
        write!(&mut ans, "\n").unwrap();
    }
    ans
}
pub struct Scanner<B> {
    reader: B,
    buf_str: Vec<u8>,
    buf_iter: std::str::SplitWhitespace<'static>,
}
impl<B: BufRead> Scanner<B> {
    pub fn new(reader: B) -> Self {
        Self {
            reader,
            buf_str: Vec::new(),
            buf_iter: "".split_whitespace()
        }
    }
    pub fn token<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buf_iter.next() {
                return token.parse().ok().expect("Failed parse");
            }
            self.buf_str.clear();
            self.reader.read_until(b'\n', &mut self.buf_str).expect("Failed read");
            self.buf_iter = unsafe {
                let slice = std::str::from_utf8_unchecked(&self.buf_str);
                std::mem::transmute(slice.split_whitespace()) }
        }
    }
    pub fn get_matrix<T: std::str::FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>> {
        // m rows and n columns
        let mut ans: Vec<Vec<T>> = Vec::with_capacity(m);
        for i in 0..m {
            ans.push(Vec::with_capacity(n));
            for _ in 0..n {
                ans[i].push(self.token::<T>());
            }
        }
        ans
    }
    pub fn get_vector<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        let mut ans: Vec<T> = Vec::with_capacity(n);
        for _ in 0..n {
            ans.push(self.token::<T>());
        }
        ans
    }
}

use std::io;

fn main() {
    let mut s = String::new();
    for i in 0..5 {
        io::stdin().read_line(&mut s).unwrap();
    }
    let arr : Vec<i32> = s.split_whitespace().map(|s| s.parse().unwrap()).collect();
    let mut cnt = 0;
    for i in 1..arr[4]+1 {
        let mut flag = true;
        for j in 0..4 {
            if i % arr[j as usize] == 0 {
                flag = false;
            }
        }
        if flag == false {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}

use std::str::FromStr;
use std::fmt::Debug;

fn main() {
    let mut c = 0;
    let k = read_line().to::<usize>();
    let l = read_line().to::<usize>();
    let m = read_line().to::<usize>();
    let n = read_line().to::<usize>();
    let d = read_line().to::<usize>();

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

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

fn read_line() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Ошибка чтения");

    buffer.trim().to_string()
}

trait ParseStr {
    fn to_vec<T>(&self, separator: &str) -> Vec<T>
    where
        T: FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug;

    fn to_vec_chars(&self) -> Vec<char>;

    fn to<T>(&self) -> T
    where
        T: FromStr + Copy,
        <T as std::str::FromStr>::Err: Debug;
}

impl ParseStr for String {

    fn to_vec<T>(&self, separator: &str) -> Vec<T>
    where
        T: FromStr,
        <T as std::str::FromStr>::Err: Debug,
    {
        self.split(separator).map(|c| c.parse::<T>().expect("Ошибка преобразования")).collect()
    }

    fn to_vec_chars(&self) -> Vec<char> {
        self.chars().collect()
    }

    fn to<T>(&self) -> T
    where
        T: FromStr + Copy,
        <T as std::str::FromStr>::Err: Debug,
    {
        ParseStr::to_vec::<T>(self, " ")[0]
    }
}

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 (k, l, m, n, d): (u32, u32, u32, u32, u32) = (
        read_int(), read_int(), read_int(), read_int(), read_int());

    let mut total: u32 = 0;
    for index in 1..d + 1 {
        if index % k == 0 { total += 1; }
        else if index % l == 0 { total += 1; }
        else if index % m == 0 { total += 1; }
        else if index % n == 0 { total += 1; }
    }
    print!("{}", total);
}

use std::io;
use std::io::{Write};
use std::str;

/// Reads white-space separated tokens one at a time.
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![],
        }
    }

    /// Use "turbofish" syntax token::<T>() to select data type of next token.
    ///
    /// # Panics
    ///
    /// Panics if there's an I/O error or if the token cannot be parsed as T.
    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();
        }
    }
}

/// Same API as Scanner but nearly twice as fast, using horribly unsafe dark arts
/// **REQUIRES** Rust 1.34 or higher
pub struct UnsafeScanner<R> {
    reader: R,
    buf_str: Vec<u8>,
    buf_iter: str::SplitAsciiWhitespace<'static>,
}

impl<R: io::BufRead> UnsafeScanner<R> {
    pub fn new(reader: R) -> Self {
        Self {
            reader,
            buf_str: vec![],
            buf_iter: "".split_ascii_whitespace(),
        }
    }

    /// This function should be marked unsafe, but noone has time for that in a
    /// programming contest. Use at your own risk!
    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buf_iter.next() {
                return token.parse().ok().expect("Failed parse");
            }
            self.buf_str.clear();
            self.reader
                .read_until(b'\n', &mut self.buf_str)
                .expect("Failed read");
            self.buf_iter = unsafe {
                let slice = str::from_utf8_unchecked(&self.buf_str);
                std::mem::transmute(slice.split_ascii_whitespace())
            }
        }
    }
}

pub fn scanner_from_file(filename: &str) -> Scanner<io::BufReader<std::fs::File>> {
    let file = std::fs::File::open(filename).expect("Input file not found");
    Scanner::new(io::BufReader::new(file))
}

pub fn writer_to_file(filename: &str) -> io::BufWriter<std::fs::File> {
    let file = std::fs::File::create(filename).expect("Output file not found");
    io::BufWriter::new(file)
}

fn solve() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = Scanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());
    let  k = scan.token::<i32>();
    let  l = scan.token::<i32>();
    let  m = scan.token::<i32>();
    let  n = scan.token::<i32>();
    let  d = scan.token::<i32>();
    let mut ans = 0;
    for i in 1..=d {
        if i % k == 0 || i % l == 0 || i % m == 0 || i % n == 0 {
            ans += 1;
        }
    }
    out.write(format!("{}", ans).as_bytes()).unwrap();
    // let k = scan.token::<i32>();
    // let mut arr = scan.token::<String>().chars().collect::<Vec<char>>();
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024)
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}

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

fn read_line(stdin : &Stdin, line : &mut String) {
    match stdin.read_line(line) {
        Ok(_) => return,
        Err(msg) => panic!("Could not read line! Message: {}.", msg),
    }
}

fn parse_t<T : FromStr>(s : &str) -> T {
    match s.trim().parse() {
        Ok(y) => y,
        Err(_) => panic!("Could not read from string!"),
    }
}

fn read_t<T : FromStr>(stdin : &Stdin) -> T {
    let mut line = String::new();
    read_line(stdin, &mut line);
    parse_t(&line)
}

fn gcd(a : u64, b : u64) -> u64 {
    let mut t_a = if a > b { a } else { b };
    let mut t_b = if t_a == a { b } else { a };
    loop {
        if t_b == 0 {
            return t_a;
        } else {
            let t_a_mod_t_b = t_a % t_b;
            t_a = t_b;
            t_b = t_a_mod_t_b;
        }
    }
}

fn lcm(a : u64, b : u64) -> u64 {
    let g = gcd(a, b);
    (a / g) * b
}

macro_rules! lcm_list {
    ($x:expr) => ($x);
    ($x:expr, $($y:expr),+) => (
        lcm($x, lcm_list!($($y),+))
    )
}

fn num_damaged_dragons(k : u64, l : u64, m : u64, n : u64, d : u64) -> u64 {
    let t_k = d / k;
    let t_l = d / l;
    let t_m = d / m;
    let t_n = d / n;
    let t_k_l = d / lcm_list!(k, l);
    let t_k_m = d / lcm_list!(k, m);
    let t_k_n = d / lcm_list!(k, n);
    let t_l_m = d / lcm_list!(l, m);
    let t_l_n = d / lcm_list!(l, n);
    let t_m_n = d / lcm_list!(m, n);
    let t_k_l_m = d / lcm_list!(k, l, m);
    let t_k_l_n = d / lcm_list!(k, l, n);
    let t_k_m_n = d / lcm_list!(k, m, n);
    let t_l_m_n = d / lcm_list!(l, m, n);
    let t_k_l_m_n = d / lcm_list!(k, l, m, n);
    let t_1 = t_k + t_l + t_m + t_n;
    let t_2 = t_k_l + t_k_m + t_k_n + t_l_m + t_l_n + t_m_n;
    let t_3 = t_k_l_m + t_k_l_n + t_k_m_n + t_l_m_n;
    let t_4 = t_k_l_m_n;
    t_1 - t_2 + t_3 - t_4
}

fn main() {
    let stdin = io::stdin();
    let k = read_t(&stdin);
    let l = read_t(&stdin);
    let m = read_t(&stdin);
    let n = read_t(&stdin);
    let d = read_t(&stdin);
    let r = num_damaged_dragons(k, l, m, n, d);
    println!("{}", r);
}

fn main() {
    let (k, l, m, n, d) = {
        let mut bufs: Vec<usize> = Vec::new();
        for _ in 0..5 {
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).unwrap();
            bufs.push(buf.trim_end().parse().unwrap());
        }
        (bufs[0], bufs[1], bufs[2], bufs[3], bufs[4])
    };

    let mut ans = 0;
    for i in 0..d {
        let num = i + 1;
        if num % k == 0 || num % l == 0 || num % m == 0 || num % n == 0 {
            ans += 1
        }
    }
    println!("{}", ans);
}

fn readln() -> Vec<i32> {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();

    line.split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect()
}

fn main() {
    let mut input = readln();
    let k = input[0];
    input = readln();
    let l = input[0];
    input = readln();
    let m = input[0];
    input = readln();
    let n = input[0];
    input = readln();
    let d = input[0];

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

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

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 1..=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 = 0;
    for i in 1..nd+1 {
        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(non_snake_case, unused_imports)]

// Input 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)*} }; }
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)*} }; }
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, [ $t:tt ]) => { { let len = read_value!($next, usize); (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") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,VecDeque,BinaryHeap};

// Functions

// Main
fn main(){

    input!{
        K: usize,
        L: usize,
        M: usize,
        N: usize,
        D: usize
    }

    let mut ans = 0;
    for d in 1..D+1{
        if d%K==0 || d%L==0 || d%M==0 || d%N==0{
            ans += 1;
        }
    }
    println!("{}", ans);
}

#[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 = (1..=d).filter(|x| x % k == 0 || x % l == 0 || x % m == 0 || x % n == 0).count();
    writeln!(out, "{}", res).expect("fail");
}

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

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

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

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

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

    let x = vec![k, l, m, n];
    let ret = (0..d).fold(0, |total, i| if x.iter().any(|&k| i % k == 0) {
        total + 1
    } else {
        total
    });
    println!("{:?}", ret);
}

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 (k, l, m, n, d): (u32, u32, u32, u32, u32) = (
        read_int(), read_int(), read_int(), read_int(), read_int());

    let mut total: u32 = 0;
    for index in 0..d {
        if index % k == 0 { total += 1; }
        else if index % l == 0 { total += 1; }
        else if index % m == 0 { total += 1; }
        else if index % n == 0 { total += 1; }
    }
    print!("{}", total);
}

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 (k, l, m, n, d): (u32, u32, u32, u32, u32) = (
        read_int(), read_int(), read_int(), read_int(), read_int());

    let mut total: u32 = 0;
    for index in 1..d {
        if index % k == 0 { total += 1; }
        else if index % l == 0 { total += 1; }
        else if index % m == 0 { total += 1; }
        else if index % n == 0 { total += 1; }
    }
    print!("{}", total);
}

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");
}


After passing a test, Vasya got himself a box of $$$n$$$ candies. He decided to eat an equal amount of candies each morning until there are no more candies. However, Petya also noticed the box and decided to get some candies for himself.This means the process of eating candies is the following: in the beginning Vasya chooses a single integer $$$k$$$, same for all days. After that, in the morning he eats $$$k$$$ candies from the box (if there are less than $$$k$$$ candies in the box, he eats them all), then in the evening Petya eats $$$10\%$$$ of the candies remaining in the box. If there are still candies left in the box, the process repeats — next day Vasya eats $$$k$$$ candies again, and Petya — $$$10\%$$$ of the candies left in a box, and so on.If the amount of candies in the box is not divisible by $$$10$$$, Petya rounds the amount he takes from the box down. For example, if there were $$$97$$$ candies in the box, Petya would eat only $$$9$$$ of them. In particular, if there are less than $$$10$$$ candies in a box, Petya won't eat any at all.Your task is to find out the minimal amount of $$$k$$$ that can be chosen by Vasya so that he would eat at least half of the $$$n$$$ candies he initially got. Note that the number $$$k$$$ must be integer.

The first line contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^{18}$$$) — the initial amount of candies in the box.

Output a single integer — the minimal amount of $$$k$$$ that would allow Vasya to eat at least half of candies he got.

NoteIn the sample, the amount of candies, with $$$k=3$$$, would change in the following way (Vasya eats first):$$$68 \to 65 \to 59 \to 56 \to 51 \to 48 \to 44 \to 41 \\ \to 37 \to 34 \to 31 \to 28 \to 26 \to 23 \to 21 \to 18 \to 17 \to 14 \\ \to 13 \to 10 \to 9 \to 6 \to 6 \to 3 \to 3 \to 0$$$.In total, Vasya would eat $$$39$$$ candies, while Petya — $$$29$$$.

// 991C
use std::io;
fn main() {
    let n: u64 = read_one(&io::stdin());
    let mut min = 0;
    let mut max = n;
    loop {
        let mid = (min + max) / 2;
        if mid == min {
            break;
        }
        if eats_half(n, mid) {
            max = mid;
        } else {
            min = mid;
        }
    }
    println!("{}", max);
}

fn eats_half(mut n: u64, k: u64) -> bool {
    let original_n = n;
    let mut v = 0;
    while n >= k {
        n -= k;
        v += k;
        n -= n / 10;
    }
    v += n;
    return 2 * v >= original_n;
}

fn read_one<T>(stdin: &io::Stdin) -> T
where
    T: std::str::FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin.read_line(&mut s).unwrap();
    s.trim().split_whitespace().next().unwrap().parse().unwrap()
}

use std::io;

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

    let mut l: u64 = 1;
    let mut r: u64 = n;
    let mut m: u64;

    if tryv(n, 1) { println!("1"); return; }

    loop {
        // println!("l: {}, r: {}", l, r);
        if l + 1 == r {
            break;
        }
        m = (l + r) / 2;
        // println!("m: {}", m);
        if tryv(n, m) {
            r = m;
        } else {
            l = m;
        }
    }

    if tryv(n, l) {
        println!("{}", l);
    } else {
        println!("{}", r);
    }
    return;
}

fn tryv(nn: u64, k: u64) -> bool {
    // println!("n: {}, k: {}", nn, k);
    // println!("=====================");
    if k == 0 { return false; }
    let mut n = nn;
    let mut v: u64 = 0;
    loop {
        if v >= nn/2 + nn%2{
            return true;
        } else if v + n < nn/2 + nn%2 {
            return false;
        }

        if k >= n {
            v += n;
            n = 0;
        } else {
            v += k;
            n -= k;
        }

        n -= n/10;
        // println!("left: {}, vasya: {}", n, v);
    }
}

fn main() {
    let mut input = String::new();
    use std::io::{self, prelude::*};
    io::stdin().read_to_string(&mut input).unwrap();

    let n: u64 = input.trim().parse().unwrap();

    let check = |k| {
        let mut n = n;

        let mut v = 0;
        let mut p = 0;
        loop {
            if n < k {
                v += n;
                break;
            }
            n -= k;
            v += k;

            let q = n / 10;
            n -= q;
            p += q;
        }

        p <= v
    };

    let mut low = 0;
    let mut up = (n + 1) / 2;

    while low + 1 != up {
        let cur = (low + up) / 2;
        if check(cur) {
            up = cur;
        } else {
            low = cur;
        }
    }

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

use std::io;

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

    let mut l: u64 = 1;
    let mut r: u64 = (n/2) + (n%2);
    let mut m: u64;

    if tryv(n, 1) { println!("1"); return; }

    loop {
        if l + 1 == r {
            break;
        }
        m = (l + r) / 2;
        if tryv(n, m) {
            r = m;
        } else {
            l = m;
        }
    }

    println!("{}", r);
    return;
}

fn tryv(nn: u64, k: u64) -> bool {
    // println!("n: {}, k: {}", nn, k);
    // println!("=====================");
    if k == 0 { return false; }
    let mut n = nn;
    let mut v: u64 = 0;
    loop {
        if v >= nn/2 {
            return true;
        } else if v + n < nn/2 {
            return false;
        }

        if k >= n {
            v += n;
            n = 0;
        } else {
            v += k;
            n -= k;
        }

        n -= n/10;
        // println!("left: {}, vasya: {}", n, v);
    }
}

fn main() {
    let mut input = String::new();
    use std::io::{self, prelude::*};
    io::stdin().read_to_string(&mut input).unwrap();

    let n: u64 = input.trim().parse().unwrap();

    let check = |k| {
        let mut n = n;

        let mut v = 0;
        let mut p = 0;
        loop {
            if n < k {
                n = 0;
                v += n;
                break;
            }
            n -= k;
            v += k;

            let q = n / 10;
            n -= q;
            p += q;
        }

        p <= v
    };

    let mut low = 0;
    let mut up = (n + 1) / 2;

    while low + 1 != up {
        let cur = (low + up) / 2;
        if check(cur) {
            up = cur;
        } else {
            low = cur;
        }
    }

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