#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

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

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (n, k) = get!(u64, u64);

    let mut ans = 1;

    if k > 1 {
        for i in 2..k + 1 {
            let u = (n - i + 1..n + 1).fold(1, |a, b| a * b);
            let d = (1..i + 1).fold(1, |a, b| a * b);

            let c = u / d;

            ans += c * [1, 2, 9][(i - 2) as usize];
        }
    }

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

fn main() {
    let v: Vec<i64> = vec![1,0,1,2,9];
    let mut ri = ReadIn::new();
    let tp = ri.int2();
    let mut ans:i64 = 1;
    for kk in 2..tp.1+1 {
        ans += cal(tp.0 as i64, kk as i64) * v[(kk as usize)] ;
    }
    println!("{}", ans)
}

fn cal(n: i64, k: i64) -> i64{
    let mut up: i64 = 1;
    let mut down: i64 = 1;
    for kk in 0..k {
        up = up * (n - kk);
        down = down * (1 + kk);
    }
    up / down
}

use std::iter::Map;
use std::str::SplitWhitespace;
use std::io::stdin;
use std::mem::forget;

pub struct ReadIn(pub String);

impl ReadIn {
    pub fn new() -> ReadIn {
        ReadIn(String::new())
    }
    fn read_i32(s: &str) -> i32 {
        s.parse().unwrap()
    }
    pub fn read_line(&mut self) {
        self.0.clear();
        forget(stdin().read_line(&mut self.0));
    }
    pub fn ints(&mut self) -> Map<SplitWhitespace, fn(&str) -> i32> {
        self.read_line();
        self.0.split_whitespace().map(ReadIn::read_i32)
    }
    pub fn int(&mut self) -> i32 {
        self.ints().next().unwrap()
    }
    pub fn int2(&mut self) -> (i32, i32) {
        let mut it = self.ints();
        (it.next().unwrap(), it.next().unwrap())
    }
}


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

fn get_nums() -> (usize, usize, usize, usize) {
    let mut input = String::new();

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

    let v = input
        .trim()
        .split_whitespace()
        .map(|s| usize::from_str(s).unwrap())
        .collect::<Vec<_>>();

    (v[0], v[1], v[2], v[3])
}

fn main() {
    let (a, b, c, d) = get_nums();

    let misha = std::cmp::max(3 * a / 10, a - a / 250 * c);
    let vasya = std::cmp::max(3 * b / 10, b - b / 250 * d);

    if misha > vasya {
        println!("Misha");
    } else if misha < vasya {
        println!("Vasya");
    } else {
        println!("Tie");
    }
}

//spnauti-rust
use std::io::*;
use std::str::*;
use std::fmt::Debug;
#[allow(unused_imports)] use std::cmp::Ordering::{self,*};
#[allow(unused_imports)] use std::ops::*;
#[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 a = input.i();
    let b = input.i();
    let c = input.i();
    let d = input.i();
    println!("{}", match ((a * 3 / 10).max(a - a/250 * c)).cmp(&(b * 3 / 10).max(b - b/250 * d)) {
        Greater => "Misha",
        Less => "Vasya",
        Equal => "Tie",
    });
}

#[allow(unused_imports)]
use std::cmp::{max,min,Ordering};
#[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 solve(a: i64, t: i64) -> i64 {
  return max((a*3)/10,a-(a/250)*t);
}

fn main() {
  let (a,b,c,d) = readln!(i64,i64,i64,i64);
  let p1 = solve(a,c);
  let p2 = solve(b,d);
  println!("{}",if p1 < p2 { "Vasya" } else if p1 > p2 { "Misha" } else { "Tie" });
}

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

fn score(p: i32, t: i32) -> i32 {
    std::cmp::max(3 * p / 10, p - p / 250 * t)
}

fn main() {
    let stdin = io::stdin();
    let line = stdin.lock().lines().next().unwrap().unwrap();
    let v: Vec<_> = line.split(" ").map(|x| x.parse::<i32>().unwrap()).collect();
    let (a, b, c, d) = (v[0], v[1], v[2], v[3]);
    let misha = score(a,c);
    let vasya = score(b,d);
    match vasya.cmp(&misha) {
        Ordering::Greater => println!("Vasya"),
        Ordering::Equal => println!("Tie"),
        Ordering::Less => println!("Misha"),
    }
}

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

fn get_nums() -> (usize, usize, usize, usize) {
    let mut input = String::new();

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

    let v = input
        .trim()
        .split_whitespace()
        .map(|s| usize::from_str(s).unwrap())
        .collect::<Vec<_>>();

    (v[0], v[1], v[2], v[3])
}

fn main() {
    let (a, b, c, d) = get_nums();

    let misha = std::cmp::max(3 * a / 10, a / 250 * c);
    let vasya = std::cmp::max(3 * b / 10, b / 250 * d);

    if misha > vasya {
        println!("Misha");
    } else if misha < vasya {
        println!("Vasya");
    } else {
        println!("Tie");
    }
}


use std::collections::HashSet;
use std::io::*;

fn reads<T: std::str::FromStr>(i: &mut StdinLock) -> Vec<T> {
    let mut s = String::new();
    i.by_ref().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    // initialize stdin
    let sin = std::io::stdin();
    let mut sin = sin.lock();
    let sin = &mut sin;
    let input: Vec<u64> = reads(sin);

    let mut set = HashSet::new();

    for c in input {
        set.insert(c);
    }

    println!("{}", 4 - set.len());
}

//! http://codeforces.com/contest/228/problem/A

fn main() {
  use std::io;
  let mut buf = String::new();
  io::stdin().read_line(&mut buf).unwrap();
  let mut ns: Vec<u32> = buf.split(" ")
    .map(|str| str.trim().parse::<u32>().unwrap())
    .collect();
  ns.sort();
  let mut last = 0;
  let mut shoes = 0;
  for n in ns {
    if n != last { shoes += 1; last = n; }
  }
  println!("{}", 4 - shoes);
}

#[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)] use std::thread::*;
#[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 _ in 0..$n { let t = s.next(); if t == None { break; }
        v.push(t.unwrap().parse::<$T>().unwrap()); } v }),+)
    }}; }
///////////////////////////////////////////////////////////////////////////////

fn main()
{
    let mut a = arr!(4usize, i32);
    a.sort_by(|x, y| x.cmp(&y));
    println!("{}", (1..4).filter(|&x| a[x] == a[x-1]).count());
}

fn input_split() -> Vec<u64> {
    let mut buf = String::with_capacity(7);
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|elem| elem.parse().unwrap())
        .collect()
}

fn main() {
    let mut shoes = input_split();
    shoes.sort_unstable();
    shoes.dedup();
    println!("{}", 4 - shoes.len());
}

//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 ai(&mut self, n: usize) -> Vec<i32> {
        let mut a = Vec::with_capacity(n);
        for _ in 0..n { a.push(self.i()); }
        a
    }
}

fn main() {
    let mut input = WordReader::from_stdin();
    let mut a = input.ai(4);
    a.sort();
    a.dedup();
    let sol = 4 - a.len();
    println!("{}", sol);
}

#[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 mut s: BTreeSet<u64> = BTreeSet::new();
    for i in 1..=4 {
    	s.insert(scanner.next());
    }
    println!["{}", 4 - s.len()];
}

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

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

    let line = iterator.next().unwrap().unwrap();
    let colors: Vec<&str> = line
        .split_whitespace()
        .collect();

    let unique: HashSet<_> = colors.iter().cloned().collect();

    let unique_count: i32 = unique.len() as i32;
    println!("{}", (unique_count-4).abs());
}

use std::collections::HashSet;
use std::io::stdin;

fn main() {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();

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

    let mut lista_sin_repetidos = HashSet::new();

    for i in line {
        lista_sin_repetidos.insert(i);
    }

    println!("{}", 4 - lista_sin_repetidos.len());
}

// {{{ 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 main() {
    let mut ns = R!(usize, ...);
    ns.sort();
    ns.dedup();
    println!("{}", 4 - ns.len());
}

#![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;

// -----------------------------------------------

#[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 main() {
    let input = rl();

    let mut s = HashSet::new();

    input
        .split(" ")
        .for_each(|t| {
            s.insert(t);
        });

    println!("{}", 4-s.len());

	return;
}

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

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_ts<T: FromStr>(stdin: &Stdin, ts: &mut Vec<T>) {
    let mut line = String::new();
    read_line(stdin, &mut line);
    let word_iter = line.split_whitespace();
    for word in word_iter {
        let x = parse_t(word);
        ts.push(x);
    }
}

fn read_i64(stdin: &Stdin) -> i64 {
    let mut line = String::new();
    read_line(&stdin, &mut line);
    match line.trim().parse() {
        Ok(i) => i,
        Err(e) => {
            panic!("Could not read i64!");
        }
    }
}

fn main() {
    let stdin = io::stdin();
    let mut v:Vec<i64>= vec![];
    read_ts(&stdin, &mut v);
    let mut hs = HashSet::new();
    for i in v {
        hs.insert(i);
    }
    println!("{}", 4 - hs.len());
}

// https://codeforces.com/problemset/problem/228/A
use std::io;
use std::collections::HashSet;

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

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

    let words: Vec<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let mut horseshoes = HashSet::new();

    for item in words {
        horseshoes.insert(item);
    }

    println!("{}", 4-horseshoes.len());

}

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 mut input: Vec<i64> = scan.get_vector(4);

    input.sort();
    input.dedup();
    let ans: usize = 4 -input.len();

    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::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_hash<T: FromStr + std::cmp::Eq + std::hash::Hash>() -> std::collections::HashSet<T> {
    read_str()
        .split_whitespace()
        .map(|value| value.parse::<T>().ok().expect("Error"))
        .collect()
}

fn main() {
    let shoes: std::collections::HashSet<u32> = read_hash();
    print!("{}", 4 - shoes.len());
}

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();
    let a: usize = scan.next();
    let b: usize = scan.next();
    let c: usize = scan.next();
    let d: usize = scan.next();
    let eq: [bool;3]  = [a==b || a==c || a==d, b==c || b==d, c==d];
    let result: usize = eq.iter().map(|&x| (x as usize))
        .fold(0,|sum, x| sum+x);
    println!("{}", result);
}

use std::collections::BTreeSet;
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_ts<T : FromStr>(stdin : &Stdin, ts : &mut Vec<T>) {
    let mut line = String::new();
    read_line(stdin, &mut line);
    let word_iter = line.split_whitespace();
    for word in word_iter {
        let x = parse_t(word);
        ts.push(x);
    }
}

fn main() {
    let stdin = io::stdin();
    let mut cols : Vec<u64> = vec![];
    read_ts(&stdin, &mut cols);
    let mut distinct_cols = BTreeSet::new();
    for c in cols {
        distinct_cols.insert(c);
    }
    println!("{}", 4 - distinct_cols.len());
}

use std::collections::HashSet;

fn main() {
    let a: HashSet<u32> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let ws = buf.split_whitespace();
        ws.map(|c| c.parse().unwrap()).collect()
    };

    println!("{}", 4 - a.len());
}

fn readln() -> Vec<i32> {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect()
}
fn main() {
    let mut colors = readln();
    colors.sort();

    let mut ans = 0;

    for i in 1..4 {
        if colors[i - 1] == colors[i] {
            ans += 1;
        }
    }

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

fn main() {
	let mut inp = String::new();
	std::io::stdin().read_line(&mut inp).unwrap();
	let inp: Vec<i32> = inp
		.split_whitespace()
		.map(|x| x.parse::<i32>().unwrap())
		.collect();

	let mut exist: Vec<i32> = vec![];
	let mut ans = 0;
	for i in inp {
		if exist.contains(&i) {
			ans += 1;
		} else {
			exist.push(i);
		}
	}
	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 n = 4;
    let mut p = (0..n).map(|_| scan.next::<u64>()).collect::<Vec<u64>>();
    p.sort();
    p.dedup();

    writeln!(out, "{}", n - p.len()).expect("fail");
}


use std::io::stdin;
use std::collections::HashSet;

fn read_line<'a>() -> Result<String, Box<std::error::Error>> {
    let mut line = String::new();
    stdin().read_line(&mut line)?;

    Ok(line.trim().to_owned())
}

fn main() -> Result<(), Box<std::error::Error>> {
    let line = read_line()?;
    let mut nums = line
        .split(' ')
        .map(|s| s.parse::<i32>().unwrap());

    let _ = nums.next().unwrap();
    let mut b = nums.next().unwrap();

    let line = read_line()?;

    let nums = line
        .split(' ')
        .map(|s| s.parse::<i32>().unwrap())
        .collect::<Vec<_>>();

    let evency = nums
        .iter()
        .map(|n| if n % 2 == 0 { 1 } else { -1 })
        .collect::<Vec<_>>();

    let mut split_points = HashSet::new();
    let mut s = 0;

    for (i, e) in evency[..evency.len() - 1].iter().enumerate() {
        s += e;

        // println!("{}, {}, {}", i, s, e);

        if s == 0 {
            split_points.insert(i);
        }
    }

    let mut diffs = nums
        .iter()
        .zip(&nums[1..])
        .map(|(&prev, &curr)| (curr - prev).abs())
        .enumerate()
        .collect::<Vec<_>>();

    diffs.sort_unstable_by_key(|&(_, diff)| diff);

    // println!("diffs: {:?}", diffs);
    // println!("split_points: {:?}", split_points);

    let mut ans = 0;

    for (i, diff) in diffs {
        if split_points.contains(&i) && b >= diff {
            // println!("split at {}, price {}, current budget: {}", i, diff, b);

            ans += 1;
            b -= diff;
        }
    }

    println!("{}", ans);

    Ok(())
}

use std::io::{self, Read};
use std::cmp::Ordering;

fn cut( accum: &Vec<(i64,i64)>, nums: &Vec<i64>, s: usize, e: usize ) -> (i64,i64) {
    //println!("cut range: {},{}", s,e);
    for idx in s..e {
        let b = ( accum[e-1].0 - accum[idx].0, accum[e-1].1 - accum[idx].1 );
        let a = if s > 0 {
            ( accum[idx].0 - accum[s-1].0, accum[idx].1 - accum[s-1].1 )
        } else {
            ( accum[idx].0, accum[idx].1 )
        };
        //println!("idx:{}, a: {:?}, b: {:?}", idx, a, b );
        if b.0 == b.1 && b.0 != 0 && a.0 == a.1 && a.0 != 0 {
            //make a cut between (idx, idx+1)
            //println!("make a cut between {}, {}", idx, idx+1 );
            return (idx as i64,idx as i64 + 1)
        }
    }
    return (-1,-1)
}

fn main() {

    use std::collections::{HashMap,HashSet, BinaryHeap};

    let mut buffer = String::new();
    let stdin = io::stdin();
    let mut handle = stdin.lock();

    handle.read_to_string(&mut buffer).unwrap();

    let input_strs = buffer.split_whitespace().map( |x| x.parse::<i64>().unwrap() ).collect::< Vec<i64> >();

    let n = *input_strs.iter().nth(0).unwrap();
    let b = *input_strs.iter().nth(1).unwrap();

    let nums = input_strs.iter().skip(2).cloned().collect::< Vec<i64> >();

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

    let mut eo = nums.iter().map( |x| if *x % 2 == 0 { true } else { false } ).collect::<Vec< bool >>();

    let mut count_e = 0;
    let mut count_o = 0;
    let accum = eo.iter().enumerate().map(|(k,x)| {
        if *x == true { count_e += 1; } else { count_o += 1; }
        ( count_e, count_o )
    } ).collect::< Vec< (i64,i64) > >();

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

    let mut cut_idxs = cut( &accum, &nums, 0, nums.len() );
    let mut accum_cost = 0;
    let mut num_cuts = 0;

    let mut possible_cuts = vec![];
    loop {
        if cut_idxs.0 == -1 || cut_idxs.1 == -1 {
            break;
        }
        let cost_cut = (nums[cut_idxs.0 as usize] - nums[cut_idxs.1 as usize]).abs();

        cut_idxs = cut( &accum, &nums, cut_idxs.1 as usize, nums.len() );
        possible_cuts.push( ( cost_cut, cut_idxs ) );
    }

    possible_cuts.sort();

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

    for i in possible_cuts.iter() {
        if accum_cost + i.0 <= b {
            accum_cost += i.0;
            num_cuts += 1;
        } else {
            break;
        }
    }

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

use std::io::stdin;
use std::collections::HashSet;

fn read_line<'a>() -> Result<String, Box<std::error::Error>> {
    let mut line = String::new();
    stdin().read_line(&mut line)?;

    Ok(line.trim().to_owned())
}

fn main() -> Result<(), Box<std::error::Error>> {
    let line = read_line()?;
    let mut nums = line
        .split(' ')
        .map(|s| s.parse::<i32>().unwrap());

    let _ = nums.next().unwrap();
    let mut b = nums.next().unwrap();

    let line = read_line()?;

    let nums = line
        .split(' ')
        .map(|s| s.parse::<i32>().unwrap())
        .collect::<Vec<_>>();

    let evency = nums
        .iter()
        .map(|n| if n % 2 == 0 { 1 } else { -1 })
        .collect::<Vec<_>>();

    let mut split_points = HashSet::new();
    let mut s = 0;

    for (i, e) in evency[..evency.len() - 1].iter().enumerate() {
        s += e;

        // println!("{}, {}, {}", i, s, e);

        if s == 0 {
            split_points.insert(i);
        }
    }

    let mut diffs = nums
        .iter()
        .zip(&nums[1..])
        .map(|(&prev, &curr)| (prev - curr).abs())
        .enumerate()
        .collect::<Vec<_>>();

    diffs.sort_unstable_by_key(|&(_, diff)| diff);

    // println!("diffs: {:?}", diffs);
    // println!("split_points: {:?}", split_points);

    let mut ans = 0;

    for (i, diff) in diffs {
        if split_points.contains(&(i + 1)) && b >= diff {
            ans += 1;
            b -= diff;
        }
    }

    println!("{}", ans);

    Ok(())
}

use std::io::stdin;
use std::collections::HashSet;

fn read_line<'a>() -> Result<String, Box<std::error::Error>> {
    let mut line = String::new();
    stdin().read_line(&mut line)?;

    Ok(line.trim().to_owned())
}

fn main() -> Result<(), Box<std::error::Error>> {
    let line = read_line()?;
    let mut nums = line
        .split(' ')
        .map(|s| s.parse::<i32>().unwrap());

    let _ = nums.next().unwrap();
    let mut b = nums.next().unwrap();

    let line = read_line()?;

    let nums = line
        .split(' ')
        .map(|s| s.parse::<i32>().unwrap())
        .collect::<Vec<_>>();

    let evency = nums
        .iter()
        .map(|n| if n % 2 == 0 { 1 } else { -1 })
        .collect::<Vec<_>>();

    let mut split_points = HashSet::new();
    let mut s = 0;

    for (i, e) in evency[..evency.len() - 1].iter().enumerate() {
        s += e;

        // println!("{}, {}, {}", i, s, e);

        if s == 0 {
            split_points.insert(i);
        }
    }

    let mut diffs = nums
        .iter()
        .zip(&nums[1..])
        .map(|(&prev, &curr)| (prev - curr).abs())
        .enumerate()
        .collect::<Vec<_>>();

    diffs.sort_unstable_by_key(|&(_, diff)| diff);

    // println!("diffs: {:?}", diffs);
    // println!("split_points: {:?}", split_points);

    let mut ans = 0;

    for (i, diff) in diffs {
        if split_points.contains(&(i + 1)) && b > diff {
            ans += 1;
            b -= diff;
        }
    }

    println!("{}", ans);

    Ok(())
}

use std::io::stdin;
use std::collections::HashSet;

fn read_line<'a>() -> Result<String, Box<std::error::Error>> {
    let mut line = String::new();
    stdin().read_line(&mut line)?;

    Ok(line.trim().to_owned())
}

fn main() -> Result<(), Box<std::error::Error>> {
    let line = read_line()?;
    let mut nums = line
        .split(' ')
        .map(|s| s.parse::<i32>().unwrap());

    let _ = nums.next().unwrap();
    let mut b = nums.next().unwrap();

    let line = read_line()?;

    let nums = line
        .split(' ')
        .map(|s| s.parse::<i32>().unwrap())
        .collect::<Vec<_>>();

    let evency = nums
        .iter()
        .map(|n| if n % 2 == 0 { 1 } else { -1 })
        .collect::<Vec<_>>();

    let mut split_points = HashSet::new();
    let mut s = 0;

    for (i, e) in evency[..evency.len() - 1].iter().enumerate() {
        s += e;

        // println!("{}, {}, {}", i, s, e);

        if s == 0 {
            split_points.insert(i);
        }
    }

    let mut diffs = nums
        .iter()
        .zip(&nums[1..])
        .map(|(&prev, &curr)| (curr - prev).abs())
        .enumerate()
        .collect::<Vec<_>>();

    diffs.sort_unstable_by_key(|&(_, diff)| diff);

    println!("diffs: {:?}", diffs);
    println!("split_points: {:?}", split_points);

    let mut ans = 0;

    for (i, diff) in diffs {
        if split_points.contains(&i) && b >= diff {
            println!("split at {}, price {}, current budget: {}", i, diff, b);

            ans += 1;
            b -= diff;
        }
    }

    println!("{}", ans);

    Ok(())
}


// use rand::Rng;

use std::collections::*;
use std::io;

fn trim_newline(s: &mut String) {
    if s.ends_with('\n') {
        s.pop();
        if s.ends_with('\r') {
            s.pop();
        }
    }
}
macro_rules! parse_input {
    ($t:ident) => {{
        let mut input_line = String::new();
        io::stdin().read_line(&mut input_line).unwrap();
        trim_newline(&mut input_line);
        input_line.parse::<$t>().unwrap()
    }};
}

macro_rules! split_input {
    ($t:ident) => {{
        parse_input!(String)
            .split(" ")
            .map(|z| z.parse::<$t>().unwrap())
            .collect::<Vec<$t>>()
    }};
}

fn main() {
    let a = split_input!(u64);
    let n = a[0];
    let single = a[2];
    let group = a[3];
    let group_count = a[1];
    let mut best = single * n;
    best = std::cmp::min(best, ((n + (group_count - 1)) / group_count) * group);
    let other = n / group_count * group;
    let rem = n % group_count;
    best = std::cmp::min(other + rem * single, best);

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

use std::io::{self, prelude::*, Write};
use std::str;
use std::string::String;
use std::vec::Vec;

use std::cmp;

#[allow(unused_must_use)]
fn run<B: BufRead, W: Write>(mut reader: Scanner<B>, mut writer: W) {
    let total_number_of_trips: i32 = reader.next();
    let number_of_trips_with_special_ticket: i32 = reader.next();
    let one_trip_price: i32 = reader.next();
    let special_ticket_price: i32 = reader.next();

    let number_of_special_tickets_bought: i32 = total_number_of_trips / number_of_trips_with_special_ticket;
    let mut total_cost: i32 = number_of_special_tickets_bought * special_ticket_price;
    let remaining_trips_needed: i32 = total_number_of_trips % number_of_trips_with_special_ticket;
    if remaining_trips_needed > 0 {
        total_cost += cmp::min(remaining_trips_needed * one_trip_price, special_ticket_price);
    }

    total_cost = cmp::min(total_cost, total_number_of_trips * one_trip_price);

    writeln!(writer, "{}", total_cost);
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();

    let reader = Scanner::new(stdin.lock());
    let writer = io::BufWriter::new(stdout.lock());
    run(reader, writer);
    io::stdout().flush().unwrap();
}

pub struct Scanner<B> {
    reader: B,
    buffer_string: Vec<u8>,
    buffer_iterator: str::SplitWhitespace<'static>,
}

impl <B: BufRead> Scanner<B> {
    pub fn new(reader: B) -> Self {
        return Self {
            reader,
            buffer_string: Vec::new(),
            buffer_iterator: "".split_whitespace()
        };
    }

    pub fn next<T: str::FromStr>(&mut self) -> T {
        loop {
            //if buffer already exists, just use existing buffer
            if let Some(token) = self.buffer_iterator.next() {
                return token.parse().ok().expect("Fail to parse token");
            }

            //get new line
            self.buffer_string.clear();
            self.reader.read_until(b'\n', &mut self.buffer_string).expect("Failed to read");

            //split by white space
            self.buffer_iterator = unsafe {
                let slice = str::from_utf8_unchecked(&self.buffer_string);
                std::mem::transmute(slice.split_whitespace())
            };
        }
    }

    pub fn next_line(&mut self) -> String {
        //reset buffer
        self.buffer_iterator = "".split_whitespace();
        self.buffer_string.clear();

        let mut input: String = String::new();
        self.reader.read_line(&mut input).expect("Failed to read line");
        return input.trim().to_string();
    }
}

fn input_split() -> Vec<u32> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|elem| elem.parse().unwrap())
        .collect()
}

fn main() {
    let (n, m, a, b) = {
        let temp = input_split();
        (temp[0], temp[1], temp[2], temp[3])
    };

    if m * a > b {
        println!("{}", (n / m) * b + b.min((n % m) * a));
    } else {
        println!("{}", n * a);
    }
}

//spnauti-rust
#[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 {
    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 ai(&mut self, n: usize) -> Vec<i32> {
        let mut a = Vec::with_capacity(n);
        for _ in 0..n { a.push(self.i()); }
        a
    }
}

fn main() {
    let mut input = WordReader::from_stdin();
    let n = input.i();
    let m = input.i();
    let a = input.i();
    let b = input.i();
    let p = n / m;
    let q = n % m;
    let val = [a*n, a*q+b*p, b*(p+1)];
    let sol = val.iter().min().unwrap();
    println!("{}", sol);
}

// 2018-10-12 09:00
fn main() {
    let v: Vec<i32> = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().split(" ").map(|s| s.parse::<i32>().unwrap()).collect()
    };
    let (n, m, a, b) = (v[0], v[1], v[2], v[3]);

    if b / m >= a {
        println!("{:?}", a * n);
    } else {
        if n % m * a > b {
            println!("{:?}", (n as f32 / m as f32).ceil() as i32 * b);

        } else {
            println!("{:?}", (n / m) * b + n % m * a);
        }

    }
}

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

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,m,a,b) = readln!(i32,i32,i32,i32);
    let r1 = n*a;
    let r2 = b*((n+m-1)/m);
    let r3 = b*(n/m) + a*(n%m);
    println!("{}", std::cmp::min(r1,std::cmp::min(r2,r3)));
}

// {{{ 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),*);
    }
}

// }}}

use std::cmp;

fn main() {
    let (n, m, a, b) = R!(usize, usize, usize, usize);
    println!("{}", cmp::min(n*a, cmp::min((n%m)*a + (n/m)*b, (n+m-1)/m*b)));
}

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

fn main() {
  let stdin = io::stdin();
  let mut s = String::new();
  stdin.read_line(&mut s).unwrap();

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

  let n = x[0];
  let m = x[1];
  let a = x[2];
  let b = x[3];

  let ans =
  min(  a*n,
  min(  b*(n/m + 1),
        b*(n/m) + a*(n%m)
  ));

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

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

fn main() {
  let stdin = io::stdin();
  let mut s = String::new();
  stdin.read_line(&mut s).unwrap();

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

  let n = x[0];
  let m = x[1];
  let a = x[2];
  let b = x[3];

  if m * a <= b {
    println!("{}", a*n);
  } else {
    if m > n {
      println!("{}", min(b, a*n));
    } else {
      if a*(n%m) < b {
        println!("{}", b*(n/m)+a*(n%m));
      } else {
        println!("{}", b*(n/m+1));
      }
    }
  }
}

use std::io::*;

fn reads<T: std::str::FromStr>(i: &mut StdinLock) -> Vec<T> {
    let mut s = String::new();
    i.by_ref().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

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

    let params: Vec<u32> = reads(sin);

    let n = params[0];
    let m = params[1];
    let a = params[2];
    let b = params[3];

    let ans = if a * m < b {
        n * a
    } else {
        let base = n / m;
        let remain = n % m;
        (base * b) + std::cmp::min(remain * a, b)
    };

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

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

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

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

    let words: Vec<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let n = words[0];
    let m = words[1];
    let a = words[2];
    let b = words[3];

    let sale: f64 = b as f64/m as f64;

    if sale < a as f64 {
        let mut ans = (n as f64/m as f64).floor() as i64*b;
        let minima = std::cmp::min((n%m)*a, b);
        ans += minima;
        println!("{}", ans);
    } else {
        println!("{}", n*a);
    }
}

#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::BTreeSet;
#[allow(unused_imports)]
use std::collections::HashSet;
use std::fs::File;
use std::io::Read;
#[allow(unused_imports)]
use std::mem;
use std::fmt::Display;

#[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
}

#[allow(dead_code)]
fn show1dvec<T : Display>(v : &Vec<T>) {
    let n = v.len();
    for i in 0..n - 1 {
        print!("{} " , v[i]);
    }
    println!("{} " , v[n - 1]);
}

#[derive(Debug)]
struct Piece {
    mark: char,
    y: i32,
    x: i32,
}

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 n: i32 = iter.next().unwrap().parse().unwrap();
    let m: i32 = iter.next().unwrap().parse().unwrap();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();

    println!("{}", cmp::min(cmp::min(n * a, (n + m - 1) / m * b), (n % m) * a + (n / m) * b));

    // let n = iter.next().unwrap().parse().unwrap();

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

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();
    let n: isize = scan.next();
    let m: isize = scan.next();
    let a: isize = scan.next();
    let b: isize = scan.next();
    if a*m <= b {
        println!("{}", a*n);
    } else {
        let mut result = (n/m)*b;
        if b <= a*(n%m) { result += b; }
        else {            result += (n%m)*a; }
        println!("{}", result);
    }
}

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

use std::cmp::min;
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_ts<T : FromStr>(stdin : &Stdin, ts : &mut Vec<T>) {
    let mut line = String::new();
    read_line(stdin, &mut line);
    let word_iter = line.split_whitespace();
    for word in word_iter {
        let x = parse_t(word);
        ts.push(x);
    }
}

fn main() {
    let stdin = io::stdin();
    let mut n_m_a_b : Vec<usize> = vec![];
    read_ts(&stdin, &mut n_m_a_b);
    let n = n_m_a_b[0];
    let m = n_m_a_b[1];
    let a = n_m_a_b[2];
    let b = n_m_a_b[3];
    let cost_1 = n * a;
    let cost_2 = ((n / m) * b) + min((n % m) * a, b);
    let min_cost = min(cost_1, cost_2);
    println!("{}", min_cost);
}

fn solve() {
    let (n, m, a, b) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let v: Vec<i32> = buf.split_whitespace().map(|x| x.parse().unwrap()).collect();
        (v[0], v[1], v[2], v[3])
    };

    let mut ans = 0;
    if b < m * a {
        let d = n / m;
        ans += d * b;
        if b < a * (n - d * m) {
            ans += b;
        } else {
            ans += (n - d * m) * a;
        }
    } else {
        ans += n * a;
    }
    println!("{}", ans);
}

fn main() {
    // let t: u32 = {
    //     let mut buf = String::new();
    //     std::io::stdin().read_line(&mut buf).unwrap();
    //     buf.trim_end().parse().unwrap()
    // };

    solve();
    // for _ in 0..t {}
}

// use rand::Rng;

use std::collections::*;
use std::io;

fn trim_newline(s: &mut String) {
    if s.ends_with('\n') {
        s.pop();
        if s.ends_with('\r') {
            s.pop();
        }
    }
}
macro_rules! parse_input {
    ($t:ident) => {{
        let mut input_line = String::new();
        io::stdin().read_line(&mut input_line).unwrap();
        trim_newline(&mut input_line);
        input_line.parse::<$t>().unwrap()
    }};
}

macro_rules! split_input {
    ($t:ident) => {{
        parse_input!(String)
            .split(" ")
            .map(|z| z.parse::<$t>().unwrap())
            .collect::<Vec<$t>>()
    }};
}

fn main() {
    let a = split_input!(u64);
    let n = a[0];
    let single = a[2];
    let group = a[3];
    let group_count = a[1];
    let mut best = single * n;
    best = std::cmp::min(best, ((n + (group_count - 1)) / group_count) * group);

    let other = n / group_count * group;
    let rem = n % group_count;

    best = std::cmp::min(other + rem * single, best);
    best = std::cmp::min(other + group, best);

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

use std::io::stdin;

fn read_line() -> String {
    let mut input = String::new();
    stdin().read_line(&mut input).expect("Failed to read line!");
    input
}

fn main() {
    let input1 = read_line();
    let line1: Vec<&str> = input1.split(" ").collect();
    let n = line1[0].trim().parse::<i32>().unwrap();
    let m = line1[1].trim().parse::<i32>().unwrap();
    let a = line1[2].trim().parse::<i32>().unwrap();
    let b = line1[3].trim().parse::<i32>().unwrap();

    let costs: i32;
    if b <= a {
        costs = f32::ceil(n as f32 / m as f32) as i32 * b;
    } else if b / m < a {
        if m > n {
            if n * a > b {
                costs = b;
            } else {
                costs = n * a;
            }
        } else {
            costs = (n % m) * a + f32::floor(n as f32 / m as f32) as i32 * b
        }
    } else {
        costs = n * a;
    }
    println!("{}", costs);
}

use std::io::{self, prelude::*, Write};
use std::str;
use std::string::String;
use std::vec::Vec;

use std::cmp;

#[allow(unused_must_use)]
fn run<B: BufRead, W: Write>(mut reader: Scanner<B>, mut writer: W) {
    let total_number_of_trips: i32 = reader.next();
    let number_of_trips_with_special_ticket: i32 = reader.next();
    let one_trip_price: i32 = reader.next();
    let special_ticket_price: i32 = reader.next();

    let number_of_special_tickets_bought: i32 = total_number_of_trips / number_of_trips_with_special_ticket;
    let mut total_cost: i32 = number_of_special_tickets_bought * special_ticket_price;
    let remaining_trips_needed: i32 = total_number_of_trips % number_of_trips_with_special_ticket;
    if remaining_trips_needed > 0 {
        total_cost += cmp::min(remaining_trips_needed * one_trip_price, special_ticket_price);
    }

    writeln!(writer, "{}", total_cost);
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();

    let reader = Scanner::new(stdin.lock());
    let writer = io::BufWriter::new(stdout.lock());
    run(reader, writer);
    io::stdout().flush().unwrap();
}

pub struct Scanner<B> {
    reader: B,
    buffer_string: Vec<u8>,
    buffer_iterator: str::SplitWhitespace<'static>,
}

impl <B: BufRead> Scanner<B> {
    pub fn new(reader: B) -> Self {
        return Self {
            reader,
            buffer_string: Vec::new(),
            buffer_iterator: "".split_whitespace()
        };
    }

    pub fn next<T: str::FromStr>(&mut self) -> T {
        loop {
            //if buffer already exists, just use existing buffer
            if let Some(token) = self.buffer_iterator.next() {
                return token.parse().ok().expect("Fail to parse token");
            }

            //get new line
            self.buffer_string.clear();
            self.reader.read_until(b'\n', &mut self.buffer_string).expect("Failed to read");

            //split by white space
            self.buffer_iterator = unsafe {
                let slice = str::from_utf8_unchecked(&self.buffer_string);
                std::mem::transmute(slice.split_whitespace())
            };
        }
    }

    pub fn next_line(&mut self) -> String {
        //reset buffer
        self.buffer_iterator = "".split_whitespace();
        self.buffer_string.clear();

        let mut input: String = String::new();
        self.reader.read_line(&mut input).expect("Failed to read line");
        return input.trim().to_string();
    }
}

use std::io::{self, prelude::*, Write};
use std::str;
use std::string::String;
use std::vec::Vec;

#[allow(unused_must_use)]
fn run<B: BufRead, W: Write>(mut reader: Scanner<B>, mut writer: W) {
    let total_number_of_trips: i32 = reader.next();
    let number_of_trips_with_special_ticket: i32 = reader.next();
    let one_trip_price: i32 = reader.next();
    let special_ticket_price: i32 = reader.next();

    let number_of_special_tickets_bought: i32 = total_number_of_trips / number_of_trips_with_special_ticket;
    let mut total_cost: i32 = number_of_special_tickets_bought * special_ticket_price;
    let remaining_trips_needed: i32 = total_number_of_trips % number_of_trips_with_special_ticket;
    if remaining_trips_needed > 0 {
        total_cost += remaining_trips_needed * one_trip_price;
    }

    writeln!(writer, "{}", total_cost);
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();

    let reader = Scanner::new(stdin.lock());
    let writer = io::BufWriter::new(stdout.lock());
    run(reader, writer);
    io::stdout().flush().unwrap();
}

pub struct Scanner<B> {
    reader: B,
    buffer_string: Vec<u8>,
    buffer_iterator: str::SplitWhitespace<'static>,
}

impl <B: BufRead> Scanner<B> {
    pub fn new(reader: B) -> Self {
        return Self {
            reader,
            buffer_string: Vec::new(),
            buffer_iterator: "".split_whitespace()
        };
    }

    pub fn next<T: str::FromStr>(&mut self) -> T {
        loop {
            //if buffer already exists, just use existing buffer
            if let Some(token) = self.buffer_iterator.next() {
                return token.parse().ok().expect("Fail to parse token");
            }

            //get new line
            self.buffer_string.clear();
            self.reader.read_until(b'\n', &mut self.buffer_string).expect("Failed to read");

            //split by white space
            self.buffer_iterator = unsafe {
                let slice = str::from_utf8_unchecked(&self.buffer_string);
                std::mem::transmute(slice.split_whitespace())
            };
        }
    }

    pub fn next_line(&mut self) -> String {
        //reset buffer
        self.buffer_iterator = "".split_whitespace();
        self.buffer_string.clear();

        let mut input: String = String::new();
        self.reader.read_line(&mut input).expect("Failed to read line");
        return input.trim().to_string();
    }
}

fn input_split() -> Vec<u16> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|elem| elem.parse().unwrap())
        .collect()
}

fn main() {
    let (n, m, a, b) = {
        let temp = input_split();
        (temp[0], temp[1], temp[2], temp[3])
    };

    if m * a > b {
        println!("{}", (n / m) * b + b.min((n % m) * a));
    } else {
        println!("{}", n * a);
    }
}

// 2018-10-12 09:00
fn main() {
    let v: Vec<i32> = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().split(" ").map(|s| s.parse::<i32>().unwrap()).collect()
    };
    let (n, m, a, b) = (v[0], v[1], v[2], v[3]);

    if b / m >= a {
        println!("{:?}", a * n);
    } else {
        println!("{:?}", (n as f32 / m as f32).ceil() as i32 * b);
    }
}

// 2018-10-12 09:00
fn main() {
    let v: Vec<i32> = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().split(" ").map(|s| s.parse::<i32>().unwrap()).collect()
    };
    let (n, m, a, b) = (v[0], v[1], v[2], v[3]);

    if b / m >= a {
        println!("{:?}", a * n);
    } else {
        println!("{:?}", n / m * b + n % m * a);
    }
}

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

fn main() {
  let stdin = io::stdin();
  let mut s = String::new();
  stdin.read_line(&mut s).unwrap();

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

  let n = x[0];
  let m = x[1];
  let a = x[2];
  let b = x[3];

  if m * a <= b {
    println!("{}", a*n);
  } else {
    if m > n {
      println!("{}", min(b, a*n));
    } else {
      println!("{}", b*(n/m)+a*(n%m));
    }
  }
}

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

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

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

    let words: Vec<f64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let n = words[0];
    let m = words[1];
    let a = words[2];
    let b = words[3];

    let sale: f64 = b/m;

    if sale < a {
        println!("{}", (n/m).floor()*b + (n%m)*a);
    }
}

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

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

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

    let words: Vec<f64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let n = words[0];
    let m = words[1];
    let a = words[2];
    let b = words[3];

    let sale: f64 = b/m;

    if sale < a {
        println!("{}", (n/m).floor()*b + (n%m)*a);
    } else {
        println!("{}", n*a);
    }
}

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

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

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

    let words: Vec<f64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let n = words[0];
    let m = words[1];
    let a = words[2];
    let b = words[3];

    let sale: f64 = b/m;

    if sale < a {
        println!("{}", (n/m).floor()*b + (n%m)*a);
    } else {
        println!("{}", a);
    }
}

#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::BTreeSet;
#[allow(unused_imports)]
use std::collections::HashSet;
use std::fs::File;
use std::io::Read;
#[allow(unused_imports)]
use std::mem;
use std::fmt::Display;

#[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
}

#[allow(dead_code)]
fn show1dvec<T : Display>(v : &Vec<T>) {
    let n = v.len();
    for i in 0..n - 1 {
        print!("{} " , v[i]);
    }
    println!("{} " , v[n - 1]);
}

#[derive(Debug)]
struct Piece {
    mark: char,
    y: i32,
    x: i32,
}

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 n: i32 = iter.next().unwrap().parse().unwrap();
    let m: i32 = iter.next().unwrap().parse().unwrap();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();

    println!("{}", cmp::min(n * a, (n % m) * a + (n / m) * b));

    // let n = iter.next().unwrap().parse().unwrap();

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

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();
    let n: isize = scan.next();
    let m: isize = scan.next();
    let a: isize = scan.next();
    let b: isize = scan.next();
    if a*m <= b {
        println!("{}", a*n);
    } else {
        let mut result = (n/m)*b;
        if b <= a*(n%m) { result += 1; }
        else {            result += (n%m)*a; }
        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<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();
    let n: isize = scan.next();
    let m: isize = scan.next();
    let a: isize = scan.next();
    let b: isize = scan.next();
    if a*m <= b {
        println!("{}", a*n);
    } else {
        let result = n/m*b + n%m*a;
        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<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();
    let n: isize = scan.next();
    let m: isize = scan.next();
    let a: isize = scan.next();
    let b: isize = scan.next();
    if a*m <= b {
        println!("{}", a*n);
    } else {
        let result = (n/m)*b + (n%m)*a;
        println!("{}", result);
    }
}

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

use std::cmp::min;
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_ts<T : FromStr>(stdin : &Stdin, ts : &mut Vec<T>) {
    let mut line = String::new();
    read_line(stdin, &mut line);
    let word_iter = line.split_whitespace();
    for word in word_iter {
        let x = parse_t(word);
        ts.push(x);
    }
}

fn main() {
    let stdin = io::stdin();
    let mut n_m_a_b : Vec<usize> = vec![];
    read_ts(&stdin, &mut n_m_a_b);
    let n = n_m_a_b[0];
    let m = n_m_a_b[1];
    let a = n_m_a_b[2];
    let b = n_m_a_b[3];
    let cost_1 = n * a;
    let cost_2 = ((n / m) * b) + ((n % m) * a);
    let min_cost = min(cost_1, cost_2);
    println!("{}", min_cost);
}

// use rand::Rng;

use std::collections::*;
use std::io;

fn trim_newline(s: &mut String) {
    if s.ends_with('\n') {
        s.pop();
        if s.ends_with('\r') {
            s.pop();
        }
    }
}
macro_rules! parse_input {
    ($t:ident) => {{
        let mut input_line = String::new();
        io::stdin().read_line(&mut input_line).unwrap();
        trim_newline(&mut input_line);
        input_line.parse::<$t>().unwrap()
    }};
}

macro_rules! split_input {
    ($t:ident) => {{
        parse_input!(String)
            .split(" ")
            .map(|z| z.parse::<$t>().unwrap())
            .collect::<Vec<$t>>()
    }};
}

fn main() {
    let a = split_input!(u64);
    let n = a[0];
    let single = a[2];
    let group = a[3];
    let group_count = a[1];

    if (single * group_count) <= group {
        println!("{}", single * n);
    } else if group < single {
        println!("{}", (n + (group_count - 1)) / group_count * group);
    } else {
        println!("{}", n / group_count * group + (n % group_count) * single);
    }
}

// use rand::Rng;

use std::collections::*;
use std::io;

fn trim_newline(s: &mut String) {
    if s.ends_with('\n') {
        s.pop();
        if s.ends_with('\r') {
            s.pop();
        }
    }
}
macro_rules! parse_input {
    ($t:ident) => {{
        let mut input_line = String::new();
        io::stdin().read_line(&mut input_line).unwrap();
        trim_newline(&mut input_line);
        input_line.parse::<$t>().unwrap()
    }};
}

macro_rules! split_input {
    ($t:ident) => {{
        parse_input!(String)
            .split(" ")
            .map(|z| z.parse::<$t>().unwrap())
            .collect::<Vec<$t>>()
    }};
}

fn main() {
    let a = split_input!(u64);
    let n = a[0];
    let single = a[2];
    let group = a[3];
    let group_count = a[1];

    if (single * group_count) <= group {
        println!("{}", single * n);
    } else {
        println!("{}", n / group_count * group + (n % group_count) * single);
    }
}

use std::io::stdin;

fn read_line() -> String {
    let mut input = String::new();
    stdin().read_line(&mut input).expect("Failed to read line!");
    input
}

fn main() {
    let input1 = read_line();
    let line1: Vec<&str> = input1.split(" ").collect();
    let n = line1[0].trim().parse::<i32>().unwrap();
    let m = line1[1].trim().parse::<i32>().unwrap();
    let a = line1[2].trim().parse::<i32>().unwrap();
    let b = line1[3].trim().parse::<i32>().unwrap();

    let costs: i32;
    if b / m < a {
        costs = (n % m) * a + f32::floor(n as f32 / m as f32) as i32 * b
    } else {
        costs = n * a;
    }
    println!("{}", costs);
}

use std::io::stdin;

fn read_line() -> String {
    let mut input = String::new();
    stdin().read_line(&mut input).expect("Failed to read line!");
    input
}

fn main() {
    let input1 = read_line();
    let line1: Vec<&str> = input1.split(" ").collect();
    let n = line1[0].trim().parse::<i32>().unwrap();
    let m = line1[1].trim().parse::<i32>().unwrap();
    let a = line1[2].trim().parse::<i32>().unwrap();
    let b = line1[3].trim().parse::<i32>().unwrap();

    let costs: i32;
    if b <= a {
        costs = f32::ceil(n as f32 / m as f32) as i32 * b;
    } else if b / m < a {
        costs = (n % m) * a + f32::floor(n as f32 / m as f32) as i32 * b
    } else {
        costs = n * a;
    }
    println!("{}", costs);
}

use std::io::stdin;

fn read_line() -> String {
    let mut input = String::new();
    stdin().read_line(&mut input).expect("Failed to read line!");
    input
}

fn main() {
    let input1 = read_line();
    let line1: Vec<&str> = input1.split(" ").collect();
    let n = line1[0].trim().parse::<i32>().unwrap();
    let m = line1[1].trim().parse::<i32>().unwrap();
    let a = line1[2].trim().parse::<i32>().unwrap();
    let b = line1[3].trim().parse::<i32>().unwrap();

    let costs: i32;
    if b <= a {
        costs = f32::ceil(n as f32 / m as f32) as i32 * b;
    } else if b / m < a {
        if m > n {
            if n * a > m * b {
                costs = m * b;
            } else {
                costs = n * a;
            }
        } else {
            costs = (n % m) * a + f32::floor(n as f32 / m as f32) as i32 * b
        }
    } else {
        costs = n * a;
    }
    println!("{}", costs);
}


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

use std::io::prelude::*;
use std::io::BufReader;
use std::cmp::{max, min};

fn get_line() -> String {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    input
}

fn get_vec<T>() -> Vec<T>
where T: FromStr,
      <T as FromStr>::Err: std::fmt::Debug,
{
    get_line().split_whitespace().map(|k| k.parse().unwrap()).collect()
}

fn main() {
    println!("Karen");
}

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

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

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

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }

    #[allow(dead_code)]
    pub fn get2<T: FromStr, U: FromStr>() -> (T, U)
    where
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
}

fn main() {
    let n: usize = util::get();
    let a: Vec<usize> = util::gets();
    let b: Vec<usize> = util::gets();

    let mut set = HashSet::new();
    for i in 0..n {
        set.insert(a[i]);
        set.insert(b[i]);
    }

    let mut cnt = 0;

    for i in 0..n {
        for k in 0..n {
            let xor = a[i] ^ b[k];
            if set.contains(&xor) {
                cnt += 1;
            }
        }
    }

    if cnt % 2 == 0 {
        println!("Karen");
    } else {
        println!("Koyomi");
    }

}

#![allow(dead_code, unused_imports)]

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

fn read_stdin() -> String {
    let mut s = String::new();
    std::io::stdin()
        .read_line(&mut s)
        .expect("cannot read stdin");
    s.trim().to_string()
}

fn read<T>() -> T
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    read_stdin().parse::<T>().unwrap()
}

fn read_usize() -> usize {
    read::<usize>()
}

fn read_2<A, B>() -> (A, B)
where
    A: FromStr,
    <A as FromStr>::Err: Debug,
    B: FromStr,
    <B as FromStr>::Err: Debug,
{
    let s = read_stdin();
    let mut s = s.split_whitespace();
    let a = s.next().unwrap().parse::<A>().unwrap();
    let b = s.next().unwrap().parse::<B>().unwrap();
    (a, b)
}

fn read_3<A, B, C>() -> (A, B, C)
where
    A: FromStr,
    <A as FromStr>::Err: Debug,
    B: FromStr,
    <B as FromStr>::Err: Debug,
    C: FromStr,
    <C as FromStr>::Err: Debug,
{
    let s = read_stdin();
    let mut s = s.split_whitespace();
    let a = s.next().unwrap().parse::<A>().unwrap();
    let b = s.next().unwrap().parse::<B>().unwrap();
    let c = s.next().unwrap().parse::<C>().unwrap();
    (a, b, c)
}

fn read_4<A, B, C, D>() -> (A, B, C, D)
where
    A: FromStr,
    <A as FromStr>::Err: Debug,
    B: FromStr,
    <B as FromStr>::Err: Debug,
    C: FromStr,
    <C as FromStr>::Err: Debug,
    D: FromStr,
    <D as FromStr>::Err: Debug,
{
    let s = read_stdin();
    let mut s = s.split_whitespace();
    let a = s.next().unwrap().parse::<A>().unwrap();
    let b = s.next().unwrap().parse::<B>().unwrap();
    let c = s.next().unwrap().parse::<C>().unwrap();
    let d = s.next().unwrap().parse::<D>().unwrap();
    (a, b, c, d)
}

fn read_multiple<T: FromStr>() -> Vec<T>
where
    <T as FromStr>::Err: Debug,
{
    read_stdin()
        .split_whitespace()
        .map(|x| x.parse::<T>().expect("cannot parse stdin"))
        .collect()
}

/// NOTE: sort iter beforehand if required
fn count<T>(iter: &mut impl Iterator<Item = T>) -> Vec<(T, usize)>
where
    T: std::cmp::Ord,
{
    let iter = iter.collect::<Vec<_>>();
    //iter.sort();
    let (mut v, o, c) =
        iter.into_iter()
            .fold((Vec::new(), None, 0), |(mut v, last, count), item| {
                if let Some(o) = last {
                    if item == o {
                        (v, Some(o), count + 1)
                    } else {
                        v.push((o, count));
                        (v, Some(item), 1)
                    }
                } else {
                    (v, Some(item), 1)
                }
            });
    if let Some(i) = o {
        v.push((i, c));
    }
    v
}

fn partial_sum<T>(v: impl Iterator<Item = T>) -> impl Iterator<Item = T>
where
    T: Default + std::ops::Add<Output = T> + Copy,
{
    v.scan(T::default(), |state, x| {
        *state = *state + x;
        Some(*state)
    })
}

fn max_subarray(v: impl Iterator<Item = i64>) -> (i64, (usize, usize)) {
    //assert!(v.len() > 0);
    let mut best_sum = 0;
    let (mut best_start, mut best_end) = (0, 0);
    let mut current_sum = 0;
    let mut current_start = 0;
    for (end, val) in v.enumerate() {
        if current_sum <= 0 {
            current_start = end;
            current_sum = val;
        } else {
            current_sum += val;
        }
        if current_sum > best_sum {
            best_sum = current_sum;
            best_start = current_start;
            best_end = end + 1;
        }
    }
    (best_sum, (best_start, best_end))
}

fn gcd(mut a: u64, mut b: u64) -> u64 {
    while a != 0 {
        let old_m = a;
        a = b % a;
        b = old_m;
    }
    b
}

/// returns gcd, and pair (x, y), such that x * a + b * y == gcd
fn egcd(a: i64, b: i64) -> (i64, i64, i64) {
    if a == 0 {
        (b, 0, 1)
    } else {
        let (g, x, y) = egcd(b % a, a);
        (g, y - (b / a) * x, x)
    }
}

fn factorize(mut n: u64) -> Vec<u64> {
    if n <= 3 {
        return vec![n];
    }
    let mut v = Vec::new();
    while n % 2 == 0 {
        n /= 2;
        v.push(2);
    }
    while n % 3 == 0 {
        n /= 3;
        v.push(3);
    }
    let mut f = 6;
    while (f - 1) * (f - 1) <= n {
        while n % (f - 1) == 0 {
            n /= f - 1;
            v.push(f - 1);
        }
        while n % (f + 1) == 0 {
            n /= f + 1;
            v.push(f + 1);
        }
        f += 6;
    }
    if n > 1 {
        v.push(n);
    }
    v
}

fn compact_factors(n: u64) -> Vec<(u64, usize)> {
    count(&mut factorize(n).into_iter())
}

fn all_factors(n: u64) -> Vec<u64> {
    if n == 0 {
        return vec![0];
    } else if n == 1 {
        return vec![1];
    }
    let factors = compact_factors(n);
    let mut v = vec![1];
    for (fac, num) in factors {
        let ori = v.clone();
        for i in 1..num + 1 {
            v.append(
                &mut ori
                    .clone()
                    .into_iter()
                    .map(|f| f * fac.pow(i as u32))
                    .collect::<Vec<_>>(),
            )
        }
    }
    v.sort();
    v
}

fn abs_diff<T>(a: T, b: T) -> T
where
    T: PartialOrd + std::ops::Sub<Output = T>,
{
    if a > b {
        a - b
    } else {
        b - a
    }
}

struct Permutations<T> {
    inner: Vec<T>,
    state: Vec<usize>,
    i: usize,
    start: bool,
}

impl<T> Permutations<T> {
    fn new(inner: Vec<T>) -> Self {
        Self {
            state: vec![0; inner.len()],
            i: 0,
            start: true,
            inner,
        }
    }
}

/*impl<T, X> From<X> for Permutations<T>
where
    X: IntoIterator<Item = T>,
{
    fn from(f: X) -> Self {
        Self::new(f.into_iter().collect::<Vec<T>>())
    }
}*/

impl<T> Iterator for Permutations<T>
where
    T: Clone,
{
    type Item = Vec<T>;
    fn next(&mut self) -> Option<Self::Item> {
        if self.start {
            self.start = false;
            return Some(self.inner.clone());
        }
        while self.i < self.inner.len() {
            if self.state[self.i] < self.i {
                if self.i % 2 == 0 {
                    self.inner.swap(0, self.i)
                } else {
                    self.inner.swap(self.state[self.i], self.i)
                }
                self.state[self.i] += 1;
                self.i = 0;
                return Some(self.inner.clone());
            } else {
                self.state[self.i] = 0;
                self.i += 1;
            }
        }
        None
    }
}

use std::cmp::{max, min, Ord, Ordering};
use std::collections::{BinaryHeap, VecDeque};
use std::mem::swap;

#[derive(Clone)]
struct Graph {
    nodes: usize,
    edges: Vec<Vec<(usize, u64)>>,
}

impl Graph {
    fn new(n: usize) -> Self {
        Self {
            nodes: n,
            edges: vec![Vec::new(); n + 1],
        }
    }

    fn add_edge(&mut self, x: usize, y: usize, cost: u64) {
        self.edges[x].push((y, cost));
        self.edges[y].push((x, cost));
    }

    fn dijkstra(&mut self, start: usize, end: usize) -> u64 {
        let mut dist = vec![None; self.nodes + 1];
        let mut prev = vec![None; self.nodes + 1];
        dist[start] = Some(0);
        let mut queue = (1..=self.nodes).collect::<Vec<_>>();
        queue.sort_unstable_by_key(|node| dist[*node].unwrap_or(std::u64::MAX));
        queue.reverse();
        while let Some(next_node) = queue.pop() {
            if next_node == end {
                return dist[next_node].unwrap();
            }
            for (neighbour, cost) in self.edges[next_node].iter() {
                let alt = dist[next_node].unwrap() + cost;
                if dist[*neighbour].is_none() {
                    dist[*neighbour] = Some(alt);
                    prev[*neighbour] = Some(next_node);
                } else {
                    if alt < dist[*neighbour].unwrap() {
                        dist[*neighbour] = Some(alt);
                        prev[*neighbour] = Some(next_node);
                    }
                }
            }
            //println!("{:?} {:?}", dist, prev);
            queue.sort_unstable_by_key(|node| dist[*node].unwrap_or(std::u64::MAX));
            queue.reverse();
        }
        0
    }

    fn set_cost(&mut self, x: usize, y: usize, cost: u64) {
        for i in 0..self.edges[x].len() {
            if self.edges[x][i].0 == y {
                self.edges[x][i].1 = cost
            }
        }
        for i in 0..self.edges[y].len() {
            if self.edges[y][i].0 == x {
                self.edges[y][i].1 = cost
            }
        }
    }
}

const MODULO: u64 = 1_000_000_007;

#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
struct BigPrimeRing {
    inner: u64,
}

impl<T> From<T> for BigPrimeRing
where
    T: Into<u64>,
{
    fn from(n: T) -> Self {
        Self {
            inner: n.into() % MODULO,
        }
    }
}

impl<T> std::ops::Add<T> for BigPrimeRing
where
    T: Into<Self>,
{
    type Output = BigPrimeRing;
    fn add(self, rhs: T) -> Self::Output {
        Self {
            inner: (self.inner + rhs.into().inner) % MODULO,
        }
    }
}

impl<T> std::ops::AddAssign<T> for BigPrimeRing
where
    T: Into<Self>,
{
    fn add_assign(&mut self, rhs: T) {
        self.inner += rhs.into().inner;
        self.inner %= MODULO;
    }
}

impl<T> std::ops::Sub<T> for BigPrimeRing
where
    T: Into<Self>,
{
    type Output = BigPrimeRing;
    fn sub(self, rhs: T) -> Self::Output {
        Self {
            inner: (self.inner + MODULO - rhs.into().inner) % MODULO,
        }
    }
}

impl<T> std::ops::SubAssign<T> for BigPrimeRing
where
    T: Into<Self>,
{
    fn sub_assign(&mut self, rhs: T) {
        self.inner += MODULO;
        self.inner -= rhs.into().inner;
        self.inner %= MODULO;
    }
}

impl<T> std::ops::Mul<T> for BigPrimeRing
where
    T: Into<Self>,
{
    type Output = BigPrimeRing;
    fn mul(self, rhs: T) -> Self::Output {
        Self {
            inner: (self.inner * rhs.into().inner) % MODULO,
        }
    }
}

impl<T> std::ops::MulAssign<T> for BigPrimeRing
where
    T: Into<Self>,
{
    fn mul_assign(&mut self, rhs: T) {
        self.inner *= rhs.into().inner;
        self.inner %= MODULO;
    }
}

impl BigPrimeRing {
    fn inverse(self) -> Self {
        if self.inner == 0 {
            return self;
        }
        let (_g, mut x, _y) = egcd(self.inner as i64, MODULO as i64);
        if x < 0 {
            x += MODULO as i64;
        }
        Self { inner: x as u64 }
    }
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    println!("Karen");
    Ok(())
}

// Basics

#![allow(unused_imports)]

use std::mem;
use std::io;
use std::string;
use std::cmp::*;
use std::collections::*;

fn load() -> Vec<i64> {
    let mut line = String::new();
    io::stdin().read_line(&mut line).expect("Failed to read line");
    let vec: Vec<&str> = line.split(" ").collect();
    let mut data: Vec<i64> = Vec::new();
    for i in vec {
        let el: i64 = i.trim().parse().unwrap();
        data.push(el);
    }
    data
}

fn loads() -> Vec<i32> {
    let mut line = String::new();
    io::stdin().read_line(&mut line).expect("Failed to read line");
    let vec: Vec<&str> = line.split(" ").collect();
    let mut data: Vec<i32> = Vec::new();
    for i in vec {
        let el: i32 = i.trim().parse().unwrap();
        data.push(el);
    }
    data
}

fn main() {
    let n = loads()[0] as usize;
    let a = load();
    let b = load();
    let mut s: HashSet<&i64> = HashSet::new();
    for i in 0..n {
        s.insert(&a[i]);
        s.insert(&b[i]);
    }
    let mut res = 0;
    for i in 0..n {
        for j in 0..n {
            let x: i64 = a[i] ^ a[j];
            if s.contains(&x) {
                res += 1;
            }
        }
    }
    println!("{}", if res % 2 == 0 { "Karen" } else { "Koyomi" });
}

//
//mod strings;
//
//fn main() {
//    strings_sample();
//}

#![allow(dead_code, unused_imports)]

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

fn read_stdin() -> String {
    let mut s = String::new();
    std::io::stdin()
        .read_line(&mut s)
        .expect("cannot read stdin");
    s.trim().to_string()
}

fn read<T>() -> T
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    read_stdin().parse::<T>().unwrap()
}

fn read_usize() -> usize {
    read::<usize>()
}

fn read_2<A, B>() -> (A, B)
where
    A: FromStr,
    <A as FromStr>::Err: Debug,
    B: FromStr,
    <B as FromStr>::Err: Debug,
{
    let s = read_stdin();
    let mut s = s.split_whitespace();
    let a = s.next().unwrap().parse::<A>().unwrap();
    let b = s.next().unwrap().parse::<B>().unwrap();
    (a, b)
}

fn read_3<A, B, C>() -> (A, B, C)
where
    A: FromStr,
    <A as FromStr>::Err: Debug,
    B: FromStr,
    <B as FromStr>::Err: Debug,
    C: FromStr,
    <C as FromStr>::Err: Debug,
{
    let s = read_stdin();
    let mut s = s.split_whitespace();
    let a = s.next().unwrap().parse::<A>().unwrap();
    let b = s.next().unwrap().parse::<B>().unwrap();
    let c = s.next().unwrap().parse::<C>().unwrap();
    (a, b, c)
}

fn read_4<A, B, C, D>() -> (A, B, C, D)
where
    A: FromStr,
    <A as FromStr>::Err: Debug,
    B: FromStr,
    <B as FromStr>::Err: Debug,
    C: FromStr,
    <C as FromStr>::Err: Debug,
    D: FromStr,
    <D as FromStr>::Err: Debug,
{
    let s = read_stdin();
    let mut s = s.split_whitespace();
    let a = s.next().unwrap().parse::<A>().unwrap();
    let b = s.next().unwrap().parse::<B>().unwrap();
    let c = s.next().unwrap().parse::<C>().unwrap();
    let d = s.next().unwrap().parse::<D>().unwrap();
    (a, b, c, d)
}

fn read_multiple<T: FromStr>() -> Vec<T>
where
    <T as FromStr>::Err: Debug,
{
    read_stdin()
        .split_whitespace()
        .map(|x| x.parse::<T>().expect("cannot parse stdin"))
        .collect()
}

/// NOTE: sort iter beforehand if required
fn count<T>(iter: &mut impl Iterator<Item = T>) -> Vec<(T, usize)>
where
    T: std::cmp::Ord,
{
    let iter = iter.collect::<Vec<_>>();
    //iter.sort();
    let (mut v, o, c) =
        iter.into_iter()
            .fold((Vec::new(), None, 0), |(mut v, last, count), item| {
                if let Some(o) = last {
                    if item == o {
                        (v, Some(o), count + 1)
                    } else {
                        v.push((o, count));
                        (v, Some(item), 1)
                    }
                } else {
                    (v, Some(item), 1)
                }
            });
    if let Some(i) = o {
        v.push((i, c));
    }
    v
}

fn partial_sum<T>(v: impl Iterator<Item = T>) -> impl Iterator<Item = T>
where
    T: Default + std::ops::Add<Output = T> + Copy,
{
    v.scan(T::default(), |state, x| {
        *state = *state + x;
        Some(*state)
    })
}

fn max_subarray(v: impl Iterator<Item = i64>) -> (i64, (usize, usize)) {
    //assert!(v.len() > 0);
    let mut best_sum = 0;
    let (mut best_start, mut best_end) = (0, 0);
    let mut current_sum = 0;
    let mut current_start = 0;
    for (end, val) in v.enumerate() {
        if current_sum <= 0 {
            current_start = end;
            current_sum = val;
        } else {
            current_sum += val;
        }
        if current_sum > best_sum {
            best_sum = current_sum;
            best_start = current_start;
            best_end = end + 1;
        }
    }
    (best_sum, (best_start, best_end))
}

fn gcd(mut a: u64, mut b: u64) -> u64 {
    while a != 0 {
        let old_m = a;
        a = b % a;
        b = old_m;
    }
    b
}

/// returns gcd, and pair (x, y), such that x * a + b * y == gcd
fn egcd(a: i64, b: i64) -> (i64, i64, i64) {
    if a == 0 {
        (b, 0, 1)
    } else {
        let (g, x, y) = egcd(b % a, a);
        (g, y - (b / a) * x, x)
    }
}

fn factorize(mut n: u64) -> Vec<u64> {
    if n <= 3 {
        return vec![n];
    }
    let mut v = Vec::new();
    while n % 2 == 0 {
        n /= 2;
        v.push(2);
    }
    while n % 3 == 0 {
        n /= 3;
        v.push(3);
    }
    let mut f = 6;
    while (f - 1) * (f - 1) <= n {
        while n % (f - 1) == 0 {
            n /= f - 1;
            v.push(f - 1);
        }
        while n % (f + 1) == 0 {
            n /= f + 1;
            v.push(f + 1);
        }
        f += 6;
    }
    if n > 1 {
        v.push(n);
    }
    v
}

fn compact_factors(n: u64) -> Vec<(u64, usize)> {
    count(&mut factorize(n).into_iter())
}

fn all_factors(n: u64) -> Vec<u64> {
    if n == 0 {
        return vec![0];
    } else if n == 1 {
        return vec![1];
    }
    let factors = compact_factors(n);
    let mut v = vec![1];
    for (fac, num) in factors {
        let ori = v.clone();
        for i in 1..num + 1 {
            v.append(
                &mut ori
                    .clone()
                    .into_iter()
                    .map(|f| f * fac.pow(i as u32))
                    .collect::<Vec<_>>(),
            )
        }
    }
    v.sort();
    v
}

fn abs_diff<T>(a: T, b: T) -> T
where
    T: PartialOrd + std::ops::Sub<Output = T>,
{
    if a > b {
        a - b
    } else {
        b - a
    }
}

struct Permutations<T> {
    inner: Vec<T>,
    state: Vec<usize>,
    i: usize,
    start: bool,
}

impl<T> Permutations<T> {
    fn new(inner: Vec<T>) -> Self {
        Self {
            state: vec![0; inner.len()],
            i: 0,
            start: true,
            inner,
        }
    }
}

/*impl<T, X> From<X> for Permutations<T>
where
    X: IntoIterator<Item = T>,
{
    fn from(f: X) -> Self {
        Self::new(f.into_iter().collect::<Vec<T>>())
    }
}*/

impl<T> Iterator for Permutations<T>
where
    T: Clone,
{
    type Item = Vec<T>;
    fn next(&mut self) -> Option<Self::Item> {
        if self.start {
            self.start = false;
            return Some(self.inner.clone());
        }
        while self.i < self.inner.len() {
            if self.state[self.i] < self.i {
                if self.i % 2 == 0 {
                    self.inner.swap(0, self.i)
                } else {
                    self.inner.swap(self.state[self.i], self.i)
                }
                self.state[self.i] += 1;
                self.i = 0;
                return Some(self.inner.clone());
            } else {
                self.state[self.i] = 0;
                self.i += 1;
            }
        }
        None
    }
}

use std::cmp::{max, min, Ord, Ordering};
use std::collections::{BinaryHeap, VecDeque};
use std::mem::swap;

#[derive(Clone)]
struct Graph {
    nodes: usize,
    edges: Vec<Vec<(usize, u64)>>,
}

impl Graph {
    fn new(n: usize) -> Self {
        Self {
            nodes: n,
            edges: vec![Vec::new(); n + 1],
        }
    }

    fn add_edge(&mut self, x: usize, y: usize, cost: u64) {
        self.edges[x].push((y, cost));
        self.edges[y].push((x, cost));
    }

    fn dijkstra(&mut self, start: usize, end: usize) -> u64 {
        let mut dist = vec![None; self.nodes + 1];
        let mut prev = vec![None; self.nodes + 1];
        dist[start] = Some(0);
        let mut queue = (1..=self.nodes).collect::<Vec<_>>();
        queue.sort_unstable_by_key(|node| dist[*node].unwrap_or(std::u64::MAX));
        queue.reverse();
        while let Some(next_node) = queue.pop() {
            if next_node == end {
                return dist[next_node].unwrap();
            }
            for (neighbour, cost) in self.edges[next_node].iter() {
                let alt = dist[next_node].unwrap() + cost;
                if dist[*neighbour].is_none() {
                    dist[*neighbour] = Some(alt);
                    prev[*neighbour] = Some(next_node);
                } else {
                    if alt < dist[*neighbour].unwrap() {
                        dist[*neighbour] = Some(alt);
                        prev[*neighbour] = Some(next_node);
                    }
                }
            }
            //println!("{:?} {:?}", dist, prev);
            queue.sort_unstable_by_key(|node| dist[*node].unwrap_or(std::u64::MAX));
            queue.reverse();
        }
        0
    }

    fn set_cost(&mut self, x: usize, y: usize, cost: u64) {
        for i in 0..self.edges[x].len() {
            if self.edges[x][i].0 == y {
                self.edges[x][i].1 = cost
            }
        }
        for i in 0..self.edges[y].len() {
            if self.edges[y][i].0 == x {
                self.edges[y][i].1 = cost
            }
        }
    }
}

const MODULO: u64 = 1_000_000_007;

#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
struct BigPrimeRing {
    inner: u64,
}

impl<T> From<T> for BigPrimeRing
where
    T: Into<u64>,
{
    fn from(n: T) -> Self {
        Self {
            inner: n.into() % MODULO,
        }
    }
}

impl<T> std::ops::Add<T> for BigPrimeRing
where
    T: Into<Self>,
{
    type Output = BigPrimeRing;
    fn add(self, rhs: T) -> Self::Output {
        Self {
            inner: (self.inner + rhs.into().inner) % MODULO,
        }
    }
}

impl<T> std::ops::AddAssign<T> for BigPrimeRing
where
    T: Into<Self>,
{
    fn add_assign(&mut self, rhs: T) {
        self.inner += rhs.into().inner;
        self.inner %= MODULO;
    }
}

impl<T> std::ops::Sub<T> for BigPrimeRing
where
    T: Into<Self>,
{
    type Output = BigPrimeRing;
    fn sub(self, rhs: T) -> Self::Output {
        Self {
            inner: (self.inner + MODULO - rhs.into().inner) % MODULO,
        }
    }
}

impl<T> std::ops::SubAssign<T> for BigPrimeRing
where
    T: Into<Self>,
{
    fn sub_assign(&mut self, rhs: T) {
        self.inner += MODULO;
        self.inner -= rhs.into().inner;
        self.inner %= MODULO;
    }
}

impl<T> std::ops::Mul<T> for BigPrimeRing
where
    T: Into<Self>,
{
    type Output = BigPrimeRing;
    fn mul(self, rhs: T) -> Self::Output {
        Self {
            inner: (self.inner * rhs.into().inner) % MODULO,
        }
    }
}

impl<T> std::ops::MulAssign<T> for BigPrimeRing
where
    T: Into<Self>,
{
    fn mul_assign(&mut self, rhs: T) {
        self.inner *= rhs.into().inner;
        self.inner %= MODULO;
    }
}

impl BigPrimeRing {
    fn inverse(self) -> Self {
        if self.inner == 0 {
            return self;
        }
        let (_g, mut x, _y) = egcd(self.inner as i64, MODULO as i64);
        if x < 0 {
            x += MODULO as i64;
        }
        Self { inner: x as u64 }
    }
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let _n = read_usize();
    let a_vec = read_multiple::<u64>();
    let b_vec = read_multiple::<u64>();
    let mut count = 0;
    for (a, b) in a_vec.iter().zip(b_vec.iter()) {
        if a_vec.contains(&(a ^ b)) || b_vec.contains(&(a ^ b)) {
            count += 1;
        }
    }
    if count % 2 == 0 {
        println!("Karen")
    } else {
        println!("Koyomi")
    }
    Ok(())
}