object Main2 extends App {

  import java.io._
  import java.util.{StringTokenizer}

  val in = new Reader()
  val out: PrintWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)))

  val n = in.nextInt
  var s = in.next
  (2 to n) filter(n % _ == 0) foreach { d =>
    s = s.substring(0, d).reverse + s.substring(d, n)
  }
  out.print(s)
  out.flush()
  out.close()

  class Reader @throws[IOException]
  () {
    var br: BufferedReader = new BufferedReader(new InputStreamReader(System.in))
    var tok: StringTokenizer = null

    def this(file: String) {
      this()
      br = new BufferedReader(new FileReader(file))
    }

    def next: String = {
      while (tok == null || !tok.hasMoreElements) tok = new StringTokenizer(br.readLine)
      tok.nextToken
    }

    def nextInt: Int = next.toInt

    def nextLong: Long = next.toLong

    def nextDouble: Double = next.toDouble

    def nextLine: String = br.readLine
  }

}

object CF_490_3_B {

  type In  = (Int, String)
  type Out = String

  def solve(in: In): Out = {
    val (n, s) = in

    var ms = s
    for {
      i <- 1 to n
      if n % i == 0
    } {
      val (a, b) = ms.splitAt(i)
      ms = a.reverse + b
    }

    ms
  }

//   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//   Specify Input and Output formats on RHS here:

  def formatIn(i: Input): In       = (i.int, {i.nextLine; i.nextLine})
  def formatOut(out: Out): String  = out.toString

//   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//   Boilerplate & utility methods that don't change (so ignore):

  import java.util.Scanner
  import java.io.InputStream
  import language.implicitConversions

  def main(args: Array[String]): Unit = {
    val out = new java.io.PrintWriter(System.out)
    val resultStr = new Input(System.in).solveStr
    out.println(resultStr)
    out.close()
  }

  class Input(val sc: Scanner) {
    // This class is useful for convenience, and for mock stdin in test scripts
    // Remember to call nextLine to advance past the newline character (if required) before taking a whole line
    def this(i: InputStream)       = this(new Scanner(i))
    def this(s: String)            = this(new Scanner(s.stripMargin))
    def int                        = sc.nextInt()
    def long                       = sc.nextLong()
    def double                     = sc.nextDouble()
    def nextLine                   = sc.nextLine()
    def collect[T](f: String => T) = sc.nextLine().split(" ").toVector.map(f)
    def intSeq                     = collect(_.toInt)
    def doubleSeq                  = collect(_.toDouble)
    def getLines: Vector[String]   = if (!sc.hasNextLine) Vector.empty
                                     else sc.nextLine +: getLines
    def getLines(lineCount: Int)   = {nextLine; (1 to lineCount).map(_ => sc.nextLine)}
    def solveVal: Out              = (solve _).tupled(formatIn(this))
    def solveStr: String           = formatOut(solveVal)
  }

  // Ceiling division for Int & Long
  // `a` MUST be > 0. Incorrect otherwise.
  def divideCeil(a: Int, b: Int)   = (a - 1)/b + 1
  def divideCeil(a: Long, b: Long) = (a - 1)/b + 1

  // A frequently used number in these comps
  val modulo = 1000000007

  // For convenience in test scripts, treat a String as an Input
  implicit def stringToInput(s: String): Input = new Input(s)
  // Required to make `solveVal` work when input has just 1 value (i.e. not a Tuple)
  implicit class makeTupledWorkOnFunction1[-T,+R](f: T => R) {
    def tupled: T => R = x => f(x)
  }
}

object B999 {

  import IO._
  import collection.{mutable => cu}

  def main(args: Array[String]): Unit = {
    val Array(n) = readInts(1)
    var str = read
    for(fact <- 1 to n) {
      if(n % fact == 0) {
        str = (str.take(fact).reverse) ++ str.drop(fact)
      }
    }
    out.println(str)

    out.close()
  }

  object IO {
    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))
    //    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream("src/input")))
    val out = new java.io.PrintWriter(System.out)

    @inline def read: String = input.readLine()

    @inline def tokenizeLine = new java.util.StringTokenizer(read)

    def readInt: Int = tokenizeLine.nextToken.toInt

    def readInts(n: Int): Array[Int] = {
      val tl = tokenizeLine
      Array.fill(n)(tl.nextToken.toInt)
    }

    def readLongs(n: Int): Array[Long] = {
      val tl = tokenizeLine
      Array.fill(n)(tl.nextToken.toLong)
    }

    def readBigs(n: Int): Array[BigInt] = {
      val tl = tokenizeLine
      Array.fill(n)(BigInt(tl.nextToken))
    }
  }

}

import scala.io.StdIn

object ReversingEncryption {
  def decrypt(length: Int, line: String): String = {
    var newString = line
    for (i <- 1 to length) {
      if (length % i == 0) {
        newString = newString.replaceFirst(newString.substring(0, i), newString.substring(0, i).reverse)
      }
    }
    newString
  }

  def main(args: Array[String]): Unit = {
    val length = StdIn.readInt()
    var line = StdIn.readLine()
    println(decrypt(length, line))
  }
}

import scala.io.StdIn._
import scala.annotation.tailrec

object ProblemB {
  def readLineToList = readLine.split(" ").map(_.toInt).toList

  def main(args: Array[String]): Unit = {
      val max = readLine.toInt
      val encryptedStr = readLine
      val divisors = (1 to max).filter(max % _ == 0)

      val result = divisors.foldLeft(encryptedStr)((a,b) => {
        a.substring(0, b).reverse + a.splitAt(b)._2
      })
      println(result)
  }
}

import scala.io.StdIn

object ReverseEncryption {
  def main(args: Array[String]): Unit = {
    StdIn.readLine()
    val string = StdIn.readLine()
    println(solve(string))
  }

  def solve(input: String) = {
    var result = input
    divisor(input.length).foreach(n => result = flip(result, n))
    result
  }

  private def divisor(n: Int): Seq[Int] = {
    for {
       i <- 2 to n
       if n % i == 0
    }
    yield i
  }

  private def flip(input: String, n: Int): String = {
    input.substring(0, n).reverse + input.substring(n)
  }
}

import math._
object Main extends App {
  val n = readInt
  val s = readLine
  val d = (1 to sqrt(n).toInt).filter(n % _ == 0)
  val all_d = (d ++ d.map(n / _).reverse).distinct
  val b = StringBuilder.newBuilder
  b.append(s)
  all_d.foreach(i => b.replace(0, i, b.substring(0, i).reverse))
  println(b)
}

import math._
object Main extends App {
  val n = readInt
  val s = readLine
  val d = (1 to sqrt(n).toInt).filter(n % _ == 0)
  val all_d = d ++ d.map(n / _).reverse
  val b = StringBuilder.newBuilder
  b.append(s)
  all_d.foreach(i => b.replace(0, i, b.substring(0, i).reverse))
  println(b)
}


import java.util.Scanner
import java.io.PrintWriter
import java.util.Arrays.binarySearch
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.collection.mutable.ArrayBuffer
import scala.util.Random
import scala.util.control.Breaks._

object P108A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  val List(hh, mm): List[String] = sc.nextLine.split(":").toList

  def nextPalindromicTime(n: Int): String = {
    val h = (n + 1) % 24
    val m = f"$h%02d".reverse.toInt
    if (m < 60) f"$h%02d:$m%02d"
    else nextPalindromicTime(h)
  }

  val res = {
    val rh = hh.reverse.toInt
    if (rh < 60 && rh > mm.toInt) hh + ":" + hh.reverse
    else nextPalindromicTime(hh.toInt)
  }

  out.println(res)
  out.close
}

object P108A extends App {

  val Array(hh,mm) = readLine.split(":").map(_.toInt)

  def inc(t:(Int,Int)) = ((t._1 + (if (t._2==59) 1 else 0)) % 24,(t._2+1) % 60)
  def f(s:Int) = "%02d".format(s)
  def isPal(t:Int,s:Int) = (f(t) == f(s).reverse)

  var time = (hh,mm)
  do time = inc(time) while(!isPal(time._1,time._2))
  print(f(time._1) + ":" + f(time._2))

}

object P108A extends App {
  val Array(h,m)=readLine.split(":").map(_.toInt)
  def i(t:(Int,Int))=((t._1+(if(t._2==59)1 else 0))%24,(t._2+1)%60)
  def f(s:Int)="%02d".format(s)
  var t = (h,m)
  do t = i(t) while(f(t._1) != f(t._2).reverse)
  print(f(t._1) + ":" + f(t._2))
}

import scala.io.Source

object Solution extends App {
  def pol(time: Int) = {
    val minutes = time % 60
    val hours = time / 60 % 24
    minutes % 10 == hours / 10 && minutes / 10 == hours % 10
  }

  val in = Source.stdin.getLines()
  val Array(hh, mm) = in.next().split(":").map(_.toInt)
  var time = hh * 60 + mm + 1
  while (!pol(time)) time += 1
  val minutes = time % 60
  val hours = time / 60 % 24
  println(f"$hours%02d:$minutes%02d")
}

object A108 {

  import IO._
  import collection.{mutable => cu}

  def main(args: Array[String]): Unit = {
    val in = {
      val str = read
      Array(str.take(2).toInt, str.takeRight(2).toInt)
    }
    var break = false
    while(!break) {
      if(in(0) == 23 && in(1) == 59) {
        in(0) = 0
        in(1) = 0
      } else if(in(1) == 59){
        in(0) += 1
        in(1) = 0
      } else {
        in(1) += 1
      }
      val str = "%02d".format(in(0)) + ":" + "%02d".format(in(1))
      if(str == str.reverse) {
        println(str)
        break = true
      }
    }
  }

  object IO {
    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))

    @inline def read: String = input.readLine()

    @inline def tokenizeLine = new java.util.StringTokenizer(read)

    def readInt: Int = tokenizeLine.nextToken.toInt

    def readInts(n: Int): Array[Int] = {
      val tl = tokenizeLine
      Array.fill(n)(tl.nextToken.toInt)
    }

    def readLongs(n: Int): Array[Long] = {
      val tl = tokenizeLine
      Array.fill(n)(tl.nextToken.toLong)
    }

    def readBigs(n: Int): Array[BigInt] = {
      val tl = tokenizeLine
      Array.fill(n)(BigInt(tl.nextToken))
    }
  }

}

object Main {
  def main(args: Array[String]) {
    val Array(hh, mm) = readLine().split(":")
    val h1 =
      if (hh.reverse.toInt <= mm.toInt) hh.toInt + 1
      else hh.toInt
    val h2 = h1 match {
      case 24 => "00"
      case i if i < 6 => "0" + i
      case i if i >= 6 && i <= 9 => "10"
      case i if i >= 16 && i <= 19 => "20"
      case i => i.toString
    }
    println(h2 + ":" + h2.reverse)
  }
}

object P108A extends App {

  val Array(hh,mm) = readLine.split(":").map(_.toInt)

  def inc(t:(Int,Int)) = ((t._1 + (if (t._2==59) 1 else 0)) % 24,(t._2+1) % 60)
  def isPal(t:(Int,Int)) = (t._1 == t._2.toString.reverse.toInt)

  var time = (hh,mm)
  do time = inc(time) while(!isPal(time))
  printf("%02d:%02d", time._1, time._2)

}

object P108A extends App {
  val Array(h,m)=readLine.split(":").map(_.toInt)
  def i(t:(Int,Int))=((t._1+(if(t._2==59)1 else 0))%24,(t._2+1)%60)
  def f(s:Int)="%02d".format(s)
  var t = (h,m)
  do t = i(t) while(f(t._1) != f(t._2))
  print(f(t._1) + ":" + f(t._2))
}

import java.util.Scanner
import java.io.PrintWriter
import java.util.Arrays.binarySearch
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.collection.mutable.ArrayBuffer
import scala.util.Random
import scala.util.control.Breaks._

object P108A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  val List(h, m) = sc.nextLine.split(":").toList

  val res = if (h.reverse.toInt > m.toInt) out.println(h + ":" + h.reverse)
            else nextPalindromicTIme(h.toInt)

  def nextPalindromicTIme(x: Int): String = {
    val y = (x + 1) % 24
    val z = f"$y%02d".reverse.toInt
    if (z < 60) f"$y%02d:$z%02d"
    else (nextPalindromicTIme(x + 1))
  }

  out.println(res)
  out.close
}

import java.util.Scanner
import java.io.PrintWriter
import java.util.Arrays.binarySearch
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.collection.mutable.ArrayBuffer
import scala.util.Random
import scala.util.control.Breaks._

object P108A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  val List(h, m) = sc.nextLine.split(":").toList

  if (h.reverse.toInt >= m.toInt) out.println(h + ":" + h.reverse)
  else nextPalindromicTIme(h.toInt)

  def nextPalindromicTIme(x: Int): String = {
    val y = (x + 1) % 24
    val z = f"$y%02d".reverse.toInt
    if (z < 60) f"$y%02d:$z%02d"
    else (nextPalindromicTIme(x + 1))
  }

 out.close
}

import java.util.Scanner
import java.io.PrintWriter
import java.util.Arrays.binarySearch
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.collection.mutable.ArrayBuffer
import scala.util.Random
import scala.util.control.Breaks._

object P108A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  val List(h, m) = sc.nextLine.split(":").toList

  if (h.reverse.toInt > m.toInt) out.println(h + ":" + h.reverse)
  else nextPalindromicTIme(h.toInt)

  def nextPalindromicTIme(x: Int): String = {
    val y = (x + 1) % 24
    val z = f"$y%02d".reverse.toInt
    if (z < 60) f"$y%02d:$z%02d"
    else (nextPalindromicTIme(x + 1))
  }

 out.close
}

import java.util.Scanner
import java.io.PrintWriter
import java.util.Arrays.binarySearch
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.collection.mutable.ArrayBuffer
import scala.util.Random
import scala.util.control.Breaks._

object P108A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  val List(h, m) = sc.nextLine.split(":").toList

  val res = if (h.reverse.toInt > m.toInt) h + ":" + h.reverse
            else nextPalindromicTIme(h.toInt)

  def nextPalindromicTIme(x: Int): String = {
    val y = (x + 1) % 24
    val z = f"$y%02d".reverse.toInt
    if (z < 60) f"$y%02d:$z%02d"
    else nextPalindromicTIme(x + 1)
  }

  out.println(res)
  out.close
}

import java.util.Scanner
import java.io.PrintWriter
import java.util.Arrays.binarySearch
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.collection.mutable.ArrayBuffer
import scala.util.Random
import scala.util.control.Breaks._

object P108A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  val n = sc.nextLine.split(":")(0).toInt

  def nextPalindromicTIme(x: Int): String = {
    val y = (x + 1) % 24
    val z = f"$y%02d".reverse.toInt
    if (z < 60) f"$y%02d:$z%02d"
    else (nextPalindromicTIme(x + 1))
  }

  out.println(nextPalindromicTIme(n))
  out.close
}


object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val n = in.next().toInt
  println(s"$n 0 0")
}

import java.util.Scanner

object Main {

	def main(args: Array[String]): Unit = {
		val scanner = new Scanner (System.in)
		val n = scanner nextInt ()
		print ("0 0 ")
		println (n)
	}

}

object A199 {

  import IO._
  import collection.{mutable => cu}
  def main(args: Array[String]): Unit = {
    val Array(n) = readLongs(1)
    println(s"0 0 $n")
  }

  object IO {
    @inline def read: String = scala.io.StdIn.readLine

    @inline def tokenizeLine = new java.util.StringTokenizer(read)

    def readInts(n: Int): Array[Int] = {
      val tl = tokenizeLine;
      Array.fill(n)(tl.nextToken.toInt)
    }

    def readLongs(n: Int): Array[Long] = {
      val tl = tokenizeLine;
      Array.fill(n)(tl.nextToken.toLong)
    }

    def readBigs(n: Int): Array[BigInt] = {
      val tl = tokenizeLine;
      Array.fill(n)(BigInt(tl.nextToken))
    }
  }

}

import java.util.Scanner
import java.io.PrintWriter
import scala.annotation.tailrec
import scala.collection.mutable
import scala.util.Random

object P199A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  val N = sc.nextInt

  def solve(): List[Int] = {

    @tailrec
    def loop(a: Int, b: Int, c: Int, d: Int, x: Int): List[Int] = {
      if (x == N) List(a, b, d)
      else loop(b, c, d, x, d + x)
    }

    N match {
      case 0 => List(0, 0, 0)
      case 1 => List(0, 0, 1)
      case 2 => List(0, 1, 1)
      case _ => loop(0, 1, 1, 2, 3)
    }
  }

  out.println(solve.mkString(" "))
  out.close
}

import java.util

import scala.annotation.tailrec

/**
 * @author pvasilyev
 * @since 16 Jun 2016
 */
object A199 extends App {

  @tailrec
  // fibs[from] <= f
  def binarySearch(fibs: util.ArrayList[Int], f: Int, from: Int, to: Int): Int = {
    if (to - from < 2) {
      from
    } else {
      val mid: Int = (from + to) / 2
      if (fibs.get(mid) <= f) {
        binarySearch(fibs, f, mid, to)
      } else {
        binarySearch(fibs, f, from, mid)
      }
    }
  }

  def solve() = {
    val f: Int = scala.io.StdIn.readInt()
    if (f == 0) {
      println("0 0 0")
    } else if (f == 1) {
      println("0 0 1")
    } else {
      val fibs = new util.ArrayList[Int]()
      fibs.add(0)
      fibs.add(1)
      var k = 2
      while (fibs.get(k - 1) + fibs.get(k - 2) < 1000000000) {
        fibs.add(fibs.get(k - 1) + fibs.get(k - 2))
        k += 1
      }
      val i: Int = binarySearch(fibs, f, 0, fibs.size())
      println("0 " + fibs.get(i-2) + " " + fibs.get(i-1))
    }
  }

  solve()

}

import java.io._
import java.util.Locale
import scala.annotation.tailrec

object Easy {
  val reader = new BufferedReader(new InputStreamReader(System.in))
  def readInt = reader.readLine().toInt
  def readInts = reader.readLine().split(" ").map(_.toInt)
  def readLongs = reader.readLine().split(" ").map(_.toLong)
  def readLine = reader.readLine

  def ans = Array(0, 0, readInt).mkString(" ")

  def main(a: Array[String]) {
    println(ans)
  }
}

object Main {
  val fib: Stream[Int] = {
    def fibf(a: Int, b: Int): Stream[Int] = {
      a #:: fibf(b, a + b)
    }
    fibf(0, 1)
  }

  def main(args: Array[String]) = {
    val n = readLine()
    val i = fib.takeWhile(_ < 1000000000).indexOf(n)
    if (i <= 3) println("0 0 " + n)
    else println(fib(i - 4) + " " + fib(i - 3) + " " + fib(i - 1))
  }
}

object Solution extends App{

    val in = scala.io.Source.stdin.getLines()
    val n = in.next().toInt
    println(s"$n 0 0")
}

object A199 {

  import IO._
  import collection.{mutable => cu}
  def generateFib(till: Long): Array[Long] = {
    var num1 = 1L
    var num2 = 2L
    var res = Array(1L, 2L)
    while(num2 <= till) {
      val temp = num1 + num2
      num1 = num2
      num2 = temp
      res ++= Array(num2)
    }
    res
  }
  def main(args: Array[String]): Unit = {
    val Array(n) = readLongs(1)
    val fibs = generateFib(1000000000L)
    var break = false
    for(i <- fibs; j <- fibs; k <- fibs if !break) {
      if(i+j+k == n) {
        println(s"$i $j $k")
        break = true
      }
    }
    if(!break)
      println("I'm too stupid to solve this problem")
  }

  object IO {
    @inline def read: String = scala.io.StdIn.readLine

    @inline def tokenizeLine = new java.util.StringTokenizer(read)

    def readInts(n: Int): Array[Int] = {
      val tl = tokenizeLine;
      Array.fill(n)(tl.nextToken.toInt)
    }

    def readLongs(n: Int): Array[Long] = {
      val tl = tokenizeLine;
      Array.fill(n)(tl.nextToken.toLong)
    }

    def readBigs(n: Int): Array[BigInt] = {
      val tl = tokenizeLine;
      Array.fill(n)(BigInt(tl.nextToken))
    }
  }

}


object Main extends App with fastIO{
  val s = readLine
  val st = "CODEFORCES"
  var bo = false
  //if(s.contains(st)) bo = true
  for(a <- 0 until s.length; b <- a to s.length){
    if(s.substring(0,a)++s.substring(b,s.length)==st) bo = true
  }
  println(if(bo)"YES" else "NO")
  flush
}

trait fastIO {
  import java.io._
  val isFile = false
  val input = "file.in"
  val output = "file.out"
  val bf = new BufferedReader(if(isFile) new FileReader(input) else new InputStreamReader(System.in))
  val in = new StreamTokenizer(bf)
  val out = new PrintWriter(if(isFile)new FileWriter(output) else new OutputStreamWriter(System.out))

  def next: String = {
    in.ordinaryChars('0', '9')
    in.wordChars('0', '9')
    in.nextToken()
    in.sval
  }
  def nextInt: Int = {
    in.nextToken()
    in.nval.toInt
  }
  def nextLong:Long ={
    in.nextToken()
    in.nval.toLong
  }
  def nextDouble: Double = {
    in.nextToken()
    in.nval
  }
  def readLine: String = bf.readLine()
  def println(o:Any) = out.println(o)
  def print(o:Any) = out.print(o)
  def printf(s:String,o:Any*) = out.printf(s,o)
  def flush() = out.flush()
}

import scala.io.StdIn._

object A_CuttingBanner extends App {
  val banner = readLine()
  val Code = "CODEFORCES"

  private def isPossible: Boolean = {
    if (banner.length > Code.length) {
      val sizeToCut = banner.length - Code.length
      for {
        left <- 0 to banner.length
      } {
        val L = banner.take(left)
        val R = banner.drop(left + sizeToCut)
//        println(L + "|" + R)
        if (L + R == Code) return true
      }
    }

    false
  }

  println(if (isPossible) "YES" else "NO")
}

import java.io._
import java.util._

import scala.collection.mutable

object A {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

  def nextInt: Int = return Integer.parseInt(next)

  def nextLong: Long = return java.lang.Long.parseLong(next)

  def nextDouble: Double = return java.lang.Double.parseDouble(next)

  class MultiHashSet[T <% Comparable[T]] {
    val map = new mutable.HashMap[T, Int]()

    def count(x: T): Int = {
      return map.getOrElse(x, 0)
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }
  }

  class MultiTreeSet[T <% Comparable[T]] {
    val map = new TreeMap[T, Int]()

    def count(x: T): Int = {
      val res = map.get(x)
      if (res == null)
        return 0
      return res
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def first(): T = return map.firstKey()

    def last(): T = return map.lastKey()

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }
  }

  def solve: Int = {
    val banner = next
    val n = banner.length
    for (i <- 0 until n) {
      for (j <- i - 1 until n) {
        if ((banner.substring(0, i) + banner.substring(j + 1)).equalsIgnoreCase("codeforces")) {
          out.println("YES")
          return 0
        }
      }
    }
    out.println("NO")
    return 0
  }
}

import scala.io.Source

object A extends App {
  val str = Source.stdin.getLines().next()
  val a = (0 until str.length).exists(s => (s to str.length).exists(e => str.substring(0, s) + str.substring(e) == "CODEFORCES"))
  println(if (a) "YES" else "NO")
}

import scala.collection._

object A extends App {

  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)
  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }
  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }
  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }

  val a = readLine
  val b = "CODEFORCES"
  var canCut = true
  var hasCut = false
  var ok = true

  var i = 0
  while (i < a.length && i < b.length && a(i) == b(i)) {
    i += 1
  }

  var j = 0
  while (j < a.length && j < b.length && a(a.length - j - 1) == b(b.length - j - 1)) {
    j += 1
  }
//println(i, j)
  println(if (i == b.length || j == b.length || i + j >= b.length) "YES" else "NO")
}

object Main extends App with fastIO{
  val s = readLine
  val st = "CODEFORCES"
  var bo = false
  if(s.contains(st)) bo = true
  else for(a <- 0 until s.length; b <- a until s.length){
    if(s.substring(0,a)++s.substring(b,s.length)==st) bo = true
  }
  println(if(bo)"YES" else "NO")
  flush
}

trait fastIO {
  import java.io._
  val isFile = false
  val input = "file.in"
  val output = "file.out"
  val bf = new BufferedReader(if(isFile) new FileReader(input) else new InputStreamReader(System.in))
  val in = new StreamTokenizer(bf)
  val out = new PrintWriter(if(isFile)new FileWriter(output) else new OutputStreamWriter(System.out))

  def next: String = {
    in.ordinaryChars('0', '9')
    in.wordChars('0', '9')
    in.nextToken()
    in.sval
  }
  def nextInt: Int = {
    in.nextToken()
    in.nval.toInt
  }
  def nextLong:Long ={
    in.nextToken()
    in.nval.toLong
  }
  def nextDouble: Double = {
    in.nextToken()
    in.nval
  }
  def readLine: String = bf.readLine()
  def println(o:Any) = out.println(o)
  def print(o:Any) = out.print(o)
  def printf(s:String,o:Any*) = out.printf(s,o)
  def flush() = out.flush()
}

object Main extends App with fastIO{
  val s = readLine
  val st = "CODEFORCES"
  var bo = false
  //if(s.contains(st)) bo = true
  for(a <- 0 until s.length; b <- a until s.length){
    if(s.substring(0,a)++s.substring(b,s.length)==st) bo = true
  }
  println(if(bo)"YES" else "NO")
  flush
}

trait fastIO {
  import java.io._
  val isFile = false
  val input = "file.in"
  val output = "file.out"
  val bf = new BufferedReader(if(isFile) new FileReader(input) else new InputStreamReader(System.in))
  val in = new StreamTokenizer(bf)
  val out = new PrintWriter(if(isFile)new FileWriter(output) else new OutputStreamWriter(System.out))

  def next: String = {
    in.ordinaryChars('0', '9')
    in.wordChars('0', '9')
    in.nextToken()
    in.sval
  }
  def nextInt: Int = {
    in.nextToken()
    in.nval.toInt
  }
  def nextLong:Long ={
    in.nextToken()
    in.nval.toLong
  }
  def nextDouble: Double = {
    in.nextToken()
    in.nval
  }
  def readLine: String = bf.readLine()
  def println(o:Any) = out.println(o)
  def print(o:Any) = out.print(o)
  def printf(s:String,o:Any*) = out.printf(s,o)
  def flush() = out.flush()
}

import scala.collection._

object A extends App {

  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)
  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }
  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }
  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }

  val a = readLine
  val b = "CODEFORCES"
  var canCut = true
  var hasCut = false
  var ok = true

  var i = 0
  while (i < a.length && i < b.length && a(i) == b(i)) {
    i += 1
  }

  var j = 0
  while (j < a.length && j < b.length && a(a.length - j - 1) == b(b.length - j - 1)) {
    j += 1
  }
//println(i, j)
  println(if (i == b.length || j == b.length || i + j == b.length) "YES" else "NO")
}

import scala.collection._

object A extends App {

  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)
  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }
  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }
  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }

  val a = readLine
  val b = "CODEFORCES"
  var canCut = true
  var hasCut = false
  var ok = true

  var i = 0
  while (i < a.length && i < b.length && a(i) == b(i)) {
    i += 1
  }

  var j = 0
  while (j < a.length && j < b.length && a(a.length - j - 1) == b(b.length - j - 1)) {
    j += 1
  }
//println(i, j)
  println(if (a == b || (i + j == b.length && (i > 0 || j > 0))) "YES" else "NO")
}

import java.io._
import java.util._

import scala.collection.mutable

object A {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

  def nextInt: Int = return Integer.parseInt(next)

  def nextLong: Long = return java.lang.Long.parseLong(next)

  def nextDouble: Double = return java.lang.Double.parseDouble(next)

  class MultiHashSet[T <% Comparable[T]] {
    val map = new mutable.HashMap[T, Int]()

    def count(x: T): Int = {
      return map.getOrElse(x, 0)
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }
  }

  class MultiTreeSet[T <% Comparable[T]] {
    val map = new TreeMap[T, Int]()

    def count(x: T): Int = {
      val res = map.get(x)
      if (res == null)
        return 0
      return res
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def first(): T = return map.firstKey()

    def last(): T = return map.lastKey()

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }
  }

  def solve: Int = {
    val banner = next
    val n = banner.length
    for (i <- 0 until n) {
      for (j <- i + 1 until n) {
        if ((banner.substring(0, i) + banner.substring(j)).equalsIgnoreCase("codeforces")) {
          out.println("YES")
          return 0
        }
      }
    }
    out.println("NO")
    return 0
  }
}

import scala.io.StdIn._

object A_CuttingBanner extends App {
  val banner = readLine()
  val Code = "CODEFORCES"

  private def isPossible: Boolean = {
    if (banner.length > Code.length) {
      val sizeToCut = banner.length - Code.length
      for {
        left <- 0 to (banner.length - Code.length)
      } {
        val L = banner.take(left)
        val R = banner.drop(left + banner.length - Code.length)
        if (L + R == Code) return true
      }
    }

    false
  }

  println(if (isPossible) "YES" else "NO")
}


object A676 {

  import IO._

  def main(args: Array[String]): Unit = {
    val Array(n) = readInts(1)
    val in = readInts(n)
    val idx1 = in.indexOf(1)
    val idxN = in.indexOf(n)
    var max = math.abs(idxN - idx1)
    for(i <- 0 until n if i != idxN) {
      max = math.max(max, math.abs(idxN - i))
    }
    for(i <- 0 until n if i != idx1) {
      max = math.max(max, math.abs(idx1 - i))
    }
    println(max)
  }

  object IO {
    @inline def read: String = scala.io.StdIn.readLine

    @inline def tokenizeLine = new java.util.StringTokenizer(read)

    def readInts(n: Int): Array[Int] = {
      val tl = tokenizeLine;
      Array.fill(n)(tl.nextToken.toInt)
    }

    def readLongs(n: Int): Array[Long] = {
      val tl = tokenizeLine;
      Array.fill(n)(tl.nextToken.toLong)
    }

    def readBigs(n: Int): Array[BigInt] = {
      val tl = tokenizeLine;
      Array.fill(n)(BigInt(tl.nextToken))
    }
  }

}

object Solution extends App {
  val lines = io.Source.stdin.getLines()
  lines.next()
  val data = lines.next().split(' ').map(_.toInt)
  if (data.head == 1 || data.last == 1 || data.last == data.length || data.last == data.length) {
    println(data.length - 1)
  } else {
    val indexOne = data.indexOf(1) + 1
    val indexN = data.indexOf(data.length) + 1
    var first = Math.max(indexOne - 1, indexN - 1)
    var last = Math.max(data.length - indexOne, data.length - indexN)
    println(Math.max(first, last))
  }

}

import io.StdIn._
import scala.math._

object Permutation extends App {
  val n = readInt()
  val arr = readLine().split(" ").map(_.toInt)

  val pos1 = arr.indexOf(1)
  val posMax = arr.indexOf(n)
  val diff = abs(pos1-posMax)

  if(diff == n){
    println(n-1)
  }else{
    if(pos1>posMax){
      if((n-1)-pos1>= posMax){
        println((n-1)-posMax)
      }else{
        println(pos1)
      }
    }else{
      if((n-1)-posMax>= pos1){
        println((n-1)-pos1)
      }else{
        println(posMax)
      }
    }

  }
}

import Utils._, annotation.tailrec, collection.mutable, util._, control._, math.Ordering.Implicits._

object _676A extends CodeForcesApp {
  override def apply(io: IO) = {
    val a = io[Vector[Int]]
    val n = a.length
    val (p, q) = (a.indexOf(1) + 1, a.indexOf(n) + 1)
    //debug(n, p, q)
    val ans = (p - 1).abs max (n - p) max (q - 1).abs max (n - q)
    io += ans
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: Any): Unit = if (!isOnlineJudge) println(x)
  def apply(io: IO): io.type
  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()
}
object Utils {
  import scala.collection.mutable, mutable.{Map => Dict}
  implicit class GenericExtensions[A](val a: A) extends AnyVal {
    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a
  }
  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {
    def onlyElement: A = t.head.ensuring(t.size == 1)
    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)
    def duplicates(implicit b: C of A): C[A] = {
      val elems = mutable.Set.empty[A]
      (t collect {case i if !elems.add(i) => i}).to[C]
    }
    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}
    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]
    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap
    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)
    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}
    def toMutableMultiSet: Dict[A, Int] = {
      val c = map[A] to 0
      t.foreach(i => c(i) += 1)
      c
    }
    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0
    def prefixSum(implicit n: Numeric[A]) = t.scanLeft(n.zero) {case (acc, i) => n.plus(acc, i)}
    def suffixSum(implicit n: Numeric[A]) = t.scanRight(n.zero) {case (i, acc) => n.plus(acc, i)}
  }
  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)
  }
  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)
  }
  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {
    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t
  }
  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {
    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_._1).mapValues(_._2)
    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_._1).mapValues(_.map(_._2).to[C])
    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]
  }
  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {
    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap
    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}
    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m
  }
  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {
    def notContains(x: A): Boolean = !(s contains x)
    def toMutable = mutable.Set.empty[A] ++ s
  }
  implicit class SortedExtensions[A, C[A] <: collection.SortedSet[A]](val s: C[A]) extends AnyVal {
    def greaterThanOrEqualTo(a: A): Option[A] = s.from(a).headOption
    def lessThan(a: A): Option[A] = s.until(a).lastOption
  }
  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {
    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}
    def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f) findWithIndex c
  }
  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {
    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero
  }
  implicit class LongExtensions(val x: Long) extends AnyVal {
    def bitCount: Int = java.lang.Long.bitCount(x)
  }
  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {
    import Numeric.Implicits._
    def **(i: Int): A = if (i == 0) n.one else {
      val h = x ** (i/2)
      if (i%2 == 0) h * h else h * h * x
    }
    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)
    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf "Greg" whenNegative Int.MaxValue
  }
  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {
    import scala.collection.immutable.NumericRange, Integral.Implicits._
    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x
    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(n.min(x, y), n.max(x, y), n.one)
  }
  implicit def toPoint[A](p: (A, A))(implicit n: Numeric[A]) = new java.awt.geom.Point2D.Double(n.toDouble(p._1), n.toDouble(p._2))
  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)
  def asc[A](implicit order: Ordering[A]): Ordering[A] = order
  def map[K] = new {
    def to[V](default: V): Dict[K, V] = Dict.empty[K, V] withDefaultValue default // also to(Dict.empty[K2, V])
  }
  def memoize[A, B](f: A => B): collection.Map[A, B] = new mutable.HashMap[A, B]() {
    override def apply(key: A) = getOrElseUpdate(key, f(key))
  }
  implicit class FuzzyDouble(x: Double)(implicit eps: Double = 1e-9) {
    def >~(y: Double) = x > y+eps
    def >=~(y: Double) = x >= y-eps
    def ~<(y: Double) = x < y-eps
    def ~=<(y: Double) = x <= y+eps
    def ~=(y: Double) = ~=<(y) && >=~(y)
  }
  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) Some(f) else None
  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)
  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]
  val mod: Int = (1e9 + 7).toInt
}
/***********************************[Scala I/O]*********************************************/
import Utils._, java.io._, java.util.StringTokenizer

class IO(in: BufferedReader, out: BufferedWriter) extends PrintWriter(out, true) with Iterator[String] {
  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))
  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))

  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered

  @inline private[this] def tokenizer() = {
    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()
    if (tokenizers.nonEmpty) Some(tokenizers.head) else None
  }

  def apply[A](implicit read: IO.Read[A]): A = read.apply(this)
  def apply[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(apply).to[C]

  def till(delim: String): String = tokenizer().get.nextToken(delim)
  def tillEndOfLine(): String = till("\n\r")

  override def next() = tokenizer().get.nextToken()
  override def hasNext = tokenizer().nonEmpty

  var separator = " "
  private[this] var isNewLine = true

  def +=[A](x: A)(implicit write: IO.Write[A]): this.type = {
    write(this)(x)
    this
  }
  def ++=[A: IO.Write](xs: Traversable[A]): this.type = (this += xs.size) appendNewLine xs

  def appendNewLine[A: IO.Write](x: A): this.type = {
    println()
    this += x
  }

  override def print(obj: String) = {
    if (isNewLine) isNewLine = false else super.print(separator)
    super.print(obj)
  }
  override def println() = if (!isNewLine) {
    super.println()
    isNewLine = true
  }
  override def close() = {
    flush()
    in.close()
    super.close()
  }
}
object IO {
  class Read[A](val apply: IO => A) {
    def map[B](f: A => B): Read[B] = new Read(apply andThen f)
  }
  object Read {
    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r[C, A](r[Int]))
    implicit val string                                       : Read[String]       = new Read(_.next())
    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)
    implicit val boolean                                      : Read[Boolean]      = string.map(_.toBoolean)
    implicit val int                                          : Read[Int]          = string.map(_.toInt)
    implicit val long                                         : Read[Long]         = string.map(_.toLong)
    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))
    implicit val double                                       : Read[Double]       = string.map(_.toDouble)
    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))
    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r[A], r[B]))
    implicit def tuple3[A: Read, B: Read, C: Read]            : Read[(A, B, C)]    = new Read(r => (r[A], r[B], r[C]))
    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]   : Read[(A, B, C, D)] = new Read(r => (r[A], r[B], r[C], r[D]))
  }
  trait Write[-A] {
    def apply(out: PrintWriter)(x: A): Unit
  }
  trait DefaultWrite {
    implicit def any[A]: Write[A] = Write(_.toString)
  }
  object Write extends DefaultWrite {
    def apply[A](f: A => String) = new Write[A] {
      override def apply(out: PrintWriter)(x: A) = out.print(f(x))
    }
    implicit val boolean: Write[Boolean] = Write(b => if (b) "YES" else "NO")
    implicit def tuple2[A, B]: Write[(A, B)] = Write {case (a, b) => s"$a $b"}
    implicit def array[A]: Write[Array[A]] = Write(_ mkString " ")
    implicit def iterable[A](implicit write: Write[A]): Write[Traversable[A]] = new Write[Traversable[A]] {
      override def apply(out: PrintWriter)(xs: Traversable[A]) = {
        xs foreach write(out)
        out.println()
      }
    }
  }
}

import Utils._, annotation.tailrec, collection.mutable, util._, control._, math.Ordering.Implicits._

object _676A extends CodeForcesApp {
  override def apply(io: IO) = {
    val a = io[Vector[Int]]
    val n = a.length
    val (p, q) = (a.indexOf(1), a.indexOf(n))
    val ans = p max (n - p) max q max (n - q)
    io += (ans - 1)
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: Any): Unit = if (!isOnlineJudge) println(x)
  def apply(io: IO): io.type
  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()
}
object Utils {
  import scala.collection.mutable, mutable.{Map => Dict}
  implicit class GenericExtensions[A](val a: A) extends AnyVal {
    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a
  }
  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {
    def onlyElement: A = t.head.ensuring(t.size == 1)
    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)
    def duplicates(implicit b: C of A): C[A] = {
      val elems = mutable.Set.empty[A]
      (t collect {case i if !elems.add(i) => i}).to[C]
    }
    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}
    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]
    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap
    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)
    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}
    def toMutableMultiSet: Dict[A, Int] = {
      val c = map[A] to 0
      t.foreach(i => c(i) += 1)
      c
    }
    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0
    def prefixSum(implicit n: Numeric[A]) = t.scanLeft(n.zero) {case (acc, i) => n.plus(acc, i)}
    def suffixSum(implicit n: Numeric[A]) = t.scanRight(n.zero) {case (i, acc) => n.plus(acc, i)}
  }
  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)
  }
  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)
  }
  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {
    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t
  }
  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {
    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_._1).mapValues(_._2)
    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_._1).mapValues(_.map(_._2).to[C])
    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]
  }
  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {
    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap
    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}
    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m
  }
  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {
    def notContains(x: A): Boolean = !(s contains x)
    def toMutable = mutable.Set.empty[A] ++ s
  }
  implicit class SortedExtensions[A, C[A] <: collection.SortedSet[A]](val s: C[A]) extends AnyVal {
    def greaterThanOrEqualTo(a: A): Option[A] = s.from(a).headOption
    def lessThan(a: A): Option[A] = s.until(a).lastOption
  }
  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {
    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}
    def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f) findWithIndex c
  }
  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {
    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero
  }
  implicit class LongExtensions(val x: Long) extends AnyVal {
    def bitCount: Int = java.lang.Long.bitCount(x)
  }
  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {
    import Numeric.Implicits._
    def **(i: Int): A = if (i == 0) n.one else {
      val h = x ** (i/2)
      if (i%2 == 0) h * h else h * h * x
    }
    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)
    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf "Greg" whenNegative Int.MaxValue
  }
  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {
    import scala.collection.immutable.NumericRange, Integral.Implicits._
    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x
    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(n.min(x, y), n.max(x, y), n.one)
  }
  implicit def toPoint[A](p: (A, A))(implicit n: Numeric[A]) = new java.awt.geom.Point2D.Double(n.toDouble(p._1), n.toDouble(p._2))
  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)
  def asc[A](implicit order: Ordering[A]): Ordering[A] = order
  def map[K] = new {
    def to[V](default: V): Dict[K, V] = Dict.empty[K, V] withDefaultValue default // also to(Dict.empty[K2, V])
  }
  def memoize[A, B](f: A => B): collection.Map[A, B] = new mutable.HashMap[A, B]() {
    override def apply(key: A) = getOrElseUpdate(key, f(key))
  }
  implicit class FuzzyDouble(x: Double)(implicit eps: Double = 1e-9) {
    def >~(y: Double) = x > y+eps
    def >=~(y: Double) = x >= y-eps
    def ~<(y: Double) = x < y-eps
    def ~=<(y: Double) = x <= y+eps
    def ~=(y: Double) = ~=<(y) && >=~(y)
  }
  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) Some(f) else None
  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)
  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]
  val mod: Int = (1e9 + 7).toInt
}
/***********************************[Scala I/O]*********************************************/
import Utils._, java.io._, java.util.StringTokenizer

class IO(in: BufferedReader, out: BufferedWriter) extends PrintWriter(out, true) with Iterator[String] {
  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))
  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))

  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered

  @inline private[this] def tokenizer() = {
    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()
    if (tokenizers.nonEmpty) Some(tokenizers.head) else None
  }

  def apply[A](implicit read: IO.Read[A]): A = read.apply(this)
  def apply[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(apply).to[C]

  def till(delim: String): String = tokenizer().get.nextToken(delim)
  def tillEndOfLine(): String = till("\n\r")

  override def next() = tokenizer().get.nextToken()
  override def hasNext = tokenizer().nonEmpty

  var separator = " "
  private[this] var isNewLine = true

  def +=[A](x: A)(implicit write: IO.Write[A]): this.type = {
    write(this)(x)
    this
  }
  def ++=[A: IO.Write](xs: Traversable[A]): this.type = (this += xs.size) appendNewLine xs

  def appendNewLine[A: IO.Write](x: A): this.type = {
    println()
    this += x
  }

  override def print(obj: String) = {
    if (isNewLine) isNewLine = false else super.print(separator)
    super.print(obj)
  }
  override def println() = if (!isNewLine) {
    super.println()
    isNewLine = true
  }
  override def close() = {
    flush()
    in.close()
    super.close()
  }
}
object IO {
  class Read[A](val apply: IO => A) {
    def map[B](f: A => B): Read[B] = new Read(apply andThen f)
  }
  object Read {
    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r[C, A](r[Int]))
    implicit val string                                       : Read[String]       = new Read(_.next())
    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)
    implicit val boolean                                      : Read[Boolean]      = string.map(_.toBoolean)
    implicit val int                                          : Read[Int]          = string.map(_.toInt)
    implicit val long                                         : Read[Long]         = string.map(_.toLong)
    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))
    implicit val double                                       : Read[Double]       = string.map(_.toDouble)
    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))
    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r[A], r[B]))
    implicit def tuple3[A: Read, B: Read, C: Read]            : Read[(A, B, C)]    = new Read(r => (r[A], r[B], r[C]))
    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]   : Read[(A, B, C, D)] = new Read(r => (r[A], r[B], r[C], r[D]))
  }
  trait Write[-A] {
    def apply(out: PrintWriter)(x: A): Unit
  }
  trait DefaultWrite {
    implicit def any[A]: Write[A] = Write(_.toString)
  }
  object Write extends DefaultWrite {
    def apply[A](f: A => String) = new Write[A] {
      override def apply(out: PrintWriter)(x: A) = out.print(f(x))
    }
    implicit val boolean: Write[Boolean] = Write(b => if (b) "YES" else "NO")
    implicit def tuple2[A, B]: Write[(A, B)] = Write {case (a, b) => s"$a $b"}
    implicit def array[A]: Write[Array[A]] = Write(_ mkString " ")
    implicit def iterable[A](implicit write: Write[A]): Write[Traversable[A]] = new Write[Traversable[A]] {
      override def apply(out: PrintWriter)(xs: Traversable[A]) = {
        xs foreach write(out)
        out.println()
      }
    }
  }
}


    object Main
    {
        def min(a:Int, b:Int, c:Int):Int =
        {
            var aorb = 0;
            if (a < b)
            {
                aorb = a
            }
            else
            {
                aorb = b
            }

            if (c < aorb)
                return c;
            return aorb;
        }
        def main(args:Array[String])
        {
            val a = readLine().split(" ").map(i => i.toInt);
            val n = a(0);
            val k = a(1);
            val l = a(2);
            val c = a(3);
            val d = a(4);
            val p = a(5);
            val nl = a(6);
            val np = a(7);

            println(min(k * l / nl, c * d, p / np) / n);
        }
    }

import java.util.Scanner
object Cola {

  def main(args: Array[String] ) {
    val scanner = new Scanner(System.in)
    val n, k, l, c, d, p, nl, np = scanner.nextInt();
    val limes = c*d/n
    val cola = k*l/(n*nl)
    val salt = p/(n*np)

    println(Math.min(Math.min(limes,cola),salt))

  }
}

/**
 * Created by IntelliJ IDEA.
 * User: cm
 * Date: 17.02.12
 * Time: 23:06
 * To change this template use File | Settings | File Templates.
 */

object P151A extends App {
  val Array(n, k, l, c, d, p, nl, np) = readLine().split(" ").map(_.toInt)
  print(List(k*l/nl,c*d,p/np).min / n)
}

import java.util.StringTokenizer

object _151A extends App {
  var token = new StringTokenizer("")
  def next = {
    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)
    token.nextToken()
  }
  val Array(n, k, l, c, d, p, nl, np) = (1 to 8).map(i => next.toInt).toArray
  val ans = (k * l / nl) min (c * d) min (p / np)
  println(ans / n)
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, k, l, c, d, p, nl, np) = in.next().split(" ").map(_.toInt)
  println(Math.min(c * d, Math.min((k * l) / nl, p / np)) / n)
}

import java.util.Scanner
import java.io.PrintWriter
import scala.annotation.tailrec
import scala.collection.mutable
import scala.util.Random

object P151A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  val n, k, l, c, d, p, nl, np  = sc.nextInt

  val drink = (k * l) / nl
  val lime = c * d
  val salt = p / np

  val answer = List(drink, lime, salt).min / n

  out.println(answer)
  out.close
}

import java.io._
import scala.annotation.tailrec

object Easy {
  val reader = new BufferedReader(new InputStreamReader(System.in))
  def readInt = reader.readLine().toInt
  def readInts = reader.readLine().split(" ").map(_.toInt)

  val Array(n, k, l, c, d, p, nl, np) = readInts
  def ans = ((k * l) / nl min c * d min p / np) / n

  def main(a: Array[String]) {
    println(ans)
  }
}

object Main {
  def main(args: Array[String]) {
    val nklcdpnlnp = readLine().split(" ").map(_.toInt)
    val n = nklcdpnlnp(0)
    val k = nklcdpnlnp(1)
    val l = nklcdpnlnp(2)
    val c = nklcdpnlnp(3)
    val d = nklcdpnlnp(4)
    val p = nklcdpnlnp(5)
    val nl = nklcdpnlnp(6)
    val np = nklcdpnlnp(7)

    val tests = Seq(k * l / nl) ++ Seq(c * d) ++ Seq(p / np)
    println(tests.min / n)
  }
}

import java.util.Scanner

object SoftDrinking {
  def main(args: Array[String]) {
    val sc = new Scanner(System.in)
    val n = sc.nextInt
    val k = sc.nextInt
    val l = sc.nextInt
    val c = sc.nextInt
    val d = sc.nextInt
    val p = sc.nextInt
    val nl = sc.nextInt
    val np = sc.nextInt
    println(List(k * l / nl, c * d, p / np).min / n)
  }
}

import java.util.StringTokenizer

object _151A extends App {
  var token = new StringTokenizer("")
  def next = {
    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)
    token.nextToken()
  }
  val Array(n, k, l, c, d, p, nl, np) = (1 to 8).map(i => next.toInt).toArray
  val ans = (n * k / nl) min (c * d) min (p / np)
  println(ans / n)
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, k, l, c, d, p, nl, np) = in.next().split(" ").map(_.toInt)
  println(Math.min(c * d, Math.min(n / nl, p / np)) / n)
}


import scala.io.Source

object Solution extends App {
  val in = Source.stdin.getLines()
  val Array(n, p) = in.next().split(' ').map(_.toInt)
  println((1 to n).map(_ => in.next()).reverse.tail.foldLeft((1l, p.toLong / 2)) {
    case ((mayBuy, money), "halfplus") => (mayBuy * 2 + 1, money + p * mayBuy + p / 2)
    case ((mayBuy, money), _) => (mayBuy * 2, money + p * mayBuy)
  }._2)
}

/**
 * Created by aborisenko on 21.02.16.
 */

import io.StdIn._

object Main extends App {
  def a632 (){

    val Array(n, p) = readLine().split(" ").map(_.toInt)

    var result: Long = 0
    var nn: Long = 0

    val a: Array[Int] = Array.fill[Int](n)(0)
    for( i <- 0 to n-1)
      if( readLine() == "half" )
        a(i) = 1

    for( i <- 1 to n) {
      if (a(n-i) == 1) {
        result += nn * p
        nn *= 2
      } else {
        result += nn * p + p / 2
        nn = nn * 2 + 1
      }
    }

    println(result)
  }

  a632()
}

import scala.io.Source

object Solution extends App {
  val in = Source.stdin.getLines()
  val Array(n, p) = in.next().split(' ').map(_.toInt)
  println((1 to n).map(_ => in.next()).reverse.tail.foldLeft((1, p / 2)) {
    case ((mayBuy, money), "halfplus") => (mayBuy * 2 + 1, money + p * mayBuy + p / 2)
    case ((mayBuy, money), _) => (mayBuy * 2, money + p * mayBuy)
  }._2)
}

/**
 * Created by aborisenko on 21.02.16.
 */

import io.StdIn._

object Main extends App {
  def a632 (){

    val Array(n, p) = readLine().split(" ").map(_.toInt)

    var result: Long = 0
    var nn: Long = 0

    val a: Array[Int] = Array.fill[Int](n)(0)
    for( i <- 0 to n-1)
      if( readLine() == "half" )
        a(i) = 1

    for( i <- 0 to n-1) {
      if (a(i) == 1) {
        result += nn * p
        nn *= 2
      } else {
        result += nn * p + p / 2
        nn = nn * 2 + 1
      }
    }

    println(result)
  }

  a632()
}


import scala.io.Source

object Solution extends App {
  val in = Source.stdin.getLines()
  val Array(a, b, c) = in.next().split(' ').map(_.toInt)
  val r = (0 to a).find{ i =>
    val ab = i
    val ac = a - i
    b - ab >= 0 && (b - ab) == (c - ac)
  }
  println(r.map{
    i => s"$i ${b - i} ${a - i}"
  }.getOrElse("Impossible"))
}

object B344 {
  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)

  def readInts(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)
  }

  def readLongs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)
  }

  def readBigs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))
  }

  def main(args: Array[String]): Unit = {
    val Array(a, b, c) = readInts(3)
    var i = 0
    var break = false
    while(!break && i <= a) {
      if(c-(a-i) >= 0 && c-a+2*i == b) {
        println(s"$i ${c-a+i} ${a-i}")
        break = true
      }
      i += 1
    }

    if(!break) {
      println("Impossible")
    }
  }
}

import scala.collection._

object B extends App {

  def readString = Console.readLine
  def tokenizeLine = new java.util.StringTokenizer(readString)
  def readInts(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toInt) }
  def readLongs(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toLong) }
  def readBigs(n: Int) = { val t = tokenizeLine; Array.fill(n)(BigInt(t.nextToken)) }

  val as = readInts(3)
  val sort = as.zipWithIndex.sortBy(_._1)

  val d = math.abs(sort(1)._1 - sort(2)._1)

  def idx(a: Int, b: Int) = (a, b) match {
      case (0, 1) | (1, 0) => 0
      case (1, 2) | (2, 1) => 1
      case (0, 2) | (2, 0) => 2
    }

  if ((sort(0)._1 - d) % 2 == 1 || sort(0)._1 < d) {
    println("Impossible")
  } else {
    val dd = (sort(0)._1 - d) / 2
    val bs = Array(dd, dd + d, sort(1)._1 - dd)
    val cs = Array.ofDim[Int](3)

    cs(idx(sort(0)._2, sort(1)._2)) = bs(0)
    cs(idx(sort(1)._2, sort(2)._2)) = bs(2)
    cs(idx(sort(0)._2, sort(2)._2)) = bs(1)

    println(cs.mkString(" "))
  }

}

import java.util.Scanner
import java.io.PrintWriter
import java.util.Arrays.binarySearch
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.collection.mutable.ArrayBuffer
import scala.collection.immutable.TreeSet
import scala.util.Random
import scala.util.control.Breaks._

object P344B extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  def solve(): String = {
    val A, B, C = sc.nextInt

    val xyz2 = List(A + B - C, - A + B + C, A - B + C)

    if (xyz2.forall { x => x >= 0 && x % 2 == 0 } ) {
      xyz2.map(_ / 2).mkString(" ")
    }
    else {
      "Impossible"
    }
  }

  out.println(solve)
  out.close
}

object Main {
  def main(args: Array[String]) {
    val a = readLine().split(" ").map(_.toInt)
    val s = a.map(_ => 0)

    s(0) = (a(0) + a(1) - a(2)) / 2
    s(1) = (a(1) + a(2) - a(0)) / 2
    s(2) = (a(2) + a(0) - a(1)) / 2

    if (s.min < 0 || a.sum % 2 != 0) println("Impossible")
    else println(s.mkString(" "))
  }
}

object B344 {
  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)

  def readInts(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)
  }

  def readLongs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)
  }

  def readBigs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))
  }

  def main(args: Array[String]): Unit = {
    val Array(a, b, c) = readInts(3)
    var i = 0
    var break = true
    while(break && i <= a) {
      if(c-(a-i) > 0 && c-a+2*i > 0 && c-a+2*i == b) {
        println(s"$i ${c-(a-i)} ${a-i}")
        break = false
      }
      i += 1
    }

    if(break) {
      println("Impossible")
    }
  }
}

object Main {
  def main(args: Array[String]) {
    val a = readLine().split(" ").map(_.toInt)
    val s = a.map(_ => 0)
    s(0) = (a(0) + a(1) - a(2)) / 2
    s(1) = (a(1) + a(2) - a(0)) / 2
    s(2) = (a(2) + a(0) - a(1)) / 2

    if (s.min < 0) println("Impossible")
    else println(s.mkString(" "))
  }
}


/**
  * Created by ruslan on 3/29/17.
  */
object ProblemA extends App {
    import java.io.{BufferedReader, IOException, InputStreamReader, PrintWriter}
import java.util.StringTokenizer

  val in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)))
  val out = new PrintWriter(System.out)

  class FastScanner(val in: BufferedReader) {
    var st: StringTokenizer = _;

    def nextToken(): String = {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(in.readLine);
      }
      return st.nextToken();
    }

    def nextInt(): Integer = {
      Integer.parseInt(nextToken());
    }

    def nextLong(): Long = {
      nextToken().toLong;
    }

    def nextDouble(): Double = {
      nextToken().toDouble;
    }
  }

  val n = in.nextInt()
  val m = in.nextInt()

  val k = in.nextInt()

  var res = n + 1

  for (i <- 1 to n) {
    val emount = in.nextInt()
    if (emount != 0 && emount <= k && Math.abs(i - m) < res) {
      res = Math.abs(i - m)
    }
  }

  println(res * 10)

}

import scala.io.Source
import scala.math._

object a12 {
  def main(args: Array[String]): Unit = {
    val lines = Source.stdin.getLines().take(2).map(_.split(' ').map(_.toInt)).toArray
    val Array(n,kk,l) = lines(0)
    val k = kk-1
    val (bb,cc) = lines(1).zipWithIndex.splitAt(k)
    val (b,c) = (bb.filter(_._1!=0).reverse.dropWhile(_._1 > l).headOption,
                 cc.tail.filter( _._1!=0).dropWhile(_._1 > l).headOption)
    println(
      (b,c) match {
        case (Some(a), Some(b)) => min(k-a._2, b._2-k)*10
        case (Some(d),None) => (k - d._2)*10
        case (None, Some(d)) => (d._2 - k)*10
        case (None,None) => -1
       }
    )
  }
}

//package com.obarros.hackerrank.codechallenges.daysofcode.codeforces.Round_408

object ProblemA {
  def main(args: Array[String]): Unit = {
    val input = scala.io.StdIn.readLine().split(" ").map(_.toInt)
    val n = input(0)
    val m = input(1)
    val k = input(2)
    val houses = scala.io.StdIn.readLine().split(" ").map(_.toInt)
    System.out.println(solution(n, m, k, houses))
  }

  def solution(n: Int, m: Int, k: Int, houses: Array[Int]): Int = {

    var result = Int.MaxValue
    for (i <- houses.indices) {
      if (houses(i) != 0 && houses(i) <= k)
        result = math.min(result, 10*math.abs(m -1 - i))
    }
    result
  }
}

import scala.io.Source
import scala.math._

object a12 {
  def main(args: Array[String]): Unit = {
    val lines = Source.stdin.getLines().take(2).map(_.split(' ').map(_.toInt)).toArray
    val Array(n,k,l) = lines(0)
    val (bb,cc) = lines(1).zipWithIndex.splitAt(k-1)
    val (b,c) = (bb.filter(_._1!=0).reverse.dropWhile(_._1 > l).headOption,
                 cc.tail.filter( _._1!=0).dropWhile(_._1 > l).headOption)
    println(
      (b,c) match {
        case (Some(a), Some(b)) => min(k-a._2, b._2-k)*10
        case (Some(d),None) => (k-1 - d._2)*10
        case (None, Some(d)) => (d._2 - k+1)*10
        case (None,None) => -1
       }
    )
  }
}

//package com.obarros.hackerrank.codechallenges.daysofcode.codeforces.Round_408

object ProblemA {
  def main(args: Array[String]): Unit = {
    val input = scala.io.StdIn.readLine().split(" ").map(_.toInt)
    val m = input(0)
    val n = input(1)
    val k = input(2)
    val houses = scala.io.StdIn.readLine().split(" ").map(_.toInt)
    var cond: Array[Int] = Array[Int]()
    var res: Array[Int] = Array[Int]()

    for (i <- houses.indices) {
      if (houses(i) <= k && i != n && i != 0)
        cond :+= 1
      else
        cond :+= 0
    }

    for (j <- houses.indices) {
      res :+= cond(j) * (j + 1) * 10
    }

    val reset = n * 10
    val result = {
      res.filter(x => x != 0).map(x => math.abs(x - reset)).min
    }

    System.out.println(result)
  }

}

//package com.obarros.hackerrank.codechallenges.daysofcode.codeforces.Round_408

object ProblemA {
  def main(args: Array[String]): Unit = {
    val input = scala.io.StdIn.readLine().split(" ").map(_.toInt)
    val m = input(0)
    val n = input(1)
    val k = input(2)
    val houses = scala.io.StdIn.readLine().split(" ").map(_.toInt)
    var cond: Array[Int] = Array[Int]()
    var res: Array[Int] = Array[Int]()

    for (i <- houses.indices) {
      if (houses(i) <= k && i != n && i != 0)
        cond :+= 1
      else
        cond :+= 0
    }

    for (j <- houses.indices) {
      res :+= cond(j) * (j + 1) * 10
    }

    val reset = n * 10
    val result = {
      res.map(x => x - reset).filter(x => x != 0).map(x => math.abs(x)).min
    }

    System.out.println(result)
  }

}

//package com.obarros.hackerrank.codechallenges.daysofcode.codeforces.Round_408

object ProblemA {
  def main(args: Array[String]): Unit = {
    val input = scala.io.StdIn.readLine().split(" ").map(_.toInt)
    val m = input(0)
    val n = input(1)
    val k = input(2)
    val houses = scala.io.StdIn.readLine().split(" ").map(_.toInt)
    var cond: Array[Int] = Array[Int]()
    var res: Array[Int] = Array[Int]()

    for (i <- houses.indices) {
      if (houses(i) <= k && i != n && houses(i) != 0)
        cond :+= 1
      else
        cond :+= 0
    }

    for (j <- houses.indices) {
      res :+= cond(j) * (j + 1) * 10
    }

//    System.out.println("cond: ")
//    cond.foreach(x => print(x + " "))
//    System.out.println()
//    System.out.println("res: ")
//    res.foreach(x => print(x + " "))
//    System.out.println()

    val reset = n * 10
    val result = {
      res.filter(x => x != 0 ).map(x => math.abs(x - reset)).filter(x => x != 0 ).min
    }

    System.out.println(result)
  }

}

//package Round_408

/**
  * Created by OMVB on 10/04/2017.
  */
object Problem_A {
  def main(args: Array[String]): Unit = {
    val input = scala.io.StdIn.readLine().split(" ").map(_.toInt)
    val m = input(0)
    val n = input(1)
    val k = input(2)
    val houses = scala.io.StdIn.readLine().split(" ").map(_.toInt)
    var cond: Array[Int] = Array[Int]()
    var res: Array[Int] = Array[Int]()

    for (i <- houses.indices) {
      if (houses(i) <= k && i != n && i != 0)
        cond :+= 1
      else
        cond :+= 0
    }

    for (j <- houses.indices) {
      res :+= cond(j) * (j + 1) * 10
    }

    val reset = n * 10
    val result = {
      res.map(x => x - reset).filter(x => x > 0 && x != 0 && x != m).min
    }

    System.out.println(result)
  }

}


object _1141A extends CodeForcesApp {
  import annotation._, collection.{mutable, Searching}, util._, control._, math.Ordering.Implicits._, Searching._, Math._

  override def apply(io: IO): io.type = {
    val n, m = io.read[Int]
    val ans = if (m%n == 0) {
      var r = m/n
      var c = 0
      while(r%3 == 0) {
        r /= 3
        c += 1
      }
      while(r%2 == 0) {
        r /= 2
        c += 1
      }
      if (r == 1) Some(c) else None
    } else {
      None
    }

    io.write(ans.getOrElse(-1))
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)
  def apply(io: IO): io.type
  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()
}
/***********************************[Scala I/O]*********************************************/
import java.io._, java.util.StringTokenizer
import scala.collection.generic.CanBuild

class IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {
  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))
  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))

  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered
  val printer = new PrintWriter(out, true)

  @inline private[this] def tokenizer() = {
    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()
    tokenizers.headOption
  }

  def read[A](implicit read: IO.Read[A]): A = read.apply(this)
  def read[C[_], A: IO.Read](n: Int)(implicit b: CanBuild[A, C[A]]): C[A] = Iterator.fill(n)(read).to[C]

  def readTill(delim: String): String = tokenizer().get.nextToken(delim)
  def readTillEndOfLine(): String = readTill("\n\r")

  def readAll[A: IO.Read]: (Int, Vector[A]) = {
    val data = read[Vector[A]]
    (data.length, data)
  }

  override def next() = tokenizer().get.nextToken()
  override def hasNext = tokenizer().nonEmpty

  def write(obj: Any): this.type = {
    printer.print(obj)
    this
  }
  def writeLine(): this.type = {
    printer.println()
    this
  }
  def writeLine(obj: Any): this.type = {
    printer.println(obj)
    this
  }
  def writeLines(obj: Traversable[Any]): this.type = writeAll(obj, separator = "\n")
  def writeAll(obj: Traversable[Any], separator: String = " "): this.type = write(obj mkString separator)
  def query[A: IO.Read](question: Any): A = writeLine(question).read

  override def flush() = printer.flush()
  def close() = {
    flush()
    in.close()
    printer.close()
  }
}
object IO {
  class Read[A](val apply: IO => A) {
    def map[B](f: A => B): Read[B] = new Read(apply andThen f)
  }

  object Read {
    implicit def collection[C[_], A: Read](implicit b: CanBuild[A, C[A]]) : Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))
    implicit val string                                                   : Read[String]       = new Read(_.next())
    implicit val int                                                      : Read[Int]          = string.map(_.toInt)
    implicit val long                                                     : Read[Long]         = string.map(_.toLong)
    implicit val bigInt                                                   : Read[BigInt]       = string.map(BigInt(_))
    implicit val double                                                   : Read[Double]       = string.map(_.toDouble)
    implicit val bigDecimal                                               : Read[BigDecimal]   = string.map(BigDecimal(_))
    implicit def tuple2[A: Read, B: Read]                                 : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))
    implicit def tuple3[A: Read, B: Read, C: Read]                        : Read[(A, B, C)]    = new Read(r => (r.read[A], r.read[B], r.read[C]))
    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]               : Read[(A, B, C, D)] = new Read(r => (r.read[A], r.read[B], r.read[C], r.read[D]))
    implicit val boolean                                                  : Read[Boolean]      = string map {s =>
      s.toLowerCase match {
        case "yes" | "true" | "1" => true
        case "no" | "false" | "0" => false
        case _ => s.toBoolean
      }
    }
  }
}

object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N, M = ni()
    REP(30) { two =>
      REP(18) { three =>
        val a = math.round(math.pow(2, two))
        val b = math.round(math.pow(3, three))
        debug(s"$a $b")
        if (M % a == 0 && M % b == 0 && M / a / b == N) {
          out.println(s"${two + three}")
          return
        }
      }
    }

    out.println(-1)
  }

  private val oj = System.getenv("ATCODER_DEBUG") == null

  def DEBUG(f: => Unit): Unit = {
    if (!oj){ f }
  }

  def debug(as: Array[Boolean]): Unit = DEBUG {
    debug(as.map(x => if(x) "1" else "0").mkString)
  }

  def debug(as: Array[Int]): Unit = DEBUG {
    debug(as.mkString(" "))
  }

  def debug(as: Array[Long]): Unit = DEBUG {
    debug(as.mkString(" "))
  }

  def debug(s: => String): Unit = DEBUG {
    System.err.println(s)
  }

  def debugL(num: => Long): Unit = DEBUG {
    System.err.println(num)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }
  def TO(from: Int, to: Int)(f: Int => Unit): Unit = {
    REP(to - from + 1, from) { i =>
      f(i)
    }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

import java.util.Scanner

object Main {

  def main(args: Array[String]): Unit = {
    val sc  = new Scanner(System.in)
    val n = sc.nextInt()
    val m = sc.nextInt()
    if(n == m)
      println(0)

    else if(n % 2 == 0 && m % 2 == 1)
      println(-1)

    else if(m % n == 0){
      var division = m / n
      var res = 0;
      while(division % 3 == 0){
        division = division / 3
        res += 1
      }
      while (division % 2 == 0){
        division = division / 2
        res += 1
      }
      if(division == 1)
        println(res)
      else
        println(-1)
    }
    else
      println(-1)
  }
}

object Competitive extends App {
  val Array(x,y) = readLine.split(" ").map(_.toInt)
  if(x==y) println(0)
  else if(y%x!=0) println(-1)
  else {
    var z = y / x
    var count = 0
    var stat = 1
    while(z>1) {
      if(z%2!=0 && z%3!=0) {
        stat = 0
        z = 1
      }
      else {
        if(z%2==0) z/=2
        else if(z%3==0) z/=3
        count+=1
      }
    }
    if(stat==0) println(-1)
    else println(count)
  }

}

import scala.annotation.tailrec

object Main extends App {

  val inputs = io.StdIn.readLine().split(" ").map(x => x.toInt)

  def solve(i: Int, i1: Int): Int = {
    @tailrec
    def solve(a: Int, acc: Int = 0): Int = {
      if (a == 1) acc
      else if (a == -1) -1
      else solve(if (a % 3 == 0) a / 3 else if (a % 2 == 0) a / 2 else -1, acc + 1)

    }

    if (i1 % i != 0) -1
    else solve(i1 / i)
  }

  println(solve(inputs(0), inputs(1)))

}

object Main extends App {

  val inputs = io.StdIn.readLine().split(" ").map(x => x.toInt)

  def solve(i: Int, i1: Int): Int = {
    def solve(a: Int, acc: Int = 0): Int = {
      if (a == 1) acc
      else if (a == -1) -1
      else solve(if (a % 3 == 0) a / 3 else if (a % 2 == 0) a / 2 else -1, acc + 1)

    }

    if (i1 % i != 0) -1
    else solve(i1 / i)
  }

  println(solve(inputs(0), inputs(1)))

}

object Main extends App {

  val inputs = io.StdIn.readLine().split(" ").map(x => x.toInt)

  def solve(i: Int, i1: Int) : Int = {
    def solve(a: Int, acc: Int = 0): Int = {
      if (a == 1) acc
      else solve(if (a % 3 == 0) a / 3 else a / 2, acc + 1)

    }
    if (i1 % i != 0) -1
    else solve(i1 / i)
  }

  println(solve(inputs(0),inputs(1)))

}

object Main extends App {

  val inputs = io.StdIn.readLine().split(" ").map(x => x.toInt)

  def solve(i: Int, i1: Int): Int = {
    def solve(a: Int, acc: Int = 0): Int = {
      if (a == 1) acc
      else solve(if (a % 3 == 0) a / 3 else a / 2, acc + 1)

    }

    if (i1 % i != 0) -1
    else if (i == i1) 0
    else if (i1 % 2 != 0 && i1 % 3 != 0) -1
    else solve(i1 / i)
  }

  println(solve(inputs(0), inputs(1)))

}


import scala.io.StdIn._
import scala.util.control._

object cf697B {
    def main (args: Array[String]) {
        val line = readLine()

        var b:Int = 0;
        var ex_e = false

        for (i <- 0 until line.length()) {
            if (ex_e == true) {
                b = b * 10 + line(i) - '0'
            }
            if (line(i) == 'e') ex_e = true
        }

        // println(b)
        var ex_point = false
        var buf = new StringBuilder()

        var loop = new Breaks
        loop.breakable {
            for (i <- 0 until line.length()) {
                if (line(i) == 'e') {
                    if (b > 0) {
                        while (b > 0) {
                            buf += '0'
                            b = b - 1
                        }
                        buf += '.'
                    }
                    loop.break
                }

                if (ex_point == true) {
                    if (b == 0) {
                        buf += '.'
                    }
                    buf += line(i)
                    b = b - 1
                } else {
                    if (line(i) == '.') {
                        ex_point = true
                    } else {
                        buf += line(i)
                    }
                }
            }
        }

        var pos: Int = 0
        // println(buf)
        loop.breakable {
            for (i <- 0 until buf.length()) {
                var j = buf.length() - i - 1;
                if (buf(j) == '.') {
                    pos = j
                    loop.break
                }
                if (buf(j) != '0') {
                    pos = j + 1
                    loop.break
                }
            }
        }
        // println("pos " + pos)
        var flag = false

        for (i <- 0 until pos) {
            if (flag == true) {
                if (buf(i) == '.' && i == buf.length()-1) {
                } else {
                    print(buf(i))
                }
            } else {
                if (buf(i) != '0') {
                    print(buf(i))
                    flag = true
                } else if (buf(i + 1) == '.' ) {
                    print(buf(i));
                    flag = true
                }
            }
        }
        println()
    }
}

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val line = in.next()
  val Array(ns, es) = line.split('e')
  val (ne, ee) = ns.split('.') match {
    case Array(before, after) =>
      val afterDrop = after.reverse.dropWhile(_ == '0').reverse
      (before + afterDrop, -afterDrop.length)
    case Array(before) => (before, 0)
  }
  val e = ee + es.toInt

  if (e == 0)
    println(ne)
  else if (e < 0)
    println(ne.take(ne.length + e) + '.' + ne.drop(ne.length + e))
  else
    println(ne + "0" * e)
}

object Solution {
    def main(args : Array[String]) {
        val line = readLine()
        val r = "^(.*)\\.(.*)e(.*)$"r;
        val r(a, d, e) = line
        var n = a + d
        val i = e.toInt
        if (n.size < 1 + i) n = n + ("0" * (i + 1 - n.size))
        n = n.substring(0, i + 1) +  "." + n.substring(i + 1);
        println(post(n));
    }
    def post(s:String) :String = {
        if (s.startsWith("0") && !s.startsWith("0."))
            post(s.substring(1))
        else if (s.matches(".*\\.0*")) s.substring(0,s.indexOf('.'))
        else s
    }
}

import scala.io.StdIn._
import scala.util.control._

object cf697B {
    def main (args: Array[String]) {
        val line = readLine()

        var b:Int = 0;
        var ex_e = false

        for (i <- 0 until line.length()) {
            if (ex_e == true) {
                b = b * 10 + line(i) - '0'
            }
            if (line(i) == 'e') ex_e = true
        }

        // println(b)
        var ex_point = false
        var buf = new StringBuilder()

        var loop = new Breaks
        loop.breakable {
            for (i <- 0 until line.length()) {
                if (line(i) == 'e') {
                    while (b > 0) {
                        buf += '0'
                        b = b - 1
                    }
                    buf += '.'
                    loop.break
                }

                if (ex_point == true) {
                    if (b == 0) {
                        buf += '.'
                    }
                    buf += line(i)
                    b = b - 1
                } else {
                    if (line(i) == '.') {
                        ex_point = true
                    } else {
                        buf += line(i)
                    }
                }
            }
        }

        var pos: Int = 0
        // println(buf)
        loop.breakable {
            for (i <- 0 until buf.length()) {
                var j = buf.length() - i - 1;
                if (buf(j) == '.') {
                    pos = j
                    loop.break
                }
                if (buf(j) != '0') {
                    pos = j + 1
                    loop.break
                }
            }
        }
        // println("pos " + pos)
        var flag = false

        for (i <- 0 until pos) {
            if (flag == true) {
                if (buf(i) == '.' && i == buf.length()-1) {
                } else {
                    print(buf(i))
                }
            } else {
                if (buf(i) != '0') {
                    print(buf(i))
                    flag = true
                } else if (buf(i + 1) == '.' ) {
                    print(buf(i));
                    flag = true
                }
            }
        }
        println()
    }
}

import scala.io.StdIn._
import scala.util.control._

object cf697B {
    def main (args: Array[String]) {
        val line = readLine()

        var b:Int = 0;
        var ex_e = false

        for (i <- 0 until line.length()) {
            if (ex_e == true) {
                b = b * 10 + line(i) - '0'
            }
            if (line(i) == 'e') ex_e = true
        }

        // println(b)
        var ex_point = false
        var buf = new StringBuilder()

        var loop = new Breaks
        loop.breakable {
            for (i <- 0 until line.length()) {
                if (line(i) == 'e') {
                    while (b > 0) {
                        buf += '0'
                        b = b - 1
                    }
                    loop.break
                }

                if (ex_point == true) {
                    if (b == 0) {
                        buf += '.'
                    }
                    buf += line(i)
                    b = b - 1
                } else {
                    if (line(i) == '.') {
                        ex_point = true
                    } else {
                        buf += line(i)
                    }
                }
            }
        }

        var pos: Int = 0
        // println(buf)
        loop.breakable {
            for (i <- 0 until buf.length()) {
                var j = buf.length() - i - 1;
                if (buf(j) != '0') {
                    pos = j
                    loop.break;
                }
            }
        }
        // println("pos " + pos)
        var flag = false

        for (i <- 0 until pos) {
            if (flag == true) {
                if (buf(i) == '.' && i == buf.length()-1) {
                } else {
                    print(buf(i))
                }
            } else {
                if (buf(i) != '0') {
                    print(buf(i))
                    flag = true
                } else if (buf(i + 1) == '.' ) {
                    print(buf(i));
                    flag = true
                }
            }
        }
        println()
/*
        val loop = new Breaks;
        loop.breakable {
            for (i <- 0 until buf.length()) {
                if (buf(i) == 'e') loop.break
                print(buf(i))
            }
            println()
        }
*/

    }
}

import scala.io.StdIn._
import scala.util.control._

object cf697B {
    def main (args: Array[String]) {
        val line = readLine()

        var b:Int = 0;
        var ex_e = false

        for (i <- 0 until line.length()) {
            if (ex_e == true) {
                b = b * 10 + line(i) - '0'
            }
            if (line(i) == 'e') ex_e = true
        }

        // println(b)
        var ex_point = false
        var buf = new StringBuilder()

        var loop = new Breaks
        loop.breakable {
            for (i <- 0 until line.length()) {
                if (line(i) == 'e') {
                    while (b > 0) {
                        buf += '0'
                        b = b - 1
                    }
                    loop.break
                }

                if (ex_point == true) {
                    if (b == 0) {
                        buf += '.'
                    }
                    buf += line(i)
                    b = b - 1
                } else {
                    if (line(i) == '.') {
                        ex_point = true
                    } else {
                        buf += line(i)
                    }
                }
            }
        }

        // println(buf)

        var flag = false

        for (i <- 0 until buf.length()) {
            if (flag == true) {
                if (buf(i) == '.' && i == buf.length()-1) {
                } else {
                    print(buf(i))
                }
            } else {
                if (buf(i) != '0') {
                    print(buf(i))
                    flag = true
                } else if (buf(i + 1) == '.' ) {
                    print(buf(i));
                    flag = true
                }
            }
        }
        println()
/*
        val loop = new Breaks;
        loop.breakable {
            for (i <- 0 until buf.length()) {
                if (buf(i) == 'e') loop.break
                print(buf(i))
            }
            println()
        }
*/

    }
}

import scala.io.StdIn._
import scala.util.control._

object cf697B {
    def main (args: Array[String]) {
        val line = readLine()

        var b:Int = 0;
        var ex_e = false

        for (i <- 0 until line.length()) {
            if (ex_e == true) {
                b = b * 10 + line(i) - '0'
            }
            if (line(i) == 'e') ex_e = true
        }

        // println(b)
        var ex_point = false
        var buf = new StringBuilder()

        var loop = new Breaks
        loop.breakable {
            for (i <- 0 until line.length()) {
                if (line(i) == 'e') {
                    while (b > 0) {
                        buf += '0'
                        b = b - 1
                    }
                    loop.break
                }

                if (ex_point == true) {
                    if (b == 0) {
                        buf += '.'
                    }
                    buf += line(i)
                    b = b - 1
                } else {
                    if (line(i) == '.') {
                        ex_point = true
                    } else {
                        buf += line(i)
                    }
                }
            }
        }

        var pos: Int = 0
        // println(buf)
        loop.breakable {
            for (i <- 0 until buf.length()) {
                var j = buf.length() - i - 1;
                if (buf(j) == '.') {
                    pos = j
                    loop.break
                }
                if (buf(j) != '0') {
                    pos = j + 1
                    loop.break
                }
            }
        }
        // println("pos " + pos)
        var flag = false

        for (i <- 0 until pos) {
            if (flag == true) {
                if (buf(i) == '.' && i == buf.length()-1) {
                } else {
                    print(buf(i))
                }
            } else {
                if (buf(i) != '0') {
                    print(buf(i))
                    flag = true
                } else if (buf(i + 1) == '.' ) {
                    print(buf(i));
                    flag = true
                }
            }
        }
        println()
    }
}

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val line = in.next()
  val Array(ns, es) = line.split('e')
  val n = ns.toDouble
  val e = es.toInt
  val ans = n * Math.pow(10, e)
  if (ans == ans.toInt)
    println(ans.toInt)
  else
    println(ans)
}

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val line = in.next()
  val Array(ns, es) = line.split('e')
  val n = ns.toDouble
  val e = es.toInt
  println(n * Math.pow(10, e))
}

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val line = in.next()
  val Array(ns, es) = line.split('e')
  val n = ns.filter(_ != '.')
  val eee = ns.indexOf('.')
  val ee = if (eee == -1) 0 else eee
  val e = es.toInt + ee + n.reverse.takeWhile(_ == '0').length
  val ne = n.reverse.dropWhile(_ == '0').reverse

  if (e == ne.length)
    println(ne)
  else if (e < ne.length)
    println(ne.take(e) + '.' + n.drop(e))
  else
    println(ne + "0" * (e - ne.length))
}

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val line = in.next()
  val Array(ns, es) = line.split('e')
  val (ne, ee) = ns.split('.') match {
    case Array(before, after) =>
      val afterDrop = after.reverse.dropWhile(_ == 0).reverse
      (before + afterDrop, -afterDrop.length)
    case Array(before) => (before, 0)
  }
  val e = ee + es.toInt

  if (e == 0)
    println(ne)
  else if (e < ne.length)
    println(ne.take(ne.length + e) + '.' + ne.drop(ne.length + e))
  else
    println(ne + "0" * (e - ne.length))
}

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val line = in.next()
  val Array(ns, es) = line.split('e')
  val (ne, ee) = ns.split('.') match {
    case Array(before, after) =>
      val afterDrop = after.reverse.dropWhile(_ == 0).reverse
      (before + afterDrop, -afterDrop.length)
    case Array(before) => (before, 0)
  }
  val e = ee + es.toInt

  println(e)

  if (e == 0)
    println(ne)
  else if (e < 0)
    println(ne.take(ne.length + e) + '.' + ne.drop(ne.length + e))
  else
    println(ne + "0" * e)
}

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val line = in.next()
  val Array(ns, es) = line.split('e')
  val (ne, ee) = ns.split('.') match {
    case Array(before, after) =>
      val afterDrop = after.reverse.dropWhile(_ == 0).reverse
      (before + afterDrop, -afterDrop.length)
    case Array(before) => (before, 0)
  }
  val e = ee + es.toInt
  if (e == ne.length)
    println(ne)
  else if (e < ne.length)
    println(ne.take(ne.length + e) + '.' + ne.drop(ne.length + e))
  else
    println(ne + "0" * (e - ne.length))
}

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val line = in.next()
  val Array(ns, es) = line.split('e')
  val (ne, ee) = ns.split('.') match {
    case Array(before, after) =>
      val afterDrop = after.reverse.dropWhile(_ == 0).reverse
      (before + afterDrop, -afterDrop.length)
    case Array(before) => (before, 0)
  }
  val e = ee + es.toInt

  println(e)

  if (e == ne.length)
    println(ne)
  else if (e < ne.length)
    println(ne.take(ne.length + e) + '.' + ne.drop(ne.length + e))
  else
    println(ne + "0" * (e - ne.length))
}

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val line = in.next()
  val Array(ns, es) = line.split('e')
  val n = ns.filter(_ != '.')
  val eee = ns.indexOf('.')
  val ee = if (eee == -1) 0 else eee
  val e = es.toInt + ee
  println(n.take(e) + '.' + n.drop(e))
}

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val line = in.next()
  val Array(ns, es) = line.split('e')
  val n = ns.filter(_ != '.')
  val eee = ns.indexOf('.')
  val ee = if (eee == -1) 0 else eee
  val e = es.toInt - ee + n.reverse.takeWhile(_ == '0').length
  val ne = n.reverse.dropWhile(_ == '0').reverse

  if (e == ne.length)
    println(ne)
  else if (e < ne.length)
    println(ne.take(e) + '.' + n.drop(e))
  else
    println(ne + "0" * (e - ne.length))
}

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val line = in.next()
  val Array(ns, es) = line.split('e')
  val (ne, ee) = ns.split('.') match {
    case Array(before, after) =>
      val afterDrop = after.reverse.dropWhile(_ == 0).reverse
      (before + afterDrop, -afterDrop.length)
    case Array(before) => (before, 0)
  }
  val e = ee + es.toInt

  if (e == 0)
    println(ne)
  else if (e < 0)
    println(ne.take(ne.length + e) + '.' + ne.drop(ne.length + e))
  else
    println(ne + "0" * e)
}

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val line = in.next()
  val Array(ns, es) = line.split('e')
  val (ne, ee) = ns.split('.') match {
    case Array(before, after) =>
      val afterDrop = after.reverse.dropWhile(_ == 0).reverse
      (before + afterDrop, -afterDrop.length)
    case Array(before) => (before, 0)
  }
  val e = ee + es.toInt

  println(e)

  if (e == 0)
    println(ne)
  else if (e < ne.length)
    println(ne.take(ne.length + e) + '.' + ne.drop(ne.length + e))
  else
    println(ne + "0" * (e - ne.length))
}

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val line = in.next()
  val Array(ns, es) = line.split('e')
  val n = ns.filter(_ != '.')
  val eee = ns.indexOf('.')
  val ee = if (eee == -1) 0 else eee
  val e = es.toInt + ee + n.reverse.takeWhile(_ == '0').length
  val ne = n.reverse.dropWhile(_ == '0').reverse

  if (e == ne.length)
    println(ne)
  else if (e < ne.length)
    println(ne.take(e) + '.' + n.drop(e))
  else
    println(ne + "0" * (e - ne.length + 1))
}