module Prelude = struct
  let scanf = Scanf.scanf
  let printf = Printf.printf

  module Int = struct
    type t = int
    let compare = compare
  end
end

open Prelude

module IntSet = Set.Make(Int)

let gen_prime_t = Array.create 100000 0
let gen_prime (upto: int): int array =
  let rec f (n: int) (s: int): int =
    if n > upto
    then s
    else
      let rec is_prime i =
        if i >= s then true
        else
          let t = Array.get gen_prime_t i in
          if t > n / 2 then true
          else if n mod t = 0 then false
          else is_prime (i + 1)
      in f (n + 2) (if is_prime 0 then (Array.set gen_prime_t s n; s + 1) else s)
  in
  Array.set gen_prime_t 0 2;
  let l = f 3 1 in Array.sub gen_prime_t 0 l

module PrimeFactors = struct
  type item = { factor: int; count: int; }
  type t = item list

  let to_string (src: t) =
    src |>
    List.map (fun { factor; count } -> Printf.sprintf "(%d * %d)" count factor) |>
    String.concat " "

  let get_all_factors (src: t): int list =
    let rec outer (n: int) (src: item list) (ret: int list): int list =
      match src with
      | [] -> n :: ret
      | item :: items ->
        let rec inner (i: int) (n: int) (ret: int list): int list =
          if i > item.count
          then ret
          else
            let ret = outer n items ret in
            inner (i + 1) (n * item.factor) ret
        in inner 0 n ret
    in outer 1 src []

end

let factorize (primes: int array) (src: int64): PrimeFactors.t =
  let rec f (cur: int64) (i: int) (ret: PrimeFactors.t) =
    if i >= Array.length primes then ret else
      let rec g (cur: int64) (n: int): int64 * int = Int64.(
        let t = Array.get primes i in
        if (rem cur (of_int t)) = zero
        then g (div cur (of_int t)) (n + 1)
        else (cur, n)
      ) in
      let cur, t = g cur 0 in
      let ret = if t = 0 then ret else { factor = Array.get primes i; count = t } :: ret in
      f cur (i + 1) ret
  in f src 0 []

  (* NOTE: we don't need the second extra check, the rem will do it ... *)
  (* if lhs > rhs then gcd rhs Int64.(rem lhs rhs) *)
let rec gcd (lhs: int64) (rhs: int64): int64 =
  Int64.(if rhs = zero then lhs else gcd rhs (rem lhs rhs))

let _ =
  (* let primes = gen_prime 100000 in *)
  (* printf "gen complete\n";
   * let factors = factorize primes (Int64.of_int 720720) in
   * PrimeFactors.get_all_factors factors |> List.iter (printf "%d\n")
   * printf "%s\n" (factorize primes (Int64.of_int 8400) |> PrimeFactors.to_string) *)
  let n, k, a, b = scanf "%d %d %d %d" (fun a b c d -> a, b, c, d) in Int64.(
  let n, k, a, b = of_int n, of_int k, of_int a, of_int b in
  let total = (mul n k) in
  let do_try (posb: int64) (maxv, minv): int64 * int64 =
    let time = (div total (gcd total (sub posb a))) in (* let l = (sub posb a) in let actual_l = gcd total l in *)
    ((if time > maxv then time else maxv), (if time < minv then time else minv))
  in
  let rec test_cycle (posb: int64) (maxv, minv): int64 * int64 =
    if posb > (add total a)
    then (maxv, minv)
    else test_cycle (add posb k) (do_try posb (maxv, minv))
  in
  let tu = (Int64.min_int, Int64.max_int) in
  let tu = tu |> test_cycle (add k b) |> test_cycle (sub k b) in
  let (maxv, minv) = tu in
  printf "%Ld %Ld\n" minv maxv)
  (* let factors = PrimeFactors.get_all_factors (factorize primes total) in
   * let rec f (factors: int list) (maxv: int64) (minv: int64): int64 * int64 =
   *   match factors with
   *   | [] -> maxv, minv
   *   | l :: factors ->
   *     let dist2 = (rem (add (of_int a) (of_int l)) (of_int k)) in
   *     if (dist2 = (of_int b)) || (dist2 = (of_int (k - b)))
   *     then
   *       let time = (div total (of_int l)) in
   *       let maxv = if Int64.compare time maxv > 0 then time else maxv in
   *       let minv = if Int64.compare time minv < 0 then time else minv in
   *       f factors maxv minv
   *     else f factors maxv minv
   * in
   * let maxv, minv = f factors min_int max_int in *)

module Prelude = struct
  let scanf = Scanf.scanf
  let printf = Printf.printf

  module Int = struct
    type t = int
    let compare = compare
  end
end

open Prelude

module IntSet = Set.Make(Int)

let gen_prime_t = Array.create 100000 0
let gen_prime (upto: int): int array =
  let rec f (n: int) (s: int): int =
    if n > upto
    then s
    else
      let rec is_prime i =
        if i >= s then true
        else
          let t = Array.get gen_prime_t i in
          if t > n / 2 then true
          else if n mod t = 0 then false
          else is_prime (i + 1)
      in f (n + 2) (if is_prime 0 then (Array.set gen_prime_t s n; s + 1) else s)
  in
  Array.set gen_prime_t 0 2;
  let l = f 3 1 in Array.sub gen_prime_t 0 l

module PrimeFactors = struct
  type item = { factor: int; count: int; }
  type t = item list

  let to_string (src: t) =
    src |>
    List.map (fun { factor; count } -> Printf.sprintf "(%d * %d)" count factor) |>
    String.concat " "

  let get_all_factors (src: t): int list =
    let rec outer (n: int) (src: item list) (ret: int list): int list =
      match src with
      | [] -> n :: ret
      | item :: items ->
        let rec inner (i: int) (n: int) (ret: int list): int list =
          if i > item.count
          then ret
          else
            let ret = outer n items ret in
            inner (i + 1) (n * item.factor) ret
        in inner 0 n ret
    in outer 1 src []

end

let factorize (primes: int array) (src: int64): PrimeFactors.t =
  let rec f (cur: int64) (i: int) (ret: PrimeFactors.t) =
    if i >= Array.length primes then ret else
      let rec g (cur: int64) (n: int): int64 * int = Int64.(
        let t = Array.get primes i in
        if (rem cur (of_int t)) = zero
        then g (div cur (of_int t)) (n + 1)
        else (cur, n)
      ) in
      let cur, t = g cur 0 in
      let ret = if t = 0 then ret else { factor = Array.get primes i; count = t } :: ret in
      f cur (i + 1) ret
  in f src 0 []

let rec gcd (lhs: int64) (rhs: int64): int64 =
  if rhs = Int64.zero
  then lhs
  (* NOTE: we don't need the second extra check, the rem will do it ... *)
  (* if lhs > rhs then gcd rhs Int64.(rem lhs rhs) *)
  else gcd rhs Int64.(rem lhs rhs)

let _ =
  (* let primes = gen_prime 100000 in *)
  (* printf "gen complete\n";
   * let factors = factorize primes (Int64.of_int 720720) in
   * PrimeFactors.get_all_factors factors |> List.iter (printf "%d\n")
   * printf "%s\n" (factorize primes (Int64.of_int 8400) |> PrimeFactors.to_string) *)
  let n, k, a, b = scanf "%d %d %d %d" (fun a b c d -> a, b, c, d) in Int64.(
  let total = (mul (of_int n) (of_int k)) in
  let do_try (posb: int64) (maxv, minv): int64 * int64 =
    let time =
      let l = (sub posb (of_int a)) in
      let actual_l = gcd total l in
      (div total actual_l)
    in
    let maxv = if Int64.compare time maxv > 0 then time else maxv in
    let minv = if Int64.compare time minv < 0 then time else minv in
    (maxv, minv)
  in
  let rec test_cycle (posb: int64) (maxv, minv): int64 * int64 =
    if posb > (add total (of_int a))
    then (maxv, minv)
    else let tu = do_try posb (maxv, minv) in test_cycle (add posb (of_int k)) tu
  in
  let tu = (Int64.min_int, Int64.max_int) in
  let tu = test_cycle (sub (of_int k) (of_int b)) tu in
  let tu = test_cycle (add (of_int k) (of_int b)) tu in
  let (maxv, minv) = tu in
  printf "%Ld %Ld\n" minv maxv)
  (* let factors = PrimeFactors.get_all_factors (factorize primes total) in
   * let rec f (factors: int list) (maxv: int64) (minv: int64): int64 * int64 =
   *   match factors with
   *   | [] -> maxv, minv
   *   | l :: factors ->
   *     let dist2 = (rem (add (of_int a) (of_int l)) (of_int k)) in
   *     if (dist2 = (of_int b)) || (dist2 = (of_int (k - b)))
   *     then
   *       let time = (div total (of_int l)) in
   *       let maxv = if Int64.compare time maxv > 0 then time else maxv in
   *       let minv = if Int64.compare time minv < 0 then time else minv in
   *       f factors maxv minv
   *     else f factors maxv minv
   * in
   * let maxv, minv = f factors min_int max_int in *)

module Prelude = struct
  let scanf = Scanf.scanf
  let printf = Printf.printf

  module Int = struct
    type t = int
    let compare = compare
  end
end

open Prelude

module IntSet = Set.Make(Int)

let gen_prime_t = Array.create 100000 0
let gen_prime (upto: int): int array =
  let rec f (n: int) (s: int): int =
    if n > upto
    then s
    else
      let rec is_prime i =
        if i >= s then true
        else
          let t = Array.get gen_prime_t i in
          if t > n / 2 then true
          else if n mod t = 0 then false
          else is_prime (i + 1)
      in f (n + 2) (if is_prime 0 then (Array.set gen_prime_t s n; s + 1) else s)
  in
  Array.set gen_prime_t 0 2;
  let l = f 3 1 in Array.sub gen_prime_t 0 l

module PrimeFactors = struct
  type item = { factor: int; count: int; }
  type t = item list

  let to_string (src: t) =
    src |>
    List.map (fun { factor; count } -> Printf.sprintf "(%d * %d)" count factor) |>
    String.concat " "

  let get_all_factors (src: t): int list =
    let rec outer (n: int) (src: item list) (ret: int list): int list =
      match src with
      | [] -> n :: ret
      | item :: items ->
        let rec inner (i: int) (n: int) (ret: int list): int list =
          if i > item.count
          then ret
          else
            let ret = outer n items ret in
            inner (i + 1) (n * item.factor) ret
        in inner 0 n ret
    in outer 1 src []

end

let factorize (primes: int array) (src: int64): PrimeFactors.t =
  let rec f (cur: int64) (i: int) (ret: PrimeFactors.t) =
    if i >= Array.length primes then ret else
      let rec g (cur: int64) (n: int): int64 * int = Int64.(
        let t = Array.get primes i in
        if (rem cur (of_int t)) = zero
        then g (div cur (of_int t)) (n + 1)
        else (cur, n)
      ) in
      let cur, t = g cur 0 in
      let ret = if t = 0 then ret else { factor = Array.get primes i; count = t } :: ret in
      f cur (i + 1) ret
  in f src 0 []

let rec gcd (lhs: int64) (rhs: int64): int64 =
  if rhs = Int64.zero
  then lhs
  (* NOTE: we don't need the second extra check, the rem will do it ... *)
  (* if lhs > rhs then gcd rhs Int64.(rem lhs rhs) *)
  else gcd rhs Int64.(rem lhs rhs)

let _ =
  (* let primes = gen_prime 100000 in *)
  (* printf "gen complete\n";
   * let factors = factorize primes (Int64.of_int 720720) in
   * PrimeFactors.get_all_factors factors |> List.iter (printf "%d\n")
   * printf "%s\n" (factorize primes (Int64.of_int 8400) |> PrimeFactors.to_string) *)
  let n, k, a, b = scanf "%d %d %d %d" (fun a b c d -> a, b, c, d) in Int64.(
  let total = (mul (of_int n) (of_int k)) in
  let do_try (posb: int64) (maxv, minv): int64 * int64 =
    let time =
      let l = (sub posb (of_int a)) in
      let actual_l = gcd total l in
      (div total actual_l)
    in
    let maxv = if Int64.compare time maxv > 0 then time else maxv in
    let minv = if Int64.compare time minv < 0 then time else minv in
    (maxv, minv)
  in
  let rec test_cycle (posb: int64) (maxv, minv): int64 * int64 =
    if posb > (add total (of_int a))
    then (maxv, minv)
    else let tu = do_try posb (maxv, minv) in test_cycle (add posb (of_int k)) tu
  in
  let tu = (Int64.min_int, Int64.max_int) in
  let tu = test_cycle (sub (of_int k) (of_int b)) tu in
  let tu = test_cycle (add (of_int k) (of_int b)) tu in
  let (maxv, minv) = tu in
  (* let factors = PrimeFactors.get_all_factors (factorize primes total) in
   * let rec f (factors: int list) (maxv: int64) (minv: int64): int64 * int64 =
   *   match factors with
   *   | [] -> maxv, minv
   *   | l :: factors ->
   *     let dist2 = (rem (add (of_int a) (of_int l)) (of_int k)) in
   *     if (dist2 = (of_int b)) || (dist2 = (of_int (k - b)))
   *     then
   *       let time = (div total (of_int l)) in
   *       let maxv = if Int64.compare time maxv > 0 then time else maxv in
   *       let minv = if Int64.compare time minv < 0 then time else minv in
   *       f factors maxv minv
   *     else f factors maxv minv
   * in
   * let maxv, minv = f factors min_int max_int in *)
  printf "%Ld %Ld\n" minv maxv)

module Prelude = struct
  let scanf = Scanf.scanf
  let printf = Printf.printf

  module Int = struct
    type t = int
    let compare = compare
  end
end

open Prelude

module IntSet = Set.Make(Int)

let gen_prime_t = Array.create 100000 0
let gen_prime (upto: int): int array =
  let rec f (n: int) (s: int): int =
    if n > upto
    then s
    else
      let rec is_prime i =
        if i >= s then true
        else
          let t = Array.get gen_prime_t i in
          if t > n / 2 then true
          else if n mod t = 0 then false
          else is_prime (i + 1)
      in f (n + 2) (if is_prime 0 then (Array.set gen_prime_t s n; s + 1) else s)
  in
  Array.set gen_prime_t 0 2;
  let l = f 3 1 in Array.sub gen_prime_t 0 l

module PrimeFactors = struct
  type item = { factor: int; count: int; }
  type t = item list

  let to_string (src: t) =
    src |>
    List.map (fun { factor; count } -> Printf.sprintf "(%d * %d)" count factor) |>
    String.concat " "

  let get_all_factors (src: t): int list =
    let rec outer (n: int) (src: item list) (ret: int list): int list =
      match src with
      | [] -> n :: ret
      | item :: items ->
        let rec inner (i: int) (n: int) (ret: int list): int list =
          if i > item.count
          then ret
          else
            let ret = outer n items ret in
            inner (i + 1) (n * item.factor) ret
        in inner 0 n ret
    in outer 1 src []

end

let factorize (primes: int array) (src: int64): PrimeFactors.t =
  let rec f (cur: int64) (i: int) (ret: PrimeFactors.t) =
    if i >= Array.length primes then ret else
      let rec g (cur: int64) (n: int): int64 * int = Int64.(
        let t = Array.get primes i in
        if (rem cur (of_int t)) = zero
        then g (div cur (of_int t)) (n + 1)
        else (cur, n)
      ) in
      let cur, t = g cur 0 in
      let ret = if t = 0 then ret else { factor = Array.get primes i; count = t } :: ret in
      f cur (i + 1) ret
  in f src 0 []

let rec gcd (lhs: int64) (rhs: int64): int64 =
  if rhs = Int64.zero
  then lhs
  (* NOTE: we don't need the second extra check, the rem will do it ... *)
  (* if lhs > rhs then gcd rhs Int64.(rem lhs rhs) *)
  else gcd rhs Int64.(rem lhs rhs)

let _ =
  (* let primes = gen_prime 100000 in *)
  (* printf "gen complete\n";
   * let factors = factorize primes (Int64.of_int 720720) in
   * PrimeFactors.get_all_factors factors |> List.iter (printf "%d\n")
   * printf "%s\n" (factorize primes (Int64.of_int 8400) |> PrimeFactors.to_string) *)
  let n, k, a, b = scanf "%d %d %d %d" (fun a b c d -> a, b, c, d) in Int64.(
  let n, k, a, b = of_int n, of_int k, of_int a, of_int b in
  let total = (mul n k) in
  let do_try (posb: int64) (maxv, minv): int64 * int64 =
    let time =
      let l = (sub posb a) in
      let actual_l = gcd total l in
      (div total actual_l)
    in
    let maxv = if Int64.compare time maxv > 0 then time else maxv in
    let minv = if Int64.compare time minv < 0 then time else minv in
    (maxv, minv)
  in
  let rec test_cycle (posb: int64) (maxv, minv): int64 * int64 =
    if posb > (add total a)
    then (maxv, minv)
    else let tu = do_try posb (maxv, minv) in test_cycle (add posb k) tu
  in
  let tu = (Int64.min_int, Int64.max_int) in
  let tu = tu |> test_cycle (add k b) |> test_cycle (sub k b) in
  let (maxv, minv) = tu in
  printf "%Ld %Ld\n" minv maxv)
  (* let factors = PrimeFactors.get_all_factors (factorize primes total) in
   * let rec f (factors: int list) (maxv: int64) (minv: int64): int64 * int64 =
   *   match factors with
   *   | [] -> maxv, minv
   *   | l :: factors ->
   *     let dist2 = (rem (add (of_int a) (of_int l)) (of_int k)) in
   *     if (dist2 = (of_int b)) || (dist2 = (of_int (k - b)))
   *     then
   *       let time = (div total (of_int l)) in
   *       let maxv = if Int64.compare time maxv > 0 then time else maxv in
   *       let minv = if Int64.compare time minv < 0 then time else minv in
   *       f factors maxv minv
   *     else f factors maxv minv
   * in
   * let maxv, minv = f factors min_int max_int in *)

module Prelude = struct
  let scanf = Scanf.scanf
  let printf = Printf.printf

  module Int = struct
    type t = int
    let compare = compare
  end
end

open Prelude

module IntSet = Set.Make(Int)

let gen_prime_t = Array.create 100000 0
let gen_prime (upto: int): int array =
  let rec f (n: int) (s: int): int =
    if n > upto
    then s
    else
      let rec is_prime i =
        if i >= s then true
        else
          let t = Array.get gen_prime_t i in
          if t > n / 2 then true
          else if n mod t = 0 then false
          else is_prime (i + 1)
      in f (n + 2) (if is_prime 0 then (Array.set gen_prime_t s n; s + 1) else s)
  in
  Array.set gen_prime_t 0 2;
  let l = f 3 1 in Array.sub gen_prime_t 0 l

module PrimeFactors = struct
  type item = { factor: int; count: int; }
  type t = item list

  let to_string (src: t) =
    src |>
    List.map (fun { factor; count } -> Printf.sprintf "(%d * %d)" count factor) |>
    String.concat " "

  let get_all_factors (src: t): int list =
    let rec outer (n: int) (src: item list) (ret: int list): int list =
      match src with
      | [] -> n :: ret
      | item :: items ->
        let rec inner (i: int) (n: int) (ret: int list): int list =
          if i > item.count
          then ret
          else
            let ret = outer n items ret in
            inner (i + 1) (n * item.factor) ret
        in inner 0 n ret
    in outer 1 src []

end

let factorize (primes: int array) (src: int64): PrimeFactors.t =
  let rec f (cur: int64) (i: int) (ret: PrimeFactors.t) =
    if i >= Array.length primes then ret else
      let rec g (cur: int64) (n: int): int64 * int = Int64.(
        let t = Array.get primes i in
        if (rem cur (of_int t)) = zero
        then g (div cur (of_int t)) (n + 1)
        else (cur, n)
      ) in
      let cur, t = g cur 0 in
      let ret = if t = 0 then ret else { factor = Array.get primes i; count = t } :: ret in
      f cur (i + 1) ret
  in f src 0 []

let _ =
  let primes = gen_prime 100000 in
  (* printf "gen complete\n";
   * let factors = factorize primes (Int64.of_int 720720) in
   * PrimeFactors.get_all_factors factors |> List.iter (printf "%d\n")
   * printf "%s\n" (factorize primes (Int64.of_int 8400) |> PrimeFactors.to_string) *)
  let n, k, a, b = scanf "%d %d %d %d" (fun a b c d -> a, b, c, d) in Int64.(
  let total = (mul (of_int n) (of_int k)) in
  let factors = PrimeFactors.get_all_factors (factorize primes total) in
  let rec f (factors: int list) (maxv: int64) (minv: int64): int64 * int64 =
    match factors with
    | [] -> maxv, minv
    | l :: factors ->
      let dist2 = (rem (add (of_int a) (of_int l)) (of_int k)) in
      if (dist2 = (of_int b)) || (dist2 = (of_int (k - b)))
      then
        let time = (div total (of_int l)) in
        let maxv = if Int64.compare time maxv > 0 then time else maxv in
        let minv = if Int64.compare time minv < 0 then time else minv in
        f factors maxv minv
      else f factors maxv minv
  in
  let maxv, minv = f factors min_int max_int in
  printf "%Ld %Ld\n" minv maxv)


let () = Scanf.scanf "%d\n" (fun n ->
    let arr = Array.make_matrix n n 1 in
    for i = 1 to n - 1 do
        for j = 1 to n - 1 do
            arr.(i).(j) <- arr.(i-1).(j) + arr.(i).(j-1)
        done
    done;
    Printf.printf "%d\n" arr.(n-1).(n-1))

let solve () =
    let n = Scanf.scanf "%d" (fun n -> n) in
    let rec f i =
        if i = 0
        then
            1
        else
            (f (i - 1) * (i * 2) * ((i * 2) - 1)/ i )/ i in
    f (n - 1)

let print result = Printf.printf "%d\n" result
let () = print (solve ())

let solve () =
    let n = Scanf.scanf "%d" (fun n -> n) in
    let rec loop i prev =
        if i < n
        then
            let rec looper j current =
                if j < n
                then
                    (let element = (Array.get prev j) + (Array.get current (j - 1)) in
                    Array.set current j element;
                    looper (j + 1) current)
                else
                    loop (i + 1) current
            in looper 1 (Array.make n 1)
        else
            Array.get prev (n - 1)
    in loop 1 (Array.make n 1)

let print result = Printf.printf "%d\n" result
let () = print (solve ())

open Printf
open Scanf

let ( ++ ) a b = Int64.add a b

(*------------create binomial--------------*)
let init_binomial n m =
  (* compute an array b so that b.(p).(q) = (p choose q),
     where 0 <= p <= n and 0 <= q <= m. *)
  let b = Array.make_matrix (n+1) (m+1) 0L in
    for i=0 to n do for j=0 to min i m do
      b.(i).(j) <- if j=0 then 1L else b.(i-1).(j-1) ++ b.(i-1).(j)
    done done;
    b

let read_int () = bscanf Scanning.stdib " %d " (fun x -> x)
let () =
  let n = read_int () in

  let b = init_binomial (2*(n-1)) (2*(n-1)) in

  printf "%Ld\n" (b.(2*(n-1)).(n-1))


let dist = function
  | [[x1; y1] ; [x2; y2]] ->
      begin
        let open Int64 in
        max
          (abs (sub x1 x2))
          (abs (sub y1 y2))
      end
  | _ -> Int64.zero

let () =
  let line1 = read_line () in
  let line2 = read_line () in
  [ line1; line2 ]
  |> List.map (fun x -> List.map Int64.of_string  @@ Str.split (Str.regexp " ") x)
  |> dist |> Int64.to_string
  |> print_string
  |> print_newline

let xint() = Scanf.scanf " %ld" (fun x -> x)

let () =
  let x1 = xint() and y1 = xint() in
  let x2 = xint() and y2 = xint() in
  let abs x =
    if Int32.compare x 0l < 0 then Int32.sub 0l x
    else x
  in
  let x = abs (Int32.sub x2 x1) in
  let y = abs (Int32.sub y2 y1) in
  Printf.printf "%ld\n" (
    if Int32.compare x y > 0 then x
    else y
  )

let (+|) = Int64.add
let (-|) = Int64.sub
let ( *| ) = Int64.mul
let ( /| ) = Int64.div

let _ =
  let sb = Scanf.Scanning.stdib in
  let x1 = Scanf.bscanf sb "%Ld " (fun s -> s) in
  let y1 = Scanf.bscanf sb "%Ld " (fun s -> s) in
  let x2 = Scanf.bscanf sb "%Ld " (fun s -> s) in
  let y2 = Scanf.bscanf sb "%Ld " (fun s -> s) in
  let res = max (Int64.abs (x1 -| x2)) (Int64.abs (y1 -| y2)) in
    Printf.printf "%Ld\n" res

open Printf
open Scanf

let ( ** ) a b = Int64.mul a b
let ( ++ ) a b = Int64.add a b
let ( -- ) a b = Int64.sub a b
let abs = Int64.abs

let read_pair () = bscanf Scanning.stdib " %Ld %Ld " (fun x y -> (x,y))
let () =
  let (x1,y1) = read_pair () in
  let (x2,y2) = read_pair () in

  printf "%Ld\n" (max (abs (x1--x2)) (abs (y1--y2)))

let dist = function
  | [[x1; y1] ; [x2; y2]] -> begin
    max
    (abs (x1 - x2))
    (abs (y1 - y2))
  end
  | _ -> -1

let () =
  let line1 = read_line () in
  let line2 = read_line () in
  [ line1; line2 ]
  |> List.map (fun x -> List.map int_of_string  @@ Str.split (Str.regexp " ") x)
  |> dist
  |> print_int
  |> print_newline

let xint() = Scanf.scanf " %d" (fun x -> x)

let () =
  let x1 = xint() and y1 = xint() in
  let x2 = xint() and y2 = xint() in
  let abs x =
    if x < 0 then -x
    else x
  in
  let x = abs (x2 - x1) in
  let y = abs (y2 - y1) in
  Printf.printf "%d\n" (
    if x > y then x
    else y
  )


let read_int () = Scanf.bscanf Scanf.Scanning.stdib " %d " (fun x -> x)

let () =
  let n = read_int() in
  let a = Array.init n (fun i -> read_int()) in
  let c = Array.make 3 0 in
    for i=0 to n-1 do
      let e = i mod 3 in
	c.(e) <- c.(e) + a.(i);
    done;

    let m = max (max c.(0) c.(1)) c.(2) in
    let s = if c.(0) = m then "chest"
    else if c.(1) = m then "biceps"
    else "back" in

      Printf.printf "%s\n" s

let read_int () = Scanf.bscanf Scanf.Scanning.stdib " %d " (fun x -> x) ;;

let n = read_int () ;;

let a =
    let rec loop i n f =
        if i = n then f []
        else let ai = read_int () in loop (i + 1) n (fun l -> f (ai :: l))
    in loop 0 n (fun x -> x) ;;

let count l =
    let rec loop i (chest, biceps, back) = function
        | [] -> (chest, biceps, back)
        | h :: t ->
            if i mod 3 = 0 then loop (i + 1) (chest + h, biceps, back) t
            else if i mod 3 = 1 then loop (i + 1) (chest, biceps + h, back) t
            else loop (i + 1) (chest, biceps, back + h) t
    in loop 0 (0, 0, 0) l ;;

let strongest_muscle (chest, biceps, back) =
    if chest > biceps && chest > back then "chest"
    else if biceps > chest && biceps > back then "biceps"
    else "back" ;;

Printf.printf "%s\n" (strongest_muscle (count a)) ;;


let (|>) x f = f x

let main =
  let (n, d) = Scanf.scanf "%d %d\n" (fun n d -> (n,d)) in
  let rec aux n acc =
    match n with
        0 -> acc
      | n -> aux (n-1) (acc + (Scanf.scanf "%d " (fun n -> n)))
  in
  let sum = aux n 0 in
    if (n-1)*10 + sum > d then Printf.printf "-1\n"
  else Printf.printf "%d\n" ((d-sum)/5)

let read () =  Scanf.scanf "%d " (fun n -> n)

let get_sum songs =
    let rec loop i acc =
        if i < songs
        then
            let song = read () in
            loop (i + 1) (acc + song)
        else
            acc
    in loop 0 0

let input () =
    let songs = read () in
    let time_limit = read () in
    let time_songs = get_sum songs in
    (songs, time_limit, time_songs)

let solve (songs, time_limit, time_songs) =
    let time_pauses = 10 * (songs - 1) in
    let time_needed = time_pauses + time_songs in
    if time_needed <= time_limit
    then
        (time_limit - time_songs) / 5
    else
        -1

let print result = Printf.printf "%d\n" result
let () = print (solve (input ()))

let read_int()=Scanf.scanf "%d " (fun x->x);;
let n=read_int();;
let d=read_int();;
let nb=ref 0;;
let j=ref 0;;
for i=1 to n-1 do
   let x=read_int() in
   nb:= !nb+10+x;
   j:= !j+2;
done;;
let x=Scanf.scanf "%d" (fun x->x);;
nb:= !nb+x;;
let a=d- !nb;;
if a<0 then print_int (-1) else print_int(!j+(a/5));;


let good year =
    let n1,n2,n3,n4=(year mod 10000)/1000,(year mod 1000)/100,(year mod 100)/10,(year mod 10) in
    if (n1<>n2) && (n1<>n3) && (n1<>n4) && (n2<>n3) && (n2<>n4) && (n3<>n4) then true
    else false;;
let rec solve year =
	if (good year) then year
    else solve (year+1);;
let year = read_int ();;
print_int (solve (year+1));;

let str_to_list s =
    let rec loop i l =
        if i < 0
        then l
        else loop (i - 1) ((Pervasives.int_of_char s.[i] - Pervasives.int_of_char '0') :: l) in
    loop (String.length s - 1) []

let input () = Scanf.scanf "%s" (fun s -> (List.rev (str_to_list s)))

let find_allowed year =
    let rec loop year allowed =
        match year with
        |(int :: tail) -> loop tail (List.filter((<>) int) allowed)
        |[] -> allowed
    in loop year [0;1;2;3;4;5;6;7;8;9]

let is_good year =
    List.length (find_allowed year) = 10 - List.length year

let rec increase year =
    let allowed = find_allowed year in
    match year with
    |(ones :: tail) -> (match (List.filter(fun a -> a > ones) allowed) with
        |(min :: _) when is_good tail -> (min :: tail)
        |_ -> let temp = increase tail in
        (List.hd(find_allowed temp) :: temp))
    |[] -> [1]

let solve input = List.rev (increase input)

let () = List.iter(Printf.printf "%d") (solve (input()))

let rec dig n ak =
	if n = 0 then ak
	else dig (n / 10) ((n mod 10)::ak)
;;
let good n =
	let li = List.sort compare (dig n [])
	and krok (last, ans) e =
		if e = last then (e, false)
		else (e, ans)
	in snd (List.fold_left krok (10, true) li)
;;

let rec solve n =
	if good n then n
	else solve (n + 1)
;;
let year n = solve (n + 1);;
let x = read_int ();;
print_int (year x);;

open Printf

exception Found

let n =  Scanf.scanf "%d " ( fun x -> x)

let y = ref (n+1)

let not_distinct year =
  let flag = ref false in
  try
  let s = string_of_int year in
  let l = String.length s in
  for i = 0 to l-1 do
    for j =i+1 to l -1 do
      let x = String.get s i in
      let y1 = String.get s j in
      if(x==y1) then begin flag := true; raise Found end
    done;
  done;
  !flag;
  with Found -> !flag
;;

let () =
  while( (not_distinct !y) ) do
    incr y
  done
;;

printf "%d\n" !y

let str_to_list s =
    let rec loop i l =
        if i < 0
        then l
        else loop (i - 1) ((Pervasives.int_of_char s.[i] - Pervasives.int_of_char '0') :: l) in
    loop (String.length s - 1) []

let input () = Scanf.scanf "%s" (fun s -> (List.rev (str_to_list s)))

let find_allowed year =
    let rec loop year allowed =
        match year with
        |(int :: tail) -> loop tail (List.filter((<>) int) allowed)
        |[] -> allowed
    in loop year [0; 1; 2; 3; 4; 5; 6; 7; 8; 9]

let rec increase year =
    let allowed = find_allowed year in
    match year with
    |(ones :: tail) -> (match (List.filter(fun a -> a > ones) allowed) with
        |(min :: _) -> (min :: tail)
        |[] -> let temp = increase tail in
        (List.hd(find_allowed temp) :: temp))
    |[] -> [1]

let solve input = List.rev (increase input)

let () = List.iter(Printf.printf "%d") (solve (input()))


let read_int () = Scanf.bscanf Scanf.Scanning.stdib " %d " (fun x -> x)
let read_string () = Scanf.bscanf Scanf.Scanning.stdib " %s " (fun x -> x)

let s = String.lowercase (read_string())
let k = read_int();;
for i=0 to (String.length s)-1 do
	s.[i] <- if int_of_char s.[i] < k + 97 then Char.uppercase s.[i] else Char.lowercase s.[i]
done;
Printf.printf "%s\n" s

let _ =
  let sb = Scanf.Scanning.stdib in
  let s = Scanf.bscanf sb "%s " (fun s -> s) in
  let n = Scanf.bscanf sb "%d " (fun s -> s) in
  let s = String.lowercase s in
  let res = String.make (String.length s) '\000' in
  let n = ref n in
  let pos = ref 0 in
    for i = 0 to String.length s - 1 do
      let c = s.[i] in
	if Char.code c < !n + 97
	then res.[!pos] <- Char.uppercase c
	else res.[!pos] <- c;
	incr pos
    done;
    Printf.printf "%s\n" res

let _ =
  let sb = Scanf.Scanning.stdib in
  let x = Scanf.bscanf sb "%f " (fun s -> s) in
    for a' = 1 to 10 do
      for h' = 1 to 10 do
	let a = float_of_int a'
	and h = float_of_int h' in
	let r = a *. h /. sqrt (a *. a +. 4.0 *. h *. h) in
	  if abs_float (r -. x) < 1e-6 then (
	    Printf.printf "%d %d\n" a' h';
	    exit 0
	  )
      done
    done

let read_int () = Scanf.bscanf Scanf.Scanning.stdib " %d " (fun x -> x)
let read_string () = Scanf.bscanf Scanf.Scanning.stdib " %s " (fun x -> x)

let s = String.lowercase (read_string())

let k = read_int()
;;

for i=0 to (String.length s)-1 do
  let c = s.[i] in
  let c =  if int_of_char c < k + 97 then
      Char.uppercase c else Char.lowercase c in
    s.[i] <- c
done;

Printf.printf "%s\n" s

let _ =
    let main () =
        let f a =
            Printf.printf "%.f\n" (6. *. a *. (a -. 1.) +. 1.)
        in
        Scanf.sscanf (read_line ()) "%f" f
    in
    main ()

open Int64

let rec solve n accm =
  if n < one
  then accm
  else solve (sub n one) (add accm (mul (of_int 12) (pred n)))

let solve n = solve (of_int n) one

let _ =
  Printf.printf "%s\n" (to_string (Scanf.scanf " %d" solve))

let _ =
  let sb = Scanf.Scanning.stdib in
  let a = Scanf.bscanf sb "%ld " (fun s -> s) in
  let res = Int32.add (Int32.mul 6l (Int32.mul a (Int32.sub a 1l))) 1l in
      Printf.printf "%ld\n" res;

let which f =
    let plop = ref [] in
    for a = 0 to 1 do
    for b = 0 to 1 do
    for c = 0 to 1 do
    for d = 0 to 1 do
        plop := (f (a=1) (b=1) (c=1) (d=1))::!plop
    done;
    done;
    done;
    done;
    !plop

let l =
    let olol = ref [] in
        for a = 0 to 1 do
        let b = 1 - a in
        for d = 0 to 1 do
            olol := (fun i j ->
                match i,j with
                    | true,true -> a=0
                    | true,false -> b=0
                    | false,true -> b=0
                    | false,false -> d=0
                    )::!olol;
        done;
        done;
        !olol

let prod_cart a b =
    List.(flatten (map (fun i -> map (fun j -> i,j) b) a))

let beuleu = prod_cart l (prod_cart l l)

let hamza = List.map (fun (i,(j,k)) -> i,j,k) beuleu

let f (triang,triang_sub,sqr) a b c d =
    let x = triang a b in
    let y = triang_sub c d in
    let z = sqr b c in
    let zz = triang a d in
    let dx = sqr x y in
    let dy = triang_sub z zz in
    let final = triang dx dy in
        final;;

let all_f = List.map f hamza;;

let finally = List.filter (fun i -> false = i false true true false) all_f;;

let rec no_doub = function
    | (a,b)::(c,_)::l when a = c -> no_doub ((a,b)::l)
    | x::l -> x::(no_doub l)
    | l -> l;;

let compare (a,_) (c,_) = compare a c;;

let with_sig = no_doub (List.sort compare (List.map (fun h -> which h, h) finally));;

let finnnnal = List.map snd with_sig;;

let _ =
    let kikou = Scanf.scanf "%d %d %d %d" (fun a b c d -> (List.hd finnnnal) (a=1) (b=1) (c=1) (d=1)) in
        if kikou then print_int 1 else print_int 0

let l = [(0,1,1,0),0;(0,0,0,0),0]

let rec ok x = function
    | (a,b)::l when a = x -> b
    | _::l -> ok x l
    | _ -> -1;;

let _ =
    let (a,b,c,d) = Scanf.scanf "%d %d %d %d" (fun a b c d -> (a,b,c,d)) in
    let ans = ok (a,b,c,d) l in
        if ans = -1
        then if a = 0 then print_int (1/0) else print_int 2
        else print_int ans

let rec pow x n =
    if n = 0 then 1 else x * pow x (n-1)

let olol n =
    if n = 3 then 27 else 2

let _ =
    let n = Scanf.scanf "%d" (fun n -> n) in
        print_int (olol n)

let l = [(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),1;(0,1,0,0),0;(1,1,0,0),0]

let rec ok x = function
    | (a,b)::l when a = x -> b
    | _::l -> ok x l
    | _ -> -1;;

let _ =
    let (a,b,c,d) = Scanf.scanf "%d %d %d %d" (fun a b c d -> (a,b,c,d)) in
    let ans = ok (a,b,c,d) l in
        if ans = -1
        then if b = 0 then print_int (1/0) else print_int 2
        else print_int ans

let which f =
    let plop = ref [] in
    for a = 0 to 1 do
    for b = 0 to 1 do
    for c = 0 to 1 do
    for d = 0 to 1 do
        plop := (f (a=1) (b=1) (c=1) (d=1))::!plop
    done;
    done;
    done;
    done;
    !plop

let l =
    let olol = ref [] in
        for a = 0 to 1 do
        let b = 1 - a in
        for d = 0 to 1 do
            olol := (fun i j ->
                match i,j with
                    | true,true -> a=0
                    | true,false -> b=0
                    | false,true -> b=0
                    | false,false -> d=0
                    )::!olol;
        done;
        done;
        !olol

let prod_cart a b =
    List.(flatten (map (fun i -> map (fun j -> i,j) b) a))

let beuleu = prod_cart l (prod_cart l l)

let hamza = List.map (fun (i,(j,k)) -> i,j,k) beuleu

let f (triang,triang_sub,sqr) a b c d =
    let x = triang a b in
    let y = triang_sub c d in
    let z = sqr b c in
    let zz = triang a d in
    let dx = sqr x y in
    let dy = triang_sub z zz in
    let final = triang dx dy in
        final;;

let all_f = List.map f hamza;;

let finally = List.filter (fun i -> false = i false true true false) all_f;;

let rec no_doub = function
    | (a,b)::(c,_)::l when a = c -> no_doub ((a,b)::l)
    | x::l -> x::(no_doub l)
    | l -> l;;

let compare (a,_) (c,_) = compare a c;;

let with_sig = no_doub (List.sort compare (List.map (fun h -> which h, h) finally));;

let finnnnal = List.map snd with_sig;;

let _ =
    let kikou = Scanf.scanf "%d %d %d %d" (fun a b c d -> (List.nth finnnnal 2) (a=1) (b=1) (c=1) (d=1)) in
        if kikou then print_int 1 else print_int 0

let l = [(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),0]

let rec ok x = function
    | (a,b)::l when a = x -> b
    | _::l -> ok x l
    | _ -> -1;;

let _ =
    let (a,b,c,d) = Scanf.scanf "%d %d %d %d" (fun a b c d -> (a,b,c,d)) in
    let ans = ok (a,b,c,d) l in
        if ans = -1
        then if a = 0 then print_int (1/0) else print_int 2
        else print_int ans

let l = [(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),1;(0,1,0,0),0]

let rec ok x = function
    | (a,b)::l when a = x -> b
    | _::l -> ok x l
    | _ -> -1;;

let _ =
    let (a,b,c,d) = Scanf.scanf "%d %d %d %d" (fun a b c d -> (a,b,c,d)) in
    let ans = ok (a,b,c,d) l in
        if ans = -1
        then if b = 0 then print_int (1/0) else print_int 2
        else print_int ans

let l =
    let olol = ref [] in
        for a = 0 to 1 do
        let b = 1 - a in
        for d = 0 to 1 do
            olol := (fun i j ->
                match i,j with
                    | true,true -> a=0
                    | true,false -> b=0
                    | false,true -> b=0
                    | false,false -> d=0
                    )::!olol;
        done;
        done;
        !olol

let prod_cart a b =
    List.(flatten (map (fun i -> map (fun j -> i,j) b) a))

let beuleu = prod_cart l (prod_cart l l)

let hamza = List.map (fun (i,(j,k)) -> i,j,k) beuleu

let f (triang,triang_sub,sqr) a b c d =
    let x = triang a b in
    let y = triang_sub c d in
    let z = sqr b c in
    let zz = triang a d in
    let dx = sqr x y in
    let dy = triang_sub z zz in
    let final = triang dx dy in
        final

let all_f = List.map f hamza

let finally = List.filter (fun i -> false = i false true true false) all_f

let _ =
    let kikou = Scanf.scanf "%d %d %d %d" (fun a b c d -> (List.hd finally) (a=1) (b=1) (c=1) (d=1)) in
        if kikou then print_int 1 else print_int 0

let rec solve n accm =
  if n < 1 then accm else solve (n - 1) (accm + 12*(n-1))

let solve n = solve n 1

let _ =
  Printf.printf "%d\n" (Scanf.scanf " %d" solve)

let l = [(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),1]

let rec ok x = function
    | (a,b)::l when a = x -> b
    | _::l -> ok x l
    | _ -> -1;;

let _ =
    let (a,b,c,d) = Scanf.scanf "%d %d %d %d" (fun a b c d -> (a,b,c,d)) in
    let ans = ok (a,b,c,d) l in
        if ans = -1
        then if b = 0 then print_int (1/0) else print_int 2
        else print_int ans

let which f =
    let plop = ref [] in
    for a = 0 to 1 do
    for b = 0 to 1 do
    for c = 0 to 1 do
    for d = 0 to 1 do
        plop := (f (a=1) (b=1) (c=1) (d=1))::!plop
    done;
    done;
    done;
    done;
    !plop

let l =
    let olol = ref [] in
        for a = 0 to 1 do
        let b = 1 - a in
        for d = 0 to 1 do
            olol := (fun i j ->
                match i,j with
                    | true,true -> a=0
                    | true,false -> b=0
                    | false,true -> b=0
                    | false,false -> d=0
                    )::!olol;
        done;
        done;
        !olol

let prod_cart a b =
    List.(flatten (map (fun i -> map (fun j -> i,j) b) a))

let beuleu = prod_cart l (prod_cart l l)

let hamza = List.map (fun (i,(j,k)) -> i,j,k) beuleu

let f (triang,triang_sub,sqr) a b c d =
    let x = triang a b in
    let y = triang_sub c d in
    let z = sqr b c in
    let zz = triang a d in
    let dx = sqr x y in
    let dy = triang_sub z zz in
    let final = triang dx dy in
        final;;

let all_f = List.map f hamza;;

let finally = List.filter (fun i -> false = i false true true false) all_f;;

let rec no_doub = function
    | (a,b)::(c,_)::l when a = c -> no_doub ((a,b)::l)
    | x::l -> x::(no_doub l)
    | l -> l;;

let compare (a,_) (c,_) = compare a c;;

let with_sig = no_doub (List.sort compare (List.map (fun h -> which h, h) finally));;

let finnnnal = List.map snd with_sig;;

let _ =
    let kikou = Scanf.scanf "%d %d %d %d" (fun a b c d -> (List.nth finnnnal 1) (a=1) (b=1) (c=1) (d=1)) in
        if kikou then print_int 1 else print_int 0

let rec pow x n =
    if n = 0 then 1 else x * pow x (n-1)

let olol n =
    2

let _ =
    let n = Scanf.scanf "%d" (fun n -> n) in
        print_int (olol n)


let read_int () = Scanf.bscanf Scanf.Scanning.stdib " %d " (fun x -> x)
let read_string () = Scanf.bscanf Scanf.Scanning.stdib " %s " (fun x -> x)

let () =
  let r1 = read_int() in
  let r2 = read_int() in
  let c1 = read_int() in
  let c2 = read_int() in
  let d1 = read_int() in
  let d2 = read_int() in

    for i1 = 1 to 9 do
      for i2 = 1 to 9 do
	for i3 = 1 to 9 do
	  for i4 = 1 to 9 do
	    if r1=i1+i2 && r2=i3+i4 && c1=i1+i3 && c2=i2+i4 && d1=i1+i4 && d2=i2+i3
	      && i1<>i2 && i1<>i3 && i1<>i4 && i2<>i3 && i2<>i4 && i3<>i4
	    then (
	      Printf.printf "%d %d\n%d %d\n" i1 i2 i3 i4;
	      exit 1
	    )
	  done
	done
      done
    done;

    Printf.printf "-1\n"

let r1, r2 = Scanf.scanf "%d %d\n" (fun x y -> (x,y));;
let c1, c2 = Scanf.scanf "%d %d\n" (fun x y -> (x,y));;
let d1, d2 = Scanf.scanf "%d %d\n" (fun x y -> (x,y));;

for p00 = 1 to 9 do begin
	let p01 = r1 - p00
	and p10 = c1 - p00
	and p11 = d1 - p00 in
	if (p00 <> p01) && (p00 <> p10) && (p00 <> p11) &&
		(p01 <> p10) && (p01 <> p11) && (p10 <> p11)
		&& (p10 + p11 = r2) && (p01 + p11 = c2) && (p10 + p01 = d2) then begin
		print_int p00; print_char ' '; print_int p01; print_string "\n";
		print_int p10; print_char ' '; print_int p11;
		exit 0;
	end
end done;;

print_int (0-1);;

let read_int () = Scanf.bscanf Scanf.Scanning.stdib " %d " (fun x -> x)
let read_string () = Scanf.bscanf Scanf.Scanning.stdib " %s " (fun x -> x)

let () =
  let r1 = read_int() in
  let r2 = read_int() in
  let c1 = read_int() in
  let c2 = read_int() in
  let d1 = read_int() in
  let d2 = read_int() in

    for i1 = 0 to 9 do
      for i2 = 0 to 9 do
	for i3 = 0 to 9 do
	  for i4 = 0 to 9 do
	    if r1=i1+i2 && r2=i3+i4 && c1=i1+i3 && c2=i2+i4 && d1=i1+i4 && d2=i2+i3
	      && i1<>i2 && i1<>i3 && i1<>i4 && i2<>i3 && i2<>i4 && i3<>i4
	    then (
	      Printf.printf "%d %d\n%d %d\n" i1 i2 i3 i4;
	      exit 1
	    )
	  done
	done
      done
    done;

    Printf.printf "-1\n"

let read_int () = Scanf.bscanf Scanf.Scanning.stdib " %d " (fun x -> x)
let read_string () = Scanf.bscanf Scanf.Scanning.stdib " %s " (fun x -> x)

let () =
  let r1 = read_int() in
  let r2 = read_int() in
  let c1 = read_int() in
  let c2 = read_int() in
  let d1 = read_int() in
  let d2 = read_int() in

    for i1 = 0 to 9 do
      for i2 = 0 to 9 do
	for i3 = 0 to 9 do
	  for i4 = 0 to 9 do
	    if r1=i1+i2 && r2=i3+i4 && c1=i1+i3 && c2=i2+i4 && d1=i1+i4 && d2=i2+i3 then (
	      Printf.printf "%d %d\n%d %d\n" i1 i2 i3 i4;
	      exit 1
	    )
	  done
	done
      done
    done;

    Printf.printf "-1\n"


(*#load "str.cma"*)
open Printf;;
let [a; b] = List.map (ref) (List.map (int_of_string) (Str.split (Str.regexp " ") (read_line ())));;
let ans = ref 0;;
while (!a <= !b) do
	a := !a * 3;
	b := !b * 2;
	ans := !ans + 1;
done;;
printf "%d\n" !ans;;

    let x, y = Scanf.scanf "%d %d" (fun x y -> float_of_int x, float_of_int y)

    let _ =
        print_int (int_of_float (ceil (log(y /. x) /. log(1.5) +. 0.00001)))

let input () = Scanf.scanf "%d %d" (fun a b -> (a, b))

let solve (a, b) =
    let rec loop i a_mass b_mass =
        if a_mass > b_mass
        then
            i
        else
            loop (i + 1) (a_mass * 3) (b_mass * 2)
    in loop 0 a b

let print result = Printf.printf "%d\n" result
let () = print (solve (input ()))

let main () =
  let gr () = Scanf.scanf " %d" (fun i -> i) in
  let a = gr () in
  let b = gr() in
  let rec f x y ans =
      let newx = 3 * x in
      let newy = 2 * y in
      if newx > newy then (ans + 1) else f newx newy (ans + 1)
  in
  Printf.printf "%d\n"  (f a b 0)
  ;;
let _ = main();;

let get_int () =
  Scanf.scanf " %d" (fun x -> x)
;;
let () =
  let x = get_int () in
  let y = get_int () in
  let rec f x y t =
    if x > y then t
    else f (3 * x) (2 * y) (t + 1) in
  Printf.printf "%d\n" (f x y 0)
;;

let wczytaj () =
    Scanf.scanf " %d" (fun x -> x)
;;

let rec kiedy a b cnt =
    let roznica = (a > b) in
        match roznica with
        | true -> cnt
        | false -> (kiedy (a*3) (b*2) (cnt+1))
;;

let main () =
    let a = (wczytaj ()) in
        let b = (wczytaj ()) in
            (kiedy a b 0)
;;

let _ = Printf.printf "%d" (main ())

let min_time a b =
    let rec helper a b acc =
        if a > b then
            acc
        else helper (3 * a) (2 * b) (acc + 1)
    in helper a b 0
in

let a = Scanf.scanf " %d" (fun x -> x) in
let b = Scanf.scanf " %d" (fun x -> x) in
Printf.printf "%d\n" (min_time a b);

open Printf
open Scanf

let read_pair _ = bscanf Scanning.stdib " %d %d " (fun x y -> (x,y))
let () =
  let (a,b) = read_pair () in

  let rec loop a b count = if a > b then count else loop (3*a) (2*b) (count+1) in

  printf "%d\n" (loop a b 0)

let x, y = Scanf.scanf "%d %d" (fun x y -> float_of_int x, float_of_int y)

let _ =
    print_int (int_of_float (ceil (log(y /. x) /. log(1.5))))


let read_string () = Scanf.bscanf Scanf.Scanning.stdib " %s " (fun x -> x)

let is_vowel c =
  List.mem c ['A'; 'E'; 'I'; 'O'; 'U'; 'Y']

let () =
  let s = read_string () in
  let len = String.length s in
  let rec loop i count max_sum =
    if i >= len then max (count + 1) max_sum
    else if is_vowel s.[i] then
      loop (i + 1) 0 (max (count + 1) max_sum)
    else loop (i + 1) (count + 1) max_sum
  in
  loop 0 0 0
  |> Printf.printf "%d"

let is_vowel c =
  List.mem c ['A'; 'E'; 'I'; 'O'; 'U'; 'Y']

let () =
  let s = read_line () in
  let rec loop ability jump i =
    if i = String.length s then
      max jump ability
    else if is_vowel s.[i] then
      loop (max jump ability) 1 (i + 1)
    else
      loop ability (jump + 1) (i + 1) in
  loop 1 1 0 |> string_of_int |> print_endline

let min_jump s =
  let len = String.length s in
  let rec jump i jumped m =
    if i = len then
      max m jumped
    else
      match s.[i] with
        'A' | 'E' | 'I' | 'O' | 'U' | 'Y' ->
        jump (i+1) 1 (max m jumped)
      | _ ->
        jump (i+1) (jumped+1) m
  in jump 0 1 0 ;;

let s = read_line ()
in Printf.printf "%d\n" (min_jump s) ;;

let input () = Scanf.scanf "%s\n" (fun s -> s)
let print result = Printf.printf "%d\n" result

let is_vovel char =
    match char with
        | 'A' | 'E' | 'I' | 'O' | 'U' | 'Y' -> true
        | _ -> false

let solve str =
    let l = String.length str in
    let rec loop i prev max =
        if i < l
        then
            let char = str.[i] in
            if is_vovel char
            then
                let hop = Pervasives.max (i - prev) max in
                loop (i + 1) i hop
            else
                loop (i + 1) prev max
        else
            Pervasives.max (l - prev) max
    in loop 0 (-1) 0

let () = print (solve (input ()))

let solve s =
    let n = String.length s in
    let rec solve last_pos i acc =
        if i <= n then
            if s.[i-1] = 'A' || s.[i-1] = 'E' || s.[i-1] = 'I' ||
                s.[i-1] = 'O' || s.[i-1] = 'U' || s.[i-1] = 'Y' then
                solve i (i+1) (max acc (i - last_pos))
            else
                solve last_pos (i+1) acc
        else
            max acc (i - last_pos)
    in
    solve 0 1 0
;;

let main () =
    let s = read_line () in
    let () = print_int (solve s) in
    print_string "\n"
;;

main ()

let read_string () = Scanf.bscanf Scanf.Scanning.stdib " %s " (fun x -> x)

let is_vowel c =
  List.mem c ['A'; 'E'; 'I'; 'O'; 'U'; 'Y']

let () =
  let s = read_string () in
  let len = String.length s in
  let rec loop i count max_sum =
    if i >= len then max count max_sum
    else if is_vowel s.[i] then
      loop (i + 1) 0 (max (count + 1) max_sum)
    else loop (i + 1) (count + 1) max_sum
  in
  loop 0 0 0
  |> Printf.printf "%d"

let read_string () = Scanf.bscanf Scanf.Scanning.stdib " %s " (fun x -> x)

let is_vowel c =
  List.mem c ['A'; 'E'; 'I'; 'O'; 'U'; 'Y']

let () =
  let s = read_string () in
  let len = String.length s in
  let rec loop i count max_sum =
    if i >= len then max_sum
    else if is_vowel s.[i] then
      loop (i + 1) 0 (max (count + 1) max_sum)
    else loop (i + 1) (count + 1) max_sum
  in
  loop 0 0 0
  |> Printf.printf "%d"

let is_vowel c =
  List.mem c ['A'; 'E'; 'I'; 'O'; 'U'; 'Y']

let () =
  let s = read_line () in
  let rec loop ability jump i =
    if i = String.length s then
      ability
    else if is_vowel s.[i] then
      loop (max jump ability) 1 (i + 1)
    else
      loop ability (jump + 1) (i + 1) in
  loop 1 1 0 |> string_of_int |> print_endline

let min_jump s =
  let len = String.length s in
  let rec jump i jumped m =
    if i = len then
      max m jumped
    else
      match s.[i] with
        'A' | 'E' | 'I' | 'O' | 'U' | 'Y' ->
        jump (i+1) 1 (max m jumped)
      | _ ->
        jump (i+1) (jumped+1) m
  in jump 0 0 0 ;;

let s = read_line ()
in Printf.printf "%d\n" (min_jump s) ;;


let lcm a b =
    let rec gcd a b = if b = Int32.zero then a else gcd b (Int32.rem a b)
    in (Int32.div (Int32.mul a b) (gcd a b)) in
let (x, y, a, b) = Scanf.scanf "%ld %ld %ld %ld\n" (fun x y a b -> (x, y, a, b)) in
let m = lcm x y in
(* determine number of m in interval [a,b] *)
let start = Int32.add a (Int32.rem (Int32.sub m (Int32.rem a m)) m)
and last  = Int32.sub b (Int32.rem b m) in
Printf.printf "%ld\n" (max (Int32.succ (Int32.div (Int32.sub last start) m))
Int32.zero) ;;

open Printf
open Scanf
open String
open List
open Int64

let rec gcd a b =
	if b = zero then a
	else gcd b (rem a b);;

let solve x y a b =
	let l = (div (mul x y) (gcd x y))
	in printf "%Ld" (sub (div b l) (div (pred a) l))
in scanf "%Ld %Ld %Ld %Ld" solve;;

let rec gcd a = function 0 -> a | b -> gcd b (a mod b) in
let lcm a b = (a * b) / (gcd a b) in
let (x, y, a, b) = Scanf.scanf "%d %d %d %d\n" (fun x y a b -> (x, y, a, b)) in
let m = lcm x y in
(* determine number of m in interval [a,b] *)
let start = a + (a mod m)
and last  = b - (b mod m) in
Printf.printf "%d\n" (max ((last - start) / m + 1) 0) ;;


let input () = Scanf.scanf "%s" (fun s -> s)

let solve input =
    if String.contains input 'H' || String.contains input 'Q' || String.contains input '9'
    then
        "YES"
    else
        "NO"

let print result = Printf.printf "%s\n" result

let () = print (solve (input ()))

let rec p str n = if (n=String.length str) then "NO"
                else match str.[n] with 'H' | 'Q' | '9' -> "YES" | _ -> p str (n+1)

let main () = ((print_string (p (read_line ()) 0)); print_newline ();
);;

if !Sys.interactive then () else main ();;

let flag = ref "NO";;

exception Found;;

let vote = function
  | 'H' -> raise Found
  | 'Q' -> raise Found
  | '9' -> raise Found
  | _ -> ()
;;

let s = Scanf.scanf "%s " (fun x ->  x)

try
  for i=0 to String.length s - 1 do
    vote (String.get s i)
  done
with Found -> flag := "YES";;

print_endline !flag;;

let solve p =
  if String.contains p 'H' || String.contains p 'Q' || String.contains p '9'
  then "YES"
  else "NO"

let _ =
  Printf.printf "%s\n" (Scanf.scanf "%s" solve)

let solve s len =
  let rec solve' i = match s.[i], i with
    | 'H', _ | 'Q', _ | '9', _ -> "YES"
    |   _, n when n = len -> "NO"
    |   _, n -> solve' (i + 1)
  in solve' 0

let () =
  let s = read_line () in
  Printf.printf "%s\n" (solve (s ^ " ") (String.length s))

let pf = Printf.printf;;
let sf = Scanf.scanf;;
let ssf = Scanf.sscanf;;

let (|>) x f = f x;;
let (@@) f x = f x;;

exception Error of string

let inf = 1000000000;;
let eps = 1e-11;;

let charlist_of_string s =
  let rec inner rv = function
      0 -> rv
    | m -> inner (s.[m-1]::rv) (m-1) in
  inner [] (String.length s)
;;

let l = ['H'; 'Q'; '9'];;

let _ =
  let s = read_line() in
  let func c = List.memq c @@ charlist_of_string s in
  print_endline (if List.exists func l then "YES" else "NO")
;;


let readInt64 () = Scanf.scanf " %Ld" (fun x -> x)

let tri k = Int64.(div (mul k (add k 1L)) 2L)

let isTri n =
    let rec lim k =
        if tri k <= n then lim (Int64.mul 2L k)
        else k
    in
    let rec go l r = Int64.(
        if sub r l <= 1L then tri l = n
        else
        let m = add l (div (sub r l) 2L) in
        if tri m <= n then go m r
        else go l m
    )
    in go 0L (lim 3L)

let isDoubleTri n =
    let rec go i sum = Int64.(
        if sum >= n then false
        else if isTri (sub n sum) then true
        else let ii = add i 1L in go ii (add sum ii)
    )
    in go 1L 1L

let () =
    let n = readInt64 () in
    Printf.printf (if isDoubleTri n then "YES\n" else "NO\n")

let rec gao n a b = match a, b with
  | [], _ | _, [] -> "NO"
  | (x::xs), (y::ys) ->
      if x + y = n then "YES"
      else if x + y > n then gao n a ys
      else gao n xs b
;;

let triangular n =
  if n mod 2 = 0
  then n / 2 * (n + 1)
  else (n + 1) / 2 * n
;;

let a = Array.init 45000 triangular in
let l = List.tl (Array.to_list a) in
let n = Scanf.scanf "%d" (fun x -> x) in
print_endline (gao n l (List.rev l));;

let readInt () = Scanf.scanf " %d" (fun x -> x)

let tri k = k * (k + 1) / 2

let isTri n =
    let rec go l r =
        if r - l <= 1 then tri l == n
        else
        let m = l + (r - l) / 2 in
        if tri m <= n then go m r
        else go l m
    in go 0 (int_of_float (sqrt (float_of_int (2 * n)) +. 1.))

let isDoubleTri n =
    let rec go i sum =
        if sum >= n then false
        else if isTri (n - sum) then true
        else go (i + 1) (sum + i + 1)
    in go 1 1

let () =
    let n = readInt () in
    Printf.printf (if isDoubleTri n then "YES\n" else "NO\n")

let readInt32 () = Scanf.scanf " %ld" (fun x -> x)

let tri k = Int32.(div (mul k (add k 1l)) 2l)

let isTri n =
    let rec lim k =
        if tri k <= n then lim Int32.(div (mul 14l k) 10l)
        else k
    in
    let rec go l r = Int32.(
        if sub r l <= 1l then tri l = n
        else
        let m = add l (div (sub r l) 2l) in
        if tri m <= n then go m r
        else go l m
    )
    in go 0l (lim 3l)

let isDoubleTri n =
    let rec go i sum = Int32.(
        if sum >= n then false
        else if isTri (sub n sum) then true
        else let ii = add i 1l in go ii (add sum ii)
    )
    in go 1l 1l

let () =
    let n = readInt32 () in
    Printf.printf (if isDoubleTri n then "YES\n" else "NO\n")

let readInt () = Scanf.scanf " %d" (fun x -> x)

let tri k = k * (k + 1) / 2

let isTri n =
    let rec go l r =
        if r - l <= 1 then tri l == n
        else
        let m = l + (r - l) / 2 in
        if tri m <= n then go m r
        else go l m
    in go 0 n

let isDoubleTri n =
    let rec go i sum =
        if sum >= n then false
        else if isTri (n - sum) then true
        else go (i + 1) (sum + i + 1)
    in go 1 1

let () =
    let n = readInt () in
    Printf.printf (if isDoubleTri n then "YES\n" else "NO\n")


open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64,min_i64 = Int64.(max_int,min_int)
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module I64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v))
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v)
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v)
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w)
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x)
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y)
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array

let factor n =
  let m,r = ref n,ref [] in
  rep 2L (n/2L) (fun i ->
    if !m mod i = 0L then (
      let k = ref 0L in
      while !m mod i = 0L do
        k += 1L; m /= i;
      done;
      r := (i,!k) :: !r));
  if !m>1L then (!m,1L)::!r else !r

let binary_search_opt ng ok f =
  let d = if ng < ok then 1L else -1L in
  let i = binary_search ng ok f in
  if i=ng-d || i=ok+d then None else Some i

let pow n k =
  let rec f a n = function
  | 0L -> a
  | 1L -> n*a
  | k when k mod 2L = 0L -> f a (n*n) (k/2L)
  | k -> f (a*n) n (k-1L)
  in f 1L n k

let () =
  let n = get_i64 0 in
  let ls = factor n in
  let ans,k_max = List.fold_left (fun (u,w) (v,x) -> (u*v,max w x)) (1L,0L) ls in
  let nibekies =
    let i = ref 1L in
    let r = ref [] in
    while !i <= 1000008L do
      r := !i :: !r;
      i *= 2L;
    done; !r |> List.rev |> of_list in
  let k_to = lower_bound nibekies k_max in
  if pow ans (pow 2L k_to) = n then printf "%Ld %Ld\n" ans k_to
  else printf "%Ld %Ld\n" ans (k_to + 1L)

open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64,min_i64 = Int64.(max_int,min_int)
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module I64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v))
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v)
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v)
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w)
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x)
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y)
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array
let sieve n = (* includes 0, O(nloglogn) *)
  let prime = Array.make (n+$1) true in
  prime.(0) <- false;
  prime.(1) <- false;
  for i=2 to n do
    if prime.(i) then let j = ref @@ i*$2 in
    while !j <= n do prime.(!j) <- false; j := !j +$ i; done
  done; prime
(* let pow n k = fix (fun f n k a ->
  if k=0L then a
  else if k=1L then n*a
  else if k mod 2L = 0L then f (n*n) (k/2L) a
  else f n (k-1L) (a*n)) n k 1L *)
let pow n k =
  let rec f a n = function
  | 0L -> a
  | 1L -> n*a
  | k when k mod 2L = 0L -> f a (n*n) (k/2L)
  | k -> f (a*n) n (k-1L)
  in f 1L n k
let () =
  let n = get_i64 0 in
  let pr = sieve (i32 n) in
  let i = ref 1L in
  let tp =
    let i = ref 1L in
    let r = ref [] in
    while !i <= 1000000L do
      r := !i :: !r;
      i *= 2L;
    done; !r |> List.rev |> of_list in
  (* print_array ist tp; *)
  let r = ref [] in
  while !i <= n do
    if n mod !i = 0L && pr.(i32 !i) then (
      r := !i :: !r;
    );
    i += 1L;
  done;
  (* print_list ist !r; *)
  let mx = ref 0L in
  let alltp = ref true in
  List.iter (fun p ->
    let m = ref n in
    let k = ref 0L in
    while !m>=1L && !m mod p = 0L do
      k += 1L;
      m := !m / p;
    done;
    let t = lower_bound tp !k |> i32 in
    if t<=0 || i64 t>alen tp || tp.(t) <> !k then alltp := false;
    (* printf "%Ld %Ld : %d ::: %b\n" p !k t !alltp; *)
    mx := max !mx !k
  ) !r;
  (* printf "%Ld\n" !mx; *)
  (* let mxv = tp.(i32 @@ upper_bound tp !mx) in *)
  let mxv = lower_bound tp !mx in
  let mxv = if mxv<=0L then (
    1L
  ) else mxv in
  (* printf "%Ld : %Ld\n" !mx mxv; *)
  let res = List.fold_left ( * ) 1L !r in
  if res = n then printf "%Ld 0" res
  else
  printf "%Ld %Ld\n" res
    (* (mxv + if !alltp then 0L else 1L) *)
    (mxv + if pow res @@ pow 2L mxv = n then 0L else 1L)

open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64,min_i64 = Int64.(max_int,min_int)
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module I64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v))
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v)
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v)
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w)
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x)
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y)
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array

let factor n =
  let m,r = ref n,ref [] in
  rep 2L (n/2L) (fun i ->
    if !m mod i = 0L then (
      let k = ref 0L in
      while !m mod i = 0L do
        k += 1L; m /= i;
      done;
      r := (i,!k) :: !r));
  if !m>1L then (!m,1L)::!r else !r

let binary_search_opt ng ok f =
  let d = if ng < ok then 1L else -1L in
  let i = binary_search ng ok f in
  if i=ng-d || i=ok+d then None else Some i

let pow n k =
  let rec f a n = function
  | 0L -> a
  | 1L -> n*a
  | k when k mod 2L = 0L -> f a (n*n) (k/2L)
  | k -> f (a*n) n (k-1L)
  in f 1L n k

let () =
  let n = get_i64 0 in
  let ls = factor n in
  let ans,k_max = List.fold_left (fun (u,w) (v,x) -> (u*v,max w x)) (1L,0L) ls in
  let nibekies =
    let i = ref 1L in
    let r = ref [] in
    while !i <= 1000008L do
      r := !i :: !r;
      i *= 2L;
    done; !r |> List.rev |> of_list in
  let k_to = lower_bound nibekies k_max in
  if pow ans (nibekies.(i32 k_to)) = n then printf "%Ld %Ld\n" ans k_to
  else printf "%Ld %Ld\n" ans (k_to + 1L)

open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64,min_i64 = Int64.(max_int,min_int)
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module I64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v))
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v)
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v)
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w)
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x)
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y)
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array
let sieve n = (* includes 0, O(nloglogn) *)
  let prime = Array.make (n+$1) true in
  prime.(0) <- false;
  prime.(1) <- false;
  for i=2 to n do
    if prime.(i) then let j = ref @@ i*$2 in
    while !j <= n do prime.(!j) <- false; j := !j +$ i; done
  done; prime
let () =
  let n = get_i64 0 in
  let pr = sieve (i32 n) in
  let i = ref 1L in
  let tp =
    let i = ref 1L in
    let r = ref [] in
    while !i <= 1000000L do
      r := !i :: !r;
      i *= 2L;
    done; !r |> List.rev |> of_list in
  (* print_array ist tp; *)
  let r = ref [] in
  while !i <= n / 2L do
    if n mod !i = 0L && pr.(i32 !i) then (
      r := !i :: !r;
    );
    i += 1L;
  done;
  (* print_list ist !r; *)
  let mx = ref 0L in
  let alltp = ref true in
  List.iter (fun p ->
    let m = ref n in
    let k = ref 0L in
    while !m>=1L && !m mod p = 0L do
      k += 1L;
      m := !m / p;
    done;
    let t = lower_bound tp !k |> i32 in
    if t<=0 || i64 t>alen tp || tp.(t) <> !k then alltp := false;
    (* printf "%Ld %Ld : %d\n" p !k t; *)
    mx := max !mx !k
  ) !r;
  (* printf "%Ld\n" !mx; *)
  (* let mxv = tp.(i32 @@ upper_bound tp !mx) in *)
  let mxv = lower_bound tp !mx in
  (* printf "%Ld : %Ld\n" !mx mxv; *)
  printf "%Ld %Ld\n" (List.fold_left ( * ) 1L !r)
    (mxv + if !alltp then 0L else 1L)

open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64,min_i64 = Int64.(max_int,min_int)
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module I64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v))
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v)
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v)
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w)
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x)
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y)
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array
let sieve n = (* includes 0, O(nloglogn) *)
  let prime = Array.make (n+$1) true in
  prime.(0) <- false;
  prime.(1) <- false;
  for i=2 to n do
    if prime.(i) then let j = ref @@ i*$2 in
    while !j <= n do prime.(!j) <- false; j := !j +$ i; done
  done; prime
let () =
  let n = get_i64 0 in
  let pr = sieve (i32 n) in
  let i = ref 1L in
  let tp =
    let i = ref 1L in
    let r = ref [] in
    while !i <= 1000000L do
      r := !i :: !r;
      i *= 2L;
    done; !r |> List.rev |> of_list in
  (* print_array ist tp; *)
  let r = ref [] in
  while !i <= n do
    if n mod !i = 0L && pr.(i32 !i) then (
      r := !i :: !r;
    );
    i += 1L;
  done;
  (* print_list ist !r; *)
  let mx = ref 0L in
  let alltp = ref true in
  List.iter (fun p ->
    let m = ref n in
    let k = ref 0L in
    while !m>=1L && !m mod p = 0L do
      k += 1L;
      m := !m / p;
    done;
    let t = lower_bound tp !k |> i32 in
    if t<=0 || i64 t>alen tp || tp.(t) <> !k then alltp := false;
    (* printf "%Ld %Ld : %d\n" p !k t; *)
    mx := max !mx !k
  ) !r;
  (* printf "%Ld\n" !mx; *)
  (* let mxv = tp.(i32 @@ upper_bound tp !mx) in *)
  let mxv = lower_bound tp !mx in
  let mxv = if mxv<=0L then (
    1L
  ) else mxv in
  (* printf "%Ld : %Ld\n" !mx mxv; *)
  let res = List.fold_left ( * ) 1L !r in
  if res = n then printf "%Ld 0" res
  else
  printf "%Ld %Ld\n" res
    (mxv + if !alltp then 0L else 1L)

open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64,min_i64 = Int64.(max_int,min_int)
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module I64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v))
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v)
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v)
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w)
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x)
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y)
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array
let sieve n = (* includes 0, O(nloglogn) *)
  let prime = Array.make (n+$1) true in
  prime.(0) <- false;
  prime.(1) <- false;
  for i=2 to n do
    if prime.(i) then let j = ref @@ i*$2 in
    while !j <= n do prime.(!j) <- false; j := !j +$ i; done
  done; prime
(* let pow n k = fix (fun f n k a ->
  if k=0L then a
  else if k=1L then n*a
  else if k mod 2L = 0L then f (n*n) (k/2L) a
  else f n (k-1L) (a*n)) n k 1L *)
let pow n k =
  let rec f a n = function
  | 0L -> a
  | 1L -> n*a
  | k when k mod 2L = 0L -> f a (n*n) (k/2L)
  | k -> f (a*n) n (k-1L)
  in f 1L n k
let () =
  let n = get_i64 0 in
  let pr = sieve (i32 n) in
  let i = ref 1L in
  let tp =
    let i = ref 1L in
    let r = ref [] in
    while !i <= 1000000L do
      r := !i :: !r;
      i *= 2L;
    done; !r |> List.rev |> of_list in
  (* print_array ist tp; *)
  let r = ref [] in
  while !i <= n do
    if n mod !i = 0L && pr.(i32 !i) then (
      r := !i :: !r;
    );
    i += 1L;
  done;
  (* print_list ist !r; *)
  let mx = ref 0L in
  let alltp = ref true in
  List.iter (fun p ->
    let m = ref n in
    let k = ref 0L in
    while !m>=1L && !m mod p = 0L do
      k += 1L;
      m := !m / p;
    done;
    let t = lower_bound tp !k |> i32 in
    if t<=0 || i64 t>alen tp || tp.(t) <> !k then alltp := false;
    (* printf "%Ld %Ld : %d ::: %b\n" p !k t !alltp; *)
    mx := max !mx !k
  ) !r;
  (* printf "%Ld\n" !mx; *)
  (* let mxv = tp.(i32 @@ upper_bound tp !mx) in *)
  let mxv = lower_bound tp !mx in
  let mxv = if mxv<=0L then (
    1L
  ) else mxv in
  (* printf "%Ld : %Ld\n" !mx mxv; *)
  let res = List.fold_left ( * ) 1L !r in
  if res = n then printf "%Ld 0" res
  else
  printf "%Ld %Ld\n" res
    (* (mxv + if !alltp then 0L else 1L) *)
    (mxv + if pow res mxv = n then 0L else 1L)


let is_prime n =
  if n = 2 then true
  else if n < 2 || n mod 2 = 0 then false
  else
    let rec loop k =
      if k * k > n then true
      else if n mod k = 0 then false
      else loop (k+2)
    in loop 3
;;

print_string (Scanf.scanf "%d %d" (fun n k ->
	let m = ref 0 in
	let i = ref 3 in
	let last = ref 2 in
	let _ = while (!i) <= n-(!last)-1 do
		if is_prime(!i) then begin
			if !i+ !last+ 1 <= n && is_prime(!i+ !last+ 1)
			then (incr m);
			last := (!i)
		end;
		i := (!i) + 2;
	done in
	if (!m) < k then "NO" else "YES"
));;

let read_int _ = Scanf.bscanf Scanf.Scanning.stdib " %d" (fun x -> x)

let () =
  let b = Array.make 1000 true in
  for i = 2 to 1000-1 do
    if b.(i) then
      let rec go j =
        if j < 1000 then (
          b.(j) <- false;
          go (j+i)
        )
      in
      go (i*i)
  done;
  let n = read_int 0 in
  let k = read_int 0 in
  let rec go acc last i =
    if i >= 504 then
      acc
    else if not b.(i) then
      go acc last (i+1)
    else if last > 0 && last+i+1 <= n && b.(last+i+1) then
      go (acc+1) i (i+1)
    else
      go acc i (i+1)
  in
  print_endline (if go 0 0 2 >= k then "YES" else "NO")

let is_prime n =
  if n = 2 then true
  else if n < 2 || n mod 2 = 0 then false
  else
    let rec loop k =
      if k * k > n then true
      else if n mod k = 0 then false
      else loop (k+2)
    in loop 3
;;

print_string (Scanf.scanf "%d %d" (fun n k ->
	let m = ref 0 in
	let i = ref 3 in
	let last = ref 2 in
	let _ = while (!i) <= n/2+2 do
		if is_prime(!i) then begin
			if !i+ !last+ 1 <= n && is_prime(!i+ !last+ 1)
			then (incr m);
			last := (!i)
		end;
		i := (!i) + 2;
	done in
	if (!m) < k then "NO" else "YES"
));;

let is_prime n =
  if n = 2 then true
  else if n < 2 || n mod 2 = 0 then false
  else
    let rec loop k =
      if k * k > n then true
      else if n mod k = 0 then false
      else loop (k+2)
    in loop 3
;;

print_string (Scanf.scanf "%d %d" (fun n k ->
	let m = ref 0 in
	let i = ref 3 in
	let last = ref 2 in
	let _ = while (!i) <= n/2 do
		if is_prime(!i) then begin
			if (!i)+(!last)+1 < n && is_prime((!i)+(!last)+1)
			then incr m;
			last := (!i)
		end;
		i := (!i) + 2;
	done in
	if (!m) < k then "NO" else "YES"
));;

let is_prime n =
  if n = 2 then true
  else if n < 2 || n mod 2 = 0 then false
  else
    let rec loop k =
      if k * k > n then true
      else if n mod k = 0 then false
      else loop (k+2)
    in loop 3
;;

print_string (Scanf.scanf "%d %d" (fun n k ->
	let m = ref 0 in
	let i = ref 3 in
	let last = ref 2 in
	let _ = while (!i) < n/2 do
		if is_prime(!i) then begin
			if (!i)+(!last)+1 < n && is_prime((!i)+(!last)+1)
			then incr m;
			last := (!i)
		end;
		i := (!i) + 2;
	done in
	if (!m) < k then "NO" else "YES"
));;

let is_prime n =
  if n = 2 then true
  else if n < 2 || n mod 2 = 0 then false
  else
    let rec loop k =
      if k * k > n then true
      else if n mod k = 0 then false
      else loop (k+2)
    in loop 3
;;

print_string (Scanf.scanf "%d %d" (fun n k ->
	let m = ref 0 in
	let i = ref 3 in
	let last = ref 2 in
	let _ = while (!i) <= n/2+1 do
		if is_prime(!i) then begin
			if !i+ !last+ 1 <= n && is_prime(!i+ !last+ 1)
			then (incr m);
			last := (!i)
		end;
		i := (!i) + 2;
	done in
	if (!m) < k then "NO" else "YES"
));;


let nombre = ref (read_int ()) and nb_avant = ref 0 and puissance = ref 1;;
while !nombre > 0 do
	if !nombre mod 10 = 7 then nb_avant := !nb_avant + !puissance;
	puissance := !puissance * 2;
	nombre := !nombre / 10
done;;
print_int (!nb_avant + !puissance - 1);;
print_newline ();;

let rec puiss = function
	|0	-> 1
	|n	-> let demi = puiss (n/2) in
			(1 + n mod 2) * demi * demi

let f = function '4' -> 1 | '7' -> 2

let rec place mot long n =
	if n = long
		then 0
		else (f (mot.[n]))*(puiss (long-n-1)) + place mot long (n+1)

let final n =
	let mot = string_of_int n in
	place mot (String.length mot) 0

let () =
	let n = Scanf.scanf "%d" (fun i -> i) in
		Printf.printf "%d" (final n)