The bear decided to store some raspberry for the winter. He cunningly found out the price for a barrel of honey in kilos of raspberry for each of the following n days. According to the bear's data, on the i-th (1 ≤ i ≤ n) day, the price for one barrel of honey is going to is xi kilos of raspberry.Unfortunately, the bear has neither a honey barrel, nor the raspberry. At the same time, the bear's got a friend who is ready to lend him a barrel of honey for exactly one day for c kilograms of raspberry. That's why the bear came up with a smart plan. He wants to choose some day d (1 ≤ d < n), lent a barrel of honey and immediately (on day d) sell it according to a daily exchange rate. The next day (d + 1) the bear wants to buy a new barrel of honey according to a daily exchange rate (as he's got some raspberry left from selling the previous barrel) and immediately (on day d + 1) give his friend the borrowed barrel of honey as well as c kilograms of raspberry for renting the barrel.The bear wants to execute his plan at most once and then hibernate. What maximum number of kilograms of raspberry can he earn? Note that if at some point of the plan the bear runs out of the raspberry, then he won't execute such a plan.

The first line contains two space-separated integers, n and c (2 ≤ n ≤ 100, 0 ≤ c ≤ 100), — the number of days and the number of kilos of raspberry that the bear should give for borrowing the barrel. The second line contains n space-separated integers x1, x2, ..., xn (0 ≤ xi ≤ 100), the price of a honey barrel on day i.

Print a single integer — the answer to the problem.

NoteIn the first sample the bear will lend a honey barrel at day 3 and then sell it for 7. Then the bear will buy a barrel for 3 and return it to the friend. So, the profit is (7 - 3 - 1) = 3.In the second sample bear will lend a honey barrel at day 1 and then sell it for 100. Then the bear buy the barrel for 1 at the day 2. So, the profit is (100 - 1 - 2) = 97.

import scala.io.StdIn

object BearAndRaspberryMain {
  def main(args: Array[String]): Unit ={
    val nc = StdIn.readLine().split(" ").map(_.toInt)
    val n = nc(0)
    val c = nc(1)
    val elements = StdIn.readLine().split(" ").map(_.toInt)
    var LOL = 0
    for(i <- 0 to n-2){
      val d  =  elements(i) - c - elements(i+1)
      if( LOL < d)
        LOL = d
    }
    print(LOL)
  }
}

import java.util.StringTokenizer

object _385A extends App {
  var token = new StringTokenizer("")
  def next = {
    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)
    token.nextToken()
  }
  val n = next.toInt
  val c = next.toInt
  val a = (1 to n).map(i => next.toInt)
  val b = (1 until n).map(i => a(i - 1) - a(i)).max
  val ans = (b - c) max 0
  println(ans)
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, c) = in.next().split(" ").map(_.toInt)
  val ans = Math.max(0, in.next().split(" ").map(_.toInt).sliding(2).map(t => t.head - t.last - c).max)
  println(ans)
}

import java.util.Scanner

object P385A {
    def main(args: Array[String]) {
        val scanner = new Scanner(System.in)
        val n = scanner.nextInt()
        val c = scanner.nextInt()
        val prices = for (i <- 1 to n) yield scanner.nextInt()
        val gains = for ((prev, next) <- prices.init zip prices.tail) yield prev - next - c
        val ans = if (gains.max > 0) gains.max else 0
        println(ans)
    }
}

object A385 {

  import IO._

  def main(args: Array[String]): Unit = {
    val Array(n, c) = readInts(2)
    val in = readInts(n)
    var res = 0
    for(i <- 0 until n-1) {
      val cal = in(i) - in(i+1) - c
      res = math.max(res, cal)
    }
    println(res)
  }

  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 P385A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)
  val N, C = sc.nextInt
  val X = List.fill(N)(sc.nextInt)

  val gain = (X, X.tail).zipped.map(_ - _).max - C
  val answer = if (gain > 0) gain
               else 0

  out.println(answer)
  out.close
}

//package codeforces

/**
 * TODO: describe
 *
 * @author keks
 */
object T385A {
  def main(args: Array[String]) {
    val rent = readArray.last
    print(getRasp(readArray, rent))
  }

  def getRasp(a: Array[Int], rent: Int) = {
    val total = ((0, a.head) /: a.tail)(
      (acc, prev) => (if (acc._1 < acc._2 - prev) acc._2 - prev else acc._1, prev)
    )._1
    if (total > rent) total - rent else 0
  }

  def readArray = readLine().split(' ').map(_.toInt)
}

object A extends App {
  val sc = new java.util.Scanner(System.in)
  val n, c = sc.nextInt()
  val x = Array.fill(n)(sc.nextInt())
  var ans = 0
  for (i <- 0 until n-1) {
    ans = ans.max(x(i)-x(i+1)-c)
  }
  println(ans)
}


The translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (and pronounced) reversely. For example, a Berlandish word code corresponds to a Birlandish word edoc. However, it's easy to make a mistake during the «translation». Vasya translated word s from Berlandish into Birlandish as t. Help him: find out if he translated the word correctly.

The first line contains word s, the second line contains word t. The words consist of lowercase Latin letters. The input data do not consist unnecessary spaces. The words are not empty and their lengths do not exceed 100 symbols.

If the word t is a word s, written reversely, print YES, otherwise print NO.

object P041A extends App {
  val t = readLine()
  val s = readLine()
  println(if (t.reverse == s) "YES" else "NO")
}

object Translation extends App{
    val berlandish = scala.io.StdIn.readLine()
    val birlandish = scala.io.StdIn.readLine()

    if (birlandish.reverse == berlandish) println("YES")
    else println("NO")

}

object Main extends App {
  val str1 = readLine()
  val str2 = readLine()

  if (str1 == str2.reverse) println("YES")
  else println("NO")
}

object CF0041A extends App {

  val f = readLine()
  val s = readLine()

  if( f == s.reverse) {
    println("YES")
  } else {
    println("NO")
  }

}

object Solver {
    def main(args: Array[String]) {
        val (first, second) = (Console.readLine, Console.readLine)
        val success = first.length == second.length && List.range(0, first.length).forall(i => first(i) == second(first.length - i - 1))

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

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  var str = in.next()
  var str2 = in.next()
  if (str.length != str2.length || str.zip(str2.reverse).exists(t => t._1 != t._2))
    println("NO")
  else
    println("YES")
}

object Main {

  def main(args: Array[String]) {
    val std = scala.io.StdIn

    val areTheSame = std.readLine().equals(std.readLine().reverse)
    if (areTheSame) {
      println("YES")
    }
    else {
      println("NO")
    }
  }
}

object A41 {
  @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 input1 = scala.io.StdIn.readLine
    val input2 = scala.io.StdIn.readLine
    if(input1.reverse.compareTo(input2) == 0) {
      println("YES")
    } else {
      println("NO")
    }
  }
}

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

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

  val S, T = sc.nextLine
  val answer = if (S == T.reverse) "YES" else "NO"

  out.println(answer)
  out.close
}

object Translation {
	def main (args: Array[String]) {
		val scanner = new java.util.Scanner(System.in);
		val word1 = scanner.nextLine;
		val word2 = scanner.nextLine;
		var leftIndex = 0;
		var rightIndex = word2.length - 1;
		var equal = true;
		while (equal && leftIndex < word1.length() && rightIndex >= 0) {
			equal = word1(leftIndex) == word2(rightIndex)
			leftIndex += 1; rightIndex-=1
		}
		if (equal) {
			println("YES")
		}
		else
			println("NO")
	}
}

import scala.io._
import scala.collection.mutable._
import java.io.FileWriter
import java.io.PrintWriter

object HelloWorld {

  def main(args: Array[String]): Unit = {
    var t = readLine;
    var s = readLine;
    if (t == s.reverse) {
      println("YES");
    } else {
      println("NO");
    }
  }
}

import annotation.tailrec
import java.io._

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

  def ans = if(reader.readLine() == reader.readLine().reverse) "YES" else "NO"

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

object Main {
  def main(args: Array[String]) {
    val s1 = readLine()
    val s2 = readLine()
    if (s1.reverse == s2) println("YES")
    else println("NO")
  }
}

import scala.io.StdIn._

object A_41 extends App {
  val a = readLine()
  val b = readLine()

  println(
    if (a == b.reverse) "YES" else "NO"
  )
}

import scala.io.StdIn.readLine
object problem {
  def main(args: Array[String]) {
  val s = readLine
  val t = readLine
    if(t == s.reverse) println("YES") else println("NO")
  }
}

import java.util.Scanner

object HelloWorldMain {

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)

    val str = sc.next()

    val strShouldBeReverse = sc.next()

    if(str.reverse equalsIgnoreCase strShouldBeReverse )println("YES")
    else println("NO")

  }
}

import scala.io.StdIn.readLine
import scala.io.StdIn.readInt

object Translation {

   def readInts() : Array[Int] =
     readLine.split(' ').map(_.toInt)

   def main(args: Array[String]) {
     val s = readLine
     val t = readLine
     if (s == t.reverse) println("YES") else println("NO")
   }

}

import java.util.Scanner

object TEST extends App{
    val sc = new Scanner(System.in)
    print (if(readLine.reverse == readLine)"YES" else "NO")
}

import scala.io.StdIn._

object Task extends App{
  val w1 = readLine
  val w2 = readLine

  if(w1.reverse == w2)
    println("YES")
  else
    println("NO")
}

import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    if (StdIn.readLine() == StdIn.readLine().reverse) println("YES") else println("NO")
  }
}

object P041A extends App {
  val t = readLine()
  val s = readLine()
  println(if (t.reverse == s) "YES" else "No")
}


A magic number is a number formed by concatenation of numbers 1, 14 and 144. We can use each of these numbers any number of times. Therefore 14144, 141414 and 1411 are magic numbers but 1444, 514 and 414 are not.You're given a number. Determine if it is a magic number or not.

The first line of input contains an integer n, (1 ≤ n ≤ 109). This number doesn't contain leading zeros.

Print "YES" if n is a magic number or print "NO" if it's not.

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val str = in.next()
  if (str.forall(ch => ch == '1' || ch == '4') &&
      str.head != '4' && !str.contains("444"))
    println("YES")
  else
    println("NO")
}

object A320 {

  import IO._

  def main(args: Array[String]): Unit = {
    val num = read
    val dummy = Array.fill[Char](num.length)('x').mkString("")
    val res = num.replaceAll("144", "xxx").replaceAll("14", "xx").replaceAll("1", "x")
    if(res.equals(dummy)) {
      println("YES")
    } else {
      println("NO")
    }
  }

  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 P320A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  def solve(): String = {

    @tailrec
    def loop(cs: List[Char]): String = cs match {
        case Nil                 => "YES"
        case '1' :: '4' :: '4' :: rest => loop(rest)
        case '1' :: '4' :: rest        => loop(rest)
        case '1' :: rest               => loop(rest)
        case _                         => "NO"
      }

    loop(sc.nextLine.toList)
  }

  out.println(solve)
  out.close
}

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)

  val ans = reader.readLine().matches("(14{0,2})+")
  val yesNoAns = Map(true -> "YES", false -> "NO")

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

object Main {
  def main(args: Array[String]) {
    val s = readLine()
    val r = s.replaceAll("144", "a").replaceAll("14", "a").replaceAll("1", "a")
    if (r.matches("a*")) println("YES")
    else println("NO")
  }
}

object CF320A extends App {
    override def main(args: Array[String]) {
      val s:String = readLine()
      var i = 0
      while (i < s.length()) {
        if (i+3 <= s.length() && s.substring(i, i+3) == "144")
          i += 3
        else if (i + 2 <= s.length() && s.substring(i, i+2) == "14") i += 2
        else if (s.charAt(i) == '1') i += 1
        else {
          println("NO")
          return
        }
      }
      println("YES")
    }
}

object MagicNumbers {
   def main(args:Array[String]):Unit={
     val str=readLine
     println(solve(str))
   }
  def solve(str:String):String={
//    str.toCharArray.toList match {
//      case("144"::string)=> solve(string)
//      case ("14"::string)=>solve(string)
//      case("1"::string)=>solve(string)
//      case(str.length==0)=>"YES"
//      case(_)=>"NO"
//    }
    if(str.startsWith("144")) solve(str.substring(3))
    else if(str.startsWith("14")) solve(str.substring(2))
    else if(str.startsWith("1")) solve(str.substring(1))
    else if(str.length==0) "YES"
    else "NO"
  }
}

import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val string = StdIn.readLine()
    val valuesOtherThanOneOrFour = string.exists(char => char != '1' && char != '4')
    val startsWithValueOtherThanOne = !string.startsWith("1")
    val containsThreeConsecutiveFours = string.indexOf("444") != -1
    if (valuesOtherThanOneOrFour || startsWithValueOtherThanOne || containsThreeConsecutiveFours) println("NO") else println("YES")
  }
}

object A320 {

  import IO._

  def main(args: Array[String]): Unit = {
    val num = read
    if(num.replaceAll("144", "").replaceAll("14", "").replaceAll("1", "").isEmpty) {
      println("YES")
    } else {
      println("NO")
    }
  }

  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 {
  def main(args: Array[String]) {
    val s = readLine()
    val r = s.replaceAll("144", "").replaceAll("14", "").replaceAll("1", "")
    if (r.size == 0) println("YES")
    else println("NO")
  }
}

import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    if (StdIn.readLine.forall(char => char == '4' || char == '1')) print("YES") else print("NO")
  }
}

import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    var string = StdIn.readLine()
    while (string.contains("144")) {
      string = string.replace("144", "")
    }
    while (string.contains("14")) {
      string = string.replace("14", "")
    }
    if (string.forall(_ == '1')) println("YES") else println("NO")
  }
}

import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val string = StdIn.readLine()
    if (string.exists(char => char != '4' && char != '1') || !string.startsWith("1")) print("NO") else print("YES")
  }
}


The math faculty of Berland State University has suffered the sudden drop in the math skills of enrolling students. This year the highest grade on the entrance math test was 8. Out of 100! Thus, the decision was made to make the test easier.Future students will be asked just a single question. They are given a sequence of integer numbers $$$a_1, a_2, \dots, a_n$$$, each number is from $$$1$$$ to $$$3$$$ and $$$a_i \ne a_{i + 1}$$$ for each valid $$$i$$$. The $$$i$$$-th number represents a type of the $$$i$$$-th figure:  circle;  isosceles triangle with the length of height equal to the length of base;  square. The figures of the given sequence are placed somewhere on a Cartesian plane in such a way that:  $$$(i + 1)$$$-th figure is inscribed into the $$$i$$$-th one;  each triangle base is parallel to OX;  the triangle is oriented in such a way that the vertex opposite to its base is at the top;  each square sides are parallel to the axes;  for each $$$i$$$ from $$$2$$$ to $$$n$$$ figure $$$i$$$ has the maximum possible length of side for triangle and square and maximum radius for circle. Note that the construction is unique for some fixed position and size of just the first figure.The task is to calculate the number of distinct points (not necessarily with integer coordinates) where figures touch. The trick is, however, that the number is sometimes infinite. But that won't make the task difficult for you, will it?So can you pass the math test and enroll into Berland State University?

The first line contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the number of figures. The second line contains $$$n$$$ integer numbers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 3$$$, $$$a_i \ne a_{i + 1}$$$) — types of the figures.

The first line should contain either the word "Infinite" if the number of distinct points where figures touch is infinite or "Finite" otherwise. If the number is finite than print it in the second line. It's guaranteed that the number fits into 32-bit integer type.

NoteHere are the glorious pictures for the examples. Note that the triangle is not equilateral but just isosceles with the length of height equal to the length of base. Thus it fits into a square in a unique way.The distinct points where figures touch are marked red.In the second example the triangle and the square touch each other for the whole segment, it contains infinite number of points.

object Main {
  import java.io.{BufferedReader, InputStream, InputStreamReader}
  import java.util.StringTokenizer
  import scala.reflect.ClassTag

  def main(args: Array[String]): Unit = {
    val out = new java.io.PrintWriter(System.out)
    new Main(out, new InputReader(System.in)).solve()
    out.flush()
  }

  private val oj = System.getenv("ATCODER_DEBUG") == null
  def DEBUG(f: => Unit): Unit = {
    if (!oj){ f }
  }
  def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) "1" else "0").mkString) }
  def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(" ")) }
  def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(" ")) }
  def debugDim(m: Array[Array[Long]]): Unit = if (!oj){
    REP(m.length) { i =>
      debug(m(i))
    }
  }
  def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){
    REP(m(0).length) { j =>
      REP(m.length) { i =>
        System.err.print(m(i)(j))
        System.err.print(" ")
      }
      System.err.println()
    }
  }
  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 = Integer.parseInt(next())
    def nextLong(): Long = java.lang.Long.parseLong(next())
    def nextChar(): Char = next().charAt(0)

    def ni(): Int = nextInt()
    def nl(): Long = nextLong()
    def nc(): Char = nextChar()
    def ns(): String = 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]): Array[Long] = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

class Main(out: java.io.PrintWriter, sc: Main.InputReader) {
  import sc._
  import Main._
  import java.util.Arrays.sort

  import scala.collection.mutable
  import math.{abs, max, min}
  import mutable.ArrayBuffer

  // toIntとか+7とかするならvalにしろ
  @inline private def MOD = 1000000007

  def solve(): Unit = {
    val N = ni()
    val A = na(N)

    val Inf = 1e9.toInt
    var ans = sumL(map(N - 1) { i =>
      (A(i), A(i + 1)) match {
        case (1, 2) => 3
        case (1, 3) => 4
        case (2, 1) => 3
        case (2, 3) => Inf
        case (3, 1) => 4
        case (3, 2) => Inf
      }
    })

    ans += sumL(map(N - 2) { i =>
      (A(i), A(i + 1), A(i + 2)) match {
        case (3, 1, 2) => -1
        case _ => 0
      }
    })

    if (ans >= Inf) out.println("Infinite")
    else {
      out.println("Finite")
      out.println(ans)
    }
  }
}

object Main extends App {
    val n = readInt
    val a = readLine.split(" ").map(_.toInt)
    val result = a.foldLeft((0, 0, 0))((acc, next) => {
      if (acc._3 == -1) (0, 0, -1)
      else {
        (acc._1, acc._2,  next) match {
          case (3, 1, 2) => (acc._2, next, acc._3 + 2)
          case (_, 1, 2) => (acc._2, next, acc._3 + 3)
          case (_, 1, 3) => (acc._2, next, acc._3 + 4)
          case (_, 2, 1) => (acc._2, next, acc._3 + 3)
          case (_, 3, 1) => (acc._2, next, acc._3 + 4)
          case (_, 0, _) => (acc._2, next, 0)
          case _ => (0, 0, -1)
        }
      }
    })

    if (result._3 < 0) {
      println("Infinite")
    } else {
      println("Finite")
      println(result._3)
    }
}

import java.util.Scanner

import scala.io.StdIn

object Figures extends App {
  val line = new Scanner(StdIn.readLine())
  val n = line.nextInt()
  val a = StdIn.readLine().split(' ').map(_.toInt)
  var points = 0
  for(i <- 0 until n-1) {
    if (a(i) == 1) {
      if (a(i+1) == 2) {
        points += 3
      }
      if (a(i+1) == 3) {
        points += 4
      }
    }
    if (a(i) == 2) {
      if (a(i+1) == 1) {
        points += 3
      }
      if (a(i+1) == 3) {
        println("Infinite")
        System.exit(0)
      }
    }
    if (a(i) == 3) {
      if (a(i+1) == 1) {
        points += 4
        if (i+2 < n && a(i+2) == 2) {
          points -= 1
        }
      }
      if (a(i+1) == 2) {
        println("Infinite")
        System.exit(0)
      }
    }
  }
  println("Finite")
  println(points)

}

object Main {
  import java.io.{BufferedReader, InputStream, InputStreamReader}
  import java.util.StringTokenizer
  import scala.reflect.ClassTag

  def main(args: Array[String]): Unit = {
    val out = new java.io.PrintWriter(System.out)
    new Main(out, new InputReader(System.in)).solve()
    out.flush()
  }

  private val oj = System.getenv("ATCODER_DEBUG") == null
  def DEBUG(f: => Unit): Unit = {
    if (!oj){ f }
  }
  def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) "1" else "0").mkString) }
  def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(" ")) }
  def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(" ")) }
  def debugDim(m: Array[Array[Long]]): Unit = if (!oj){
    REP(m.length) { i =>
      debug(m(i))
    }
  }
  def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){
    REP(m(0).length) { j =>
      REP(m.length) { i =>
        System.err.print(m(i)(j))
        System.err.print(" ")
      }
      System.err.println()
    }
  }
  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 = Integer.parseInt(next())
    def nextLong(): Long = java.lang.Long.parseLong(next())
    def nextChar(): Char = next().charAt(0)

    def ni(): Int = nextInt()
    def nl(): Long = nextLong()
    def nc(): Char = nextChar()
    def ns(): String = 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]): Array[Long] = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

class Main(out: java.io.PrintWriter, sc: Main.InputReader) {
  import sc._
  import Main._
  import java.util.Arrays.sort

  import scala.collection.mutable
  import math.{abs, max, min}
  import mutable.ArrayBuffer

  // toIntとか+7とかするならvalにしろ
  @inline private def MOD = 1000000007

  def solve(): Unit = {
    val N = ni()
    val A = na(N)

    val Inf = 1e9.toInt
    val ans = sumL(map(N - 1) { i =>
      (A(i), A(i + 1)) match {
        case (1, 2) => 3
        case (1, 3) => 4
        case (2, 1) => 3
        case (2, 3) => Inf
        case (3, 1) => 4
        case (3, 2) => Inf
      }
    })

    if (ans >= Inf) out.println("Infinite")
    else {
      out.println("Finite")
      out.println(ans)
    }
  }
}

object Main extends App {
    val n = readInt
    val a = readLine.split(" ").map(_.toInt)
    val result = a.foldLeft((0, 0, 0))((acc, next) => {
      if (acc._3 == -1) (0, 0, -1)
      else {
        (acc._1, acc._2,  next) match {
          case (2, 1, 3) => (acc._2, next, acc._3 + 3)
          case (_, 1, 2) => (acc._2, next, acc._3 + 3)
          case (_, 1, 3) => (acc._2, next, acc._3 + 4)
          case (_, 2, 1) => (acc._2, next, acc._3 + 3)
          case (_, 3, 1) => (acc._2, next, acc._3 + 4)
          case (_, 0, _) => (acc._2, next, 0)
          case _ => (0, 0, -1)
        }
      }
    })

    if (result._3 < 0) {
      println("Infinite")
    } else {
      println("Finite")
      println(result._3)
    }
}

object Main extends App {
    val n = readInt
    val a = readLine.split(" ").map(_.toInt)
    val result = a.foldLeft((0, 0))((acc, next) => {
      if (acc._2 == -1) (0, -1)
      else {
        (acc._1, next) match {
          case (1, 2) => (next, acc._2 + 3)
          case (2, 1) => (next, acc._2 + 3)
          case (1, 3) => (next, acc._2 + 4)
          case (3, 1) => (next, acc._2 + 4)
          case (0, _) => (next, 0)
          case (_, _) => (0, -1)
        }
      }
    })

    if (result._2 < 0) {
      println("Infinite")
    } else {
      println("Finite")
      println(result._2)
    }
}


JATC's math teacher always gives the class some interesting math problems so that they don't get bored. Today the problem is as follows. Given an integer $$$n$$$, you can perform the following operations zero or more times:  mul $$$x$$$: multiplies $$$n$$$ by $$$x$$$ (where $$$x$$$ is an arbitrary positive integer).  sqrt: replaces $$$n$$$ with $$$\sqrt{n}$$$ (to apply this operation, $$$\sqrt{n}$$$ must be an integer). You can perform these operations as many times as you like. What is the minimum value of $$$n$$$, that can be achieved and what is the minimum number of operations, to achieve that minimum value?Apparently, no one in the class knows the answer to this problem, maybe you can help them?

The only line of the input contains a single integer $$$n$$$ ($$$1 \le n \le 10^6$$$) — the initial number.

Print two integers: the minimum integer $$$n$$$ that can be achieved using the described operations and the minimum number of operations required.

NoteIn the first example, you can apply the operation mul $$$5$$$ to get $$$100$$$ and then sqrt to get $$$10$$$.In the second example, you can first apply sqrt to get $$$72$$$, then mul $$$18$$$ to get $$$1296$$$ and finally two more sqrt and you get $$$6$$$.Note, that even if the initial value of $$$n$$$ is less or equal $$$10^6$$$, it can still become greater than $$$10^6$$$ after applying one or more operations.

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 = ni()
    if (N == 1) {
      out.println(s"1 0")
    } else {
      val f = factorize(N)
      val mul = f.keys.product
      val maxPow = f.values.max
      val minPow = f.values.min
      val lg = if (maxPow == 1 ) 0 else log2(maxPow - 1) + 1
      val cnt = lg + (if (minPow == maxPow && isPow2(maxPow)) 0 else 1)
      out.println(s"$mul $cnt")
    }
  }

  def isPow2(n: Int): Boolean = {
    Integer.highestOneBit(n) == n
  }

  /**
    * *注意* IntをLongにして使わないこと
    */
  def factorize(n: Int): mutable.Map[Int, Int] = {
    import scala.collection.mutable
    val res = mutable.Map[Int, Int]() withDefaultValue 0

    def minFactor(n0: Int, rt: Int, i: Int): Int = {
      if (i > rt) n0 // √n まで見つからなかったら n0は素数か1
      else if (n0 % i == 0) i
      else minFactor(n0, rt, i + 1)
    }

    def step(n0: Int): Unit = {
      minFactor(n0, math.sqrt(n0).toInt, 2) match {
        case 1 =>
        case f =>
          res(f) = res(f) + 1
          step(n0 / f)
      }
    }

    step(n)
    res
  }

  /**
    * log2して小数点切り捨てたもの
    */
  def log2(x: Int): Int = {
    var a = Integer.highestOneBit(x)
    var i = 0
    while(a > 1) {
      i += 1
      a >>>= 1
    }
    i
  }

  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 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[Int](as.length + 1)
    rep(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

//package codeforce520

import scala.collection.mutable.ArrayBuffer

object B {
  def main(args: Array[String]): Unit = {
    val reader = scala.io.StdIn

    val n = reader.readInt()

    val sieve = ArrayBuffer.fill(n + 1)(1)
    sieve(0) = 0
    sieve(1) = 0

    (2 until sieve.size) foreach {i =>
      if (sieve(i) == 1) {
        val j = i
        var c = 2
        while (j * c < sieve.size) {
          sieve(j * c) = 0
          c += 1
        }
      }
    }

    val prime = sieve.zipWithIndex.filter(_._1 == 1).map(_._2)

    val factor = prime.map{p =>
      var c = 0
      var t = n

      while (t % p == 0 && t > 0) {
        c += 1
        t = t / p
      }

      (p , c)
    }.filter(_._2 > 0)
    //println(factor.mkString(" "))

    val minValue = factor.map(_._1).foldLeft(1)(_ * _)
    val need1Operation = factor.map(_._2).toSet.size == 1
    var mult = true

    var maxP = if (factor.size > 0) factor.map(_._2).max else 0
    var minO = 0
    var pick = 1
    while(pick < maxP) {
      minO += 1
      pick *= 2
    }

    if (pick > maxP) {
      minO += 1
      mult = false
    }

    if (!need1Operation && mult == true) minO += 1

    if (n <= 3) {
      println(s"$n 0")
    }
    else {
      println(s"$minValue $minO")
    }

  }
}

import scala.collection.mutable
import scala.io.StdIn

object Codeforces1062B {

  def getMinimumOperation(n: Int): (Int, Int) = {
    val primeFactors = getPrimeFactorization(n)

    if (isUniquePrimeFactors(primeFactors))
      return (multiply(primeFactors.keys), 0)

    var totalSteps = 0

    val maxPower = primeFactors.values.max
    if (!isPowerOfTwo(maxPower) || !primeFactors.values.forall(_ == maxPower)) {
      totalSteps += 1
    }
    val powerOfTwo = getNextPowerOfTwo(maxPower)
    totalSteps += powerOfTwo

    (multiply(primeFactors.keys), totalSteps)
  }

  def isPowerOfTwo(n: Int): Boolean = (n & (n - 1)) == 0

  def getNextPowerOfTwo(n: Int): Int = {
    var poweredNumber = 2L
    var power = 1
    while (poweredNumber < n) {
      poweredNumber *= 2
      power += 1
    }
    power
  }

  def multiply(numbers: Iterable[Int]): Int = {
    var result = 1
    for (number <- numbers) result *= number
    result
  }

  def isUniquePrimeFactors(primeFactors: mutable.Map[Int, Int]): Boolean =
    primeFactors.values.forall(_ == 1)

  def getPrimeFactorization(n: Int): mutable.Map[Int, Int] = {
    val primeFactors = new mutable.HashMap[Int, Int]()
    var remainingNumber = n
    val sqrtN = math.sqrt(n).toInt
    for (primeCandidate <- 2 to sqrtN) {
      if (remainingNumber % primeCandidate == 0) {
        primeFactors(primeCandidate) = 0
        while (remainingNumber % primeCandidate == 0) {
          primeFactors(primeCandidate) += 1
          remainingNumber /= primeCandidate
        }
      }
    }

    if (remainingNumber != 1) {
      primeFactors(remainingNumber) = 1
    }

    primeFactors
  }

  def main(args: Array[String]): Unit = {
    val n = StdIn.readLine.trim.toInt

    val result = getMinimumOperation(n)

    println(s"${result._1} ${result._2}")
  }
}

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 = ni()
    if (N == 1) {
      out.println(s"1 0")
    } else {
      val f = factorize(N)
      val mul = f.keys.product
      val maxPow = f.values.max
      val minPow = f.values.min
      val lg = if (maxPow == 1 ) 0 else log2(maxPow - 1) + 1
      val cnt = lg + (if (minPow == maxPow) 0 else 1)
      out.println(s"$mul $cnt")
    }
  }

  /**
    * *注意* IntをLongにして使わないこと
    */
  def factorize(n: Int): mutable.Map[Int, Int] = {
    import scala.collection.mutable
    val res = mutable.Map[Int, Int]() withDefaultValue 0

    def minFactor(n0: Int, rt: Int, i: Int): Int = {
      if (i > rt) n0 // √n まで見つからなかったら n0は素数か1
      else if (n0 % i == 0) i
      else minFactor(n0, rt, i + 1)
    }

    def step(n0: Int): Unit = {
      minFactor(n0, math.sqrt(n0).toInt, 2) match {
        case 1 =>
        case f =>
          res(f) = res(f) + 1
          step(n0 / f)
      }
    }

    step(n)
    res
  }

  /**
    * log2して小数点切り捨てたもの
    */
  def log2(x: Int): Int = {
    var a = Integer.highestOneBit(x)
    var i = 0
    while(a > 1) {
      i += 1
      a >>>= 1
    }
    i
  }

  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 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[Int](as.length + 1)
    rep(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

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 = ni()
    if (N == 1) {
      out.println(s"1 0")
    } else {
      val f = factorize(N)
      val mul = f.keys.product
      val maxPow = f.values.max
      val minPow = f.values.min
      val cnt = log2(maxPow - 1) + 1 + (if (minPow == maxPow) 0 else 1)
      out.println(s"$mul $cnt")
    }
  }

  /**
    * *注意* IntをLongにして使わないこと
    */
  def factorize(n: Int): mutable.Map[Int, Int] = {
    import scala.collection.mutable
    val res = mutable.Map[Int, Int]() withDefaultValue 0

    def minFactor(n0: Int, rt: Int, i: Int): Int = {
      if (i > rt) n0 // √n まで見つからなかったら n0は素数か1
      else if (n0 % i == 0) i
      else minFactor(n0, rt, i + 1)
    }

    def step(n0: Int): Unit = {
      minFactor(n0, math.sqrt(n0).toInt, 2) match {
        case 1 =>
        case f =>
          res(f) = res(f) + 1
          step(n0 / f)
      }
    }

    step(n)
    res
  }

  /**
    * log2して小数点切り捨てたもの
    */
  def log2(x: Int): Int = {
    var a = Integer.highestOneBit(x)
    var i = 0
    while(a > 1) {
      i += 1
      a >>>= 1
    }
    i
  }

  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 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[Int](as.length + 1)
    rep(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

//package codeforce520

import scala.collection.mutable.ArrayBuffer

object B {
  def main(args: Array[String]): Unit = {
    val reader = scala.io.StdIn

    val n = reader.readInt()

    val sieve = ArrayBuffer.fill(n + 1)(1)
    sieve(0) = 0
    sieve(1) = 0

    (2 until sieve.size) foreach {i =>
      if (sieve(i) == 1) {
        val j = i
        var c = 2
        while (j * c < sieve.size) {
          sieve(j * c) = 0
          c += 1
        }
      }
    }

    val prime = sieve.zipWithIndex.filter(_._1 == 1).map(_._2)

    val factor = prime.map{p =>
      var c = 0
      var t = n

      while (t % p == 0 && t > 0) {
        c += 1
        t = t / p
      }

      (p , c)
    }.filter(_._2 > 0)
    //println(factor.mkString(" "))

    val minValue = factor.map(_._1).foldLeft(1)(_ * _)
    val need1Operation = factor.map(_._2).toSet.size == 1
    var mult = false

    var maxP = if (factor.size > 0) factor.map(_._2).max else 0
    var minO = 0
    var pick = 1
    while(pick < maxP) {
      minO += 1
      pick *= 2
    }

    if (pick > maxP) minO += 1

    if (!need1Operation || mult == true) minO += 1

    if (n <= 3) {
      println(s"$n 0")
    }
    else {
      println(s"$minValue $minO")
    }

  }
}

//package codeforce520

import scala.collection.mutable.ArrayBuffer

object B {
  def main(args: Array[String]): Unit = {
    val reader = scala.io.StdIn

    val n = reader.readInt()
    val length = (n + 1) / 2

    val sieve = ArrayBuffer.fill(length + 1)(1)
    sieve(0) = 0
    sieve(1) = 0

    (2 until sieve.size) foreach {i =>
      if (sieve(i) == 1) {
        val j = i
        var c = 2
        while (j * c < sieve.size) {
          sieve(j * c) = 0
          c += 1
        }
      }
    }

    val prime = sieve.zipWithIndex.filter(_._1 == 1).map(_._2)

    val factor = prime.map{p =>
      var c = 0
      var t = n
      while (t % p == 0 && t > 0) {
        c += 1
        t = t / p
      }

      (p , c)
    }.filter(_._2 > 0)

    val minValue = factor.map(_._1).foldLeft(1)(_ * _)
    val need1Operation = factor.map(_._2).toSet.size == 1
    var minOperation = (factor.map(_._2).max / 2)
    if (!need1Operation) minOperation += 1
    println(s"$minValue $minOperation")
  }
}

//package codeforce520

import scala.collection.mutable.ArrayBuffer

object B {
  def main(args: Array[String]): Unit = {
    val reader = scala.io.StdIn

    val n = reader.readInt()

    val sieve = ArrayBuffer.fill(n + 1)(1)
    sieve(0) = 0
    sieve(1) = 0

    (2 until sieve.size) foreach {i =>
      if (sieve(i) == 1) {
        val j = i
        var c = 2
        while (j * c < sieve.size) {
          sieve(j * c) = 0
          c += 1
        }
      }
    }

    val prime = sieve.zipWithIndex.filter(_._1 == 1).map(_._2)

    val factor = prime.map{p =>
      var c = 0
      var t = n

      while (t % p == 0 && t > 0) {
        c += 1
        t = t / p
      }

      (p , c)
    }.filter(_._2 > 0)
    //println(factor.mkString(" "))

    val minValue = factor.map(_._1).foldLeft(1)(_ * _)
    val need1Operation = factor.map(_._2).toSet.size == 1
    var mult = false

    var maxP = if (factor.size > 0) factor.map(_._2).max else 0
    var minO = 0
    while(maxP > 1) {
      if (maxP % 2 == 0) {
        maxP = maxP / 2
      }
      else {
        maxP = maxP - 1
        mult = true
      }
      minO += 1
    }

    if (!need1Operation || mult == true) minO += 1

    if (n <= 3) {
      println(s"$n 0")
    }
    else {
      println(s"$minValue $minO")
    }

  }
}

//package codeforce520

import scala.collection.mutable.ArrayBuffer

object B {
  def main(args: Array[String]): Unit = {
    val reader = scala.io.StdIn

    val n = reader.readInt()

    val sieve = ArrayBuffer.fill(n + 1)(1)
    sieve(0) = 0
    sieve(1) = 0

    (2 until sieve.size) foreach {i =>
      if (sieve(i) == 1) {
        val j = i
        var c = 2
        while (j * c < sieve.size) {
          sieve(j * c) = 0
          c += 1
        }
      }
    }

    val prime = sieve.zipWithIndex.filter(_._1 == 1).map(_._2)

    val factor = prime.map{p =>
      var c = 0
      var t = n

      while (t % p == 0 && t > 0) {
        c += 1
        t = t / p
      }

      (p , c)
    }.filter(_._2 > 0)
    //println(factor.mkString(" "))

    val minValue = factor.map(_._1).foldLeft(1)(_ * _)
    val need1Operation = factor.map(_._2).toSet.size == 1
    var mult = false

    var maxP = if (factor.size > 0) factor.map(_._2).max else 0
    var minO = 0
    while(maxP > 1) {
      if (maxP % 2 == 0) {
        maxP = maxP / 2
      }
      else {
        maxP = maxP - 1
        mult = true
      }
      minO += 1
    }

    if (!need1Operation || mult == true) minO += 1

    println(s"$minValue $minO")
  }
}

import scala.collection.mutable
import scala.io.StdIn

object Codeforces1062B {

  def getMinimumOperation(n: Int): (Int, Int) = {
    val primeFactors = getPrimeFactorization(n)

    var totalSteps = 0

    val maxPower = primeFactors.values.max
    if (!isPowerOfTwo(maxPower) || !primeFactors.values.forall(_ == maxPower)) {
      totalSteps += 1
    }
    val powerOfTwo = getNextPowerOfTwo(maxPower)
    totalSteps += powerOfTwo

    (multiply(primeFactors.keys), totalSteps)
  }

  def isPowerOfTwo(n: Int): Boolean = (n & (n - 1)) == 0

  def getNextPowerOfTwo(n: Int): Int = {
    var poweredNumber = 2L
    var power = 1
    while (poweredNumber < n) {
      poweredNumber *= 2
      power += 1
    }
    power
  }

  def multiply(numbers: Iterable[Int]): Int = {
    var result = 1
    for (number <- numbers) result *= number
    result
  }

  def isUniquePrimeFactors(primeFactors: mutable.Map[Int, Int]): Boolean =
    primeFactors.values.forall(_ == 1)

  def getPrimeFactorization(n: Int): mutable.Map[Int, Int] = {
    val primeFactors = new mutable.HashMap[Int, Int]()
    var remainingNumber = n
    val sqrtN = math.sqrt(n).toInt
    for (primeCandidate <- 2 to sqrtN) {
      if (remainingNumber % primeCandidate == 0) {
        primeFactors(primeCandidate) = 0
        while (remainingNumber % primeCandidate == 0) {
          primeFactors(primeCandidate) += 1
          remainingNumber /= primeCandidate
        }
      }
    }

    if (remainingNumber != 1) {
      primeFactors(remainingNumber) = 1
    }

    primeFactors
  }

  def main(args: Array[String]): Unit = {
    val n = StdIn.readLine.trim.toInt

    val result = getMinimumOperation(n)

    println(s"${result._1} ${result._2}")
  }
}


One day the Codeforces round author sat exams. He had n exams and he needed to get an integer from 2 to 5 for each exam. He will have to re-sit each failed exam, i.e. the exam that gets mark 2. The author would need to spend too much time and effort to make the sum of his marks strictly more than k. That could have spoilt the Codeforces round. On the other hand, if the sum of his marks is strictly less than k, the author's mum won't be pleased at all. The Codeforces authors are very smart and they always get the mark they choose themselves. Also, the Codeforces authors just hate re-sitting exams. Help the author and find the minimum number of exams he will have to re-sit if he passes the exams in the way that makes the sum of marks for all n exams equal exactly k.

The single input line contains space-separated integers n and k (1 ≤ n ≤ 50, 1 ≤ k ≤ 250) — the number of exams and the required sum of marks. It is guaranteed that there exists a way to pass n exams in the way that makes the sum of marks equal exactly k.

Print the single number — the minimum number of exams that the author will get a 2 for, considering that the sum of marks for all exams must equal k.

NoteIn the first sample the author has to get a 2 for all his exams.In the second sample he should get a 3 for two exams and a 2 for two more.In the third sample he should get a 3 for one exam.

import java.util.Scanner
import math.min
import math.max

object Main {

    def main(args:Array[String]) {
        val scanner = new Scanner(System.in)
        val n, k = scanner.nextInt()
        val ans = max (0, min (n, 3 * n - k))
        println (ans)
    }

}

// vim: set ts=4 sw=4 et:

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, k) = in.next().split(' ').map(_.toInt)
  val count = n - Math.min(n, k - 2 * n)
  println(count)
}

object A194 {

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

  def main(args: Array[String]): Unit = {
    var Array(n, k) = readInts(2)
    k -= 2*n
    if(k <= n) {
      println(n-k)
    } else {
      println("0")
    }
  }

  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 result = {
			val (n, k) = {
				val line = readLine()
				val sp = line.split(' ')
				val p = sp.map(Integer.parseInt(_))
				(p(0), p(1))
			}
			val lowest = k / n
			if (lowest > 2) 0
			else n*3 - k
		}
		print(result)
	}
}

import java.util._

object Main {

    def main(args: Array[String]) {
        val in = new Scanner(System.in)
        val n = in.nextInt
        val s = in.nextInt - 2 * n
        if (s >= n) {
            println(0)
        } else {
            println(n - s)
        }
    }

}

object Main {
  def main(args: Array[String]) {
    val Array(n, k) = readLine().split(" ").map(_.toInt)
    if (k / 3 >= n) println("0")
    else println(n - (k - (k / n) * n))
  }
}

object Main extends App{
  val in = readLine
  val Array(n, k)=in.split(' ').map(_.toInt)
  val count = n -Math.min(n, k -2* n)
  println(count)
}

object Main {
  def main(args: Array[String]) {
    val Array(n, k) = readLine().split(" ").map(_.toInt)
    if (k / 3 >= n) println("0")
    else println(n - (k - (k / 2) * 2))
  }
}


When preparing a tournament, Codeforces coordinators try treir best to make the first problem as easy as possible. This time the coordinator had chosen some problem and asked $$$n$$$ people about their opinions. Each person answered whether this problem is easy or hard.If at least one of these $$$n$$$ people has answered that the problem is hard, the coordinator decides to change the problem. For the given responses, check if the problem is easy enough.

The first line contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of people who were asked to give their opinions. The second line contains $$$n$$$ integers, each integer is either $$$0$$$ or $$$1$$$. If $$$i$$$-th integer is $$$0$$$, then $$$i$$$-th person thinks that the problem is easy; if it is $$$1$$$, then $$$i$$$-th person thinks that the problem is hard.

Print one word: "EASY" if the problem is easy according to all responses, or "HARD" if there is at least one person who thinks the problem is hard.  You may print every letter in any register: "EASY", "easy", "EaSY" and "eAsY" all will be processed correctly.

NoteIn the first example the third person says it's a hard problem, so it should be replaced.In the second example the problem easy for the only person, so it doesn't have to be replaced.

import scala.io.StdIn
object EasyProblem extends App
{
    val numOfPersons = StdIn.readInt()
    val input = StdIn.readLine().split(' ').map(_.toInt)
    var hard = 0
    for(i <- input.indices)
    {
        if(input(i) == 1)
        {
            hard += 1
        }
    }
    if(hard > 0)
    {
        println("HARD")
    } else println("EASY")
}

import scala.io.StdIn

object cf1030a {
  def main(args: Array[String]): Unit = {
    val _ = StdIn.readInt()
    val in = StdIn.readLine().split(' ').map(_.toInt)

    if (in.sum > 0) {
      println("HARD")
    } else {
      println("EASY")
    }
  }
}

import scala.io.StdIn.readLine

object A1030 {
  def main(args: Array[String]): Unit = {
    val _ = readLine
    val answer = if (Helper.readToListInts.contains(1)) "HARD" else "EASY"
    println(answer)
  }
}

object Helper {
  def readInt: Int = readLine.toInt
  def readToListInts: List[Int] = readLine.split(" ").map(_.toInt).toList
  def readToVectorInts: Vector[Int] = readLine.split(" ").map(_.toInt).toVector
}

import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val n = StdIn.readLine()
    val s = StdIn.readLine()
    if(solve(s)) println("HARD")
    else println("EASY")
  }

  def solve(s: String): Boolean = {
    s.contains('1')
  }
}

import io.StdIn._
object InSearchOfEasyproblem {

  def main(args: Array[String]): Unit = {
    var number = readInt()
    var inputs: Array[Int] = readLine().split(" ").map(t => s"$t".toInt)
    val answer = inputs.sum match {
      case 0 => "EASY"
      case _ => "HARD"
    }
    println(answer)
  }

}

object InSearchofanEasyProblem1030A extends App{
  import java.io.{InputStream, PrintStream}
  import java.util.Scanner
  solve(System.in,System.out)
  def solve(in: InputStream, out: PrintStream): Unit = {
    val scanner = new Scanner(in)
    val n = scanner.nextInt()
    val isHard = (1 to n).foldLeft(0){case (current,_) => current + scanner.nextInt()} > 0
    out.println(s"${if(isHard) "HARD" else  "EASY"}")

  }
}

import scala.io.StdIn

object Codeforces1030A extends App {
  val n = StdIn.readLine().toInt
  val hard = StdIn.readLine().split("\\s").map(n => n == "1")

  val allEasy = !hard.contains(true)

  printf(if (allEasy) "EASY" else "HARD")
}

import scala.io.StdIn

object Main2 extends App {
  val personNumber = StdIn.readInt()
  val difficulties = StdIn.readLine()
  println(if (difficulties.contains("1")) "hard" else "easy")
}

import scala.io.StdIn._

object TaskA extends App {
  readInt
  println(if (readLine.split(" ").contains("1")) "HARD" else "EASY")
}

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 = ni()
    val A = na(N)
    val ok = A.forall(_ == 0)
    val ans = if(ok) "EASY" else "HARD"
    out.println(ans)
  }

  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): Array[Int] = map(n)(_ => ni())
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm(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 map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

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

object A {
  def main(args: Array[String]) = {
    val n = scala.io.StdIn.readInt()
    if (scala.io.StdIn.readLine().split(" ").map(_.toInt).sum > 0) {
      System.out.println("HARD")
    } else {
      System.out.println("EASY")
    }
  }
}

import java.util.Scanner
import scala.io.StdIn
object Toto extends App {
  val n = StdIn.readInt()
  val data = new Scanner (StdIn.readLine())
  val hard =
    (1 to n).foldLeft(false) {
      (acc, _) =>
        val x = data.nextInt()
        acc || (x == 1)
    }
  if (hard){println("HARD")} else {println("EASY")}
}

import scala.io.StdIn._

object Solution {
	val n = readLine.toInt
	var r = readLine.split(" ").map(_.toInt)

	def main(args:Array[String]):Unit = {
		var response = "EASY"
		for(i <- 0 until n) {
			if(r(i) == 1) response = "HARD"
		}
		println(response)
	}
}

object Toto extends App {
  println("HARD")
}


Petya started to attend programming lessons. On the first lesson his task was to write a simple program. The program was supposed to do the following: in the given string, consisting if uppercase and lowercase Latin letters, it:   deletes all the vowels,  inserts a character "." before each consonant,  replaces all uppercase consonants with corresponding lowercase ones. Vowels are letters "A", "O", "Y", "E", "U", "I", and the rest are consonants. The program's input is exactly one string, it should return the output as a single string, resulting after the program's processing the initial string.Help Petya cope with this easy task.

The first line represents input string of Petya's program. This string only consists of uppercase and lowercase Latin letters and its length is from 1 to 100, inclusive.

Print the resulting string. It is guaranteed that this string is not empty.

object Main extends App{

    var t = readLine().toLowerCase().replaceAll("[aeyuio]","")
    t.foreach( (c) => print("." + c ) )

}

object JuanDavidRobles {
  def main(args: Array[String]): Unit = {

    import scala.io.StdIn

    var line : String = StdIn.readLine()

    var string : String = ""

    var char : Char = 'a'

    for (i <- 0 until line.length){
      char = line.charAt(i)
      if (!char.equals('a') && !char.equals('e') &&
        !char.equals('i') && !char.equals('o') &&
        !char.equals('u') && !char.equals('y') &&
        !char.equals('A') && !char.equals('E') &&
        !char.equals('I') && !char.equals('O') &&
        !char.equals('U') && !char.equals('Y')){

        if (char.toInt >= 65 && char <= 90){
          char = (char.toInt+32).toChar
        }
        string = string + "." + char.toString
      }
    }
    println(string)
  }
}

import scala.io.StdIn

object Main {

  val vowels = Array('A', 'I', 'U', 'E', 'O', 'Y')

  def isVowel(char: Char) : Boolean =  {
    vowels contains char
  }

  def main(args: Array[String]): Unit = {
    val s = StdIn.readLine()

    println(s.map(_.toUpper).filter(!isVowel(_)).map("."+ _.toLower).mkString)
  }
}

import scala.io.StdIn.readLine

object StringTask {

  def main(args: Array[String]) {
    val line = readLine
    println(line.toLowerCase()
        .filterNot { List('a','o','y','e','u','i').contains(_) }
        .flatMap { x => "." + x }
    )

  }

}

object Main extends App {
val vovels = List('a', 'i', 'u', 'e', 'o', 'y')
val s = readLine()
val res = s.toLowerCase.filter(!vovels.contains(_)).flatMap(x=>"." + x)
println(res)
}

object Main extends App {
  val help =List('a','e','o','u','i','y')
  println(readLine().toLowerCase.filterNot(help.contains).mkString(".",".",""))
}

object Main extends App {
  val vowels = List('A', 'O', 'Y', 'E', 'U', 'I') ++ List('a', 'o', 'y', 'e', 'u', 'i')
  def isVowel(c: Char): Boolean = vowels exists { _ == c }
  def isConsonant(c: Char): Boolean = !isVowel(c)
  def insertDot(c: Char): String = "."+ c
  def solve(s: String): String = s filterNot isVowel flatMap insertDot toLowerCase

  println(solve(readLine()))
}

object StringTask {
  val vowels = Array('a', 'e', 'i', 'o', 'u', 'y')

  def main(args: Array[String]) {
    val sb = new StringBuilder

    Console.readLine.foreach { ch =>
      val lower = ch.toLower
      if (!vowels.contains(lower)) {
        sb.append(".").append(lower)
      }
    }

    println(sb.toString)
  }
}

object test
{
    def main(args : Array[String])
    {
        print(readLine.toLowerCase.replaceAll("[aeiouy]","").map("."+_).mkString)
    }
}

object Main {

  def main(args: Array[String]): Unit = {
    println(readLine().map(_.toUpperCase).filter(!"AOYEUI".contains(_)).map("."+_.toLowerCase).reduce(_+_))
  }

}

object test {
	def main(args: Array[String]){
		print(readLine.toLowerCase.replaceAll("[aeiouy]","").map("."+_).mkString)
	}
}

import scala.io.StdIn._

object StringTask_118A extends App{
	val str = readLine
	val vowels = Set('a', 'e', 'i', 'o', 'u', 'y')

	println(str.map(_.toLower).filter(!vowels.contains(_)).flatMap("." + _))
}

import java.util.Scanner

/**
  * Created by Orhan on 3/7/2017.
  */
object StringTask extends App{
  val line = new Scanner(System.in)
  var word = line.next().toLowerCase()
  val vowels = Array("a", "o", "y", "e", "u", "i")
  print(word.split("").filter( w => !vowels.contains(w)).map(w => "." + w).mkString(""))
}

object StringTask {
  import io.StdIn.{readLine => rl}
  def rnum() = rl().split(" ").map(_.toLong)
  def main(args : Array[String]) {
    val iscons = (c:Char) => !"aoyeui".contains(c)
    println (rl.toLowerCase.filter(iscons).fold("")((h,t) => h + "." + t))
  }
}

object main extends App{
    var s = readLine.toLowerCase().replaceAll("[aeyuio]","")
    s.foreach((c) => print("." + c))
}

import java.util.Scanner

object A00118 extends App {
  println(Console.readLine().filterNot("aeiouyAEIOUY".contains(_)).map(x => "." + x).map(x => x.toLowerCase()).mkString)
}

object Main {
  def main(args: Array[String]): Unit = {
    val isVowel = Set('a', 'e', 'i', 'o', 'u', 'y')

    val line = readLine.toLowerCase

    val out1 = line.filterNot(isVowel)
    val out = out1 map {x => "."+x}
    println(out.mkString)
  }
}

object A {

  def main(args: Array[String]): Unit = {
    println(readLine().toLowerCase().replaceAll("[aoyeui]", "").map(s => "." + s).mkString(""))
  }

}

import scala.io.StdIn

object  Test {
  val vovels = "AOUYIE".toLowerCase.toCharArray
  def main(args1: Array[String]) {
//    val args = Console.readLine().split(" ")
//    val (v: Long, y: Long, z: Long) = (args(0).toLong, args(1).toLong, args(2).toLong)

      val line = StdIn.readLine
      val chars = line.toCharArray
      val res = chars.map(s => s.toLower).filter(s => !isVovel(s)).map(s => s".$s")

//    val res = balls.size
    res.foreach(print)
  }

  def isVovel(char: Char): Boolean = {
    return vovels.contains(char)
  }
}

object OneOneEightA {

	def main(args : Array[String]) : Unit = {
		var vovels=Array('a', 'o', 'y', 'e', 'u', 'i','A', 'O', 'Y', 'E', 'U', 'I')
		var input=readLine.toCharArray
		var strBuff=new StringBuilder
		for(i<-input){
			if(!vovels.contains(i)){
				strBuff.append("."+i.toLower)
			}
		}
		println(strBuff.toString)
	}
}

import scala.io.StdIn._

object StringTask {
  def main(args: Array[String]): Unit = {
    val vowels = Set('a', 'o', 'y', 'e', 'u', 'i')
    val s = readLine().toLowerCase().filter(x => !vowels.contains(x))
    val ans = s.map(x => "." + x).foldLeft("")((acc, x) => acc + x)
    println(ans)
  }
}

/*input
xnhcigytnqcmy
*/

import java.util.Scanner
import scala.io.StdIn

object Solution {
	def main(args: Array[String]): Unit = {

		val str = StdIn.readLine().map(_.toLower);
		str.foreach((x: Char) => {
			if(!("aeiouy".contains(x))) {
				print('.');
				print(x);
			}
		})

	}

}

object main extends App {
    var s = readLine().toLowerCase().replaceAll("([aoyeui])", "")
    s.foreach((c) => print("." + c))
}

object CF118A extends App {
    import scala.io.StdIn.readLine
    import scala.collection.immutable.HashSet
    val s = readLine.toLowerCase.toCharArray
    val vowels:HashSet[Char] = HashSet('a','e','i','o','u','y')
    s.filter(!vowels(_)).foreach(x => print("."+x.toString))
}

object StringTask extends App {

	val input = scala.io.StdIn.readLine().toLowerCase()

    val noVowel = input.replaceAll("([aeiouy])+", "")
    val output = noVowel.map(x => s".$x").mkString

	println(output)

}

object Main extends App {
  val inputString = readLine.toList

  def replaceLiterals(list: List[Char]): List[Char] = list match {
    case List() => List()
    case e :: rest =>
      e match {
        case 'a' | 'e' | 'i' | 'o' | 'u' |'y' | 'A' | 'E' | 'I' | 'O' | 'U' | 'Y' => replaceLiterals(rest)
        case _ => '.' :: e.toLower :: replaceLiterals(rest)
      }
  }

  println(replaceLiterals(inputString).mkString)
}

object Main extends App {
  val str = readLine().toList
  val vovels = "AOYEUIaoyeui"

  def helper(xs: List[Char]): List[Char] = xs match {
    case (x :: ys) if vovels.contains(x) => helper(ys)
    case (x :: ys)                => '.' :: x.toLower :: helper(ys)
    case _                        => Nil
  }

  println(helper(str).mkString)
}

object CF0118A extends App {

  val gl = List("a", "o", "y", "e", "u", "i")

  val str = readLine()

  var result = new StringBuilder

  for (ch <- str) {
    if (!(gl contains(ch.toString.toLowerCase))) {
      result ++= "." + ch.toString.toLowerCase
    }
  }

  println(result)

}

import scala.io.StdIn

/** A. String Task
  *
  * @author Yuichiroh Matsubayashi
  *         Created on 15/01/19.
  */
object P118A extends App {
  val vowels = Seq('a', 'o', 'y', 'e', 'u', 'i')
  val word = StdIn.readLine().toLowerCase

  def solution = word.filterNot(vowels.contains(_)).map(c => "." + c).mkString

  println(solution)
}

import java.io._

object Main {

  val in = new BufferedReader(new InputStreamReader(System.in))
  val out = new PrintWriter(System.out)
  sys.addShutdownHook(out.close())

  @inline def nextInt = in.readLine().toInt
  @inline def nextInts = in.readLine().split(" +").map(_.toInt)
  @inline def println[T](x: T) = out.println(x)

  def main(args: Array[String]): Unit = {
    val s = in.readLine()
    val ans = s.
      toLowerCase.
      replace("a","").
      replace("e","").
      replace("i","").
      replace("o","").
      replace("u","").
      replace("y","").
      mkString(".", ".", "")

    println(ans)

  }
}

object HelloWorld {
  def main(args: Array[String]): Unit = {
  	var s = readLine()
  	s = s.map(c => c.toLower)
  	s = s.replaceAll( "[eyuioa]", "")
  	var str = ""
  	for(i <-0 until s.length())
  		str = str + "." + s(i)
  	println(str)
  }
}

import scala.io.StdIn._

object task1 {
  def main(args: Array[String]): Unit = {
    val input = readLine()
    val letters = List('A', 'O', 'Y', 'E', 'U', 'I').map(_.toLower)
    val result = input.filterNot(el2 => letters.contains(el2.toLower)).map{ el =>
      s".$el"
    }.mkString("").toLowerCase
    println(result)
  }

}

object task158A {
  def stripChars(s:String, ch:String)= s filterNot (ch contains _)
  def main(args:Array[String]) {
    for (c<-stripChars(io.Source.stdin.getLines.toList(0).toLowerCase,"aoyeui")) {
      print("."+c)
    }
    println
  }
}

object pratise {
    def main(args : Array[String]) {
        val str = readLine().toLowerCase().replaceAll("([aoyeui])","")
        str.foreach(c => print("."+c))
    }
}

object cf extends App{
  val vowels = Set('a', 'e', 'i', 'o', 'u', 'y')
  var s = readLine().toLowerCase()
  var res = ""
  for (i <- 0 to s.length()-1) {
    if (!vowels(s(i))) {
      res += "." + s(i)
    }
  }
  println(res)
}

object StringTask extends App {
  val str = readLine().toLowerCase
  val vowels = List('a', 'e', 'o', 'u', 'y', 'i')
  val consonants = List('b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'z')

  def filterVowels(c: Char) = if (!vowels.contains(c)) true else false

  def mapConsonants(c: Char) = if (consonants.contains(c)) "." + c else c

  println(str.toList.filter(c => filterVowels(c)).map(c => mapConsonants(c)).mkString(""))
}

object Solution {
    val vowels = Array("A", "O", "Y", "E", "U", "I")
    def split(line: String) = line.grouped(1).toList
    def consonants(chars: List[String]) = chars filter (c => ! (vowels contains (c toUpperCase)))
    def withDots(chars: List[String]) = chars flatMap (c => Array(".", c))
    def solve(line: String) = withDots (consonants (split(line toLowerCase))) mkString
    def main(args: Array[String]) = println(solve(readLine))
}

object Solution {
    val vowels = Array("A", "O", "Y", "E", "U", "I")
    def split(line: String) = line grouped 1
    def consonants(chars: Iterator[String]) = chars filter (c => ! (vowels contains (c toUpperCase)))
    def withDots(chars: Iterator[String]) = chars flatMap (c => List(".", c))
    def solve(line: String) = withDots (consonants (split(line toLowerCase))) mkString
    def main(args: Array[String]) = println(solve(readLine))
}

object Solution {
    val vowels = Array("A", "O", "Y", "E", "U", "I") map (_ charAt 0)
    def isVowel(c: Char) = ! (vowels contains (Character.toUpperCase(c)))
    def consonants(chars: Seq[Char]) = chars filter isVowel
    def withDots(chars: Seq[Char]) = chars flatMap (c => List('.', c))
    def solve(line: String) = withDots(consonants(line.toLowerCase)).mkString
    def main(args: Array[String]) = println(solve(readLine))
}

object Solution {
    val vowels = Array("A", "O", "Y", "E", "U", "I") map (_ charAt 0)
    def isVowel(c: Char) = ! (vowels contains (Character.toUpperCase(c)))
    def consonants(chars: Seq[Char]) = chars filter isVowel
    def withDots(chars: Seq[Char]) = chars flatMap (c => List('.', c))
    def solve(line: String) = withDots (consonants (line toLowerCase)) mkString
    def main(args: Array[String]) = println(solve(readLine))
}

object Solution118A extends Application {

  def solution() {
    println(_string.toLowerCase.replaceAll("[aoyeui]", "").map(c => "." + c).mkString)
  }

  //////////////////////////////////////////////////
  import java.util.Scanner
  val SC: Scanner = new Scanner(System.in)
  def _line: String = SC.nextLine
  def _int: Int = SC.nextInt
  def _long: Long = SC.nextLong
  def _string: String = SC.next
  solution()
}

object Cf118A extends App {
  val s = readLine()
  println(s.toLowerCase.replaceAll("[ayeoiu]", "").map("." + _).mkString)
}

object Main {
  def main(args: Array[String]): Unit = {
    print(readLine().split("")
      .map(el => if (!"AOYEUI".contains(el.toUpperCase())) "." + el.toLowerCase() else "")
      .mkString(""))
  }
}

import scala.collection.mutable._
import scala.math._
import scala.util.control.Breaks.break
import scala.util.control.Breaks.breakable
import java.util._
object Main extends App {
  for(i <- readLine.replaceAll("[AOYEUIaoyeui]", "").toLowerCase) print("."+i)
  println
}

// http://codeforces.com/problemset/problem/118/A

import scala.io.StdIn.readLine

object StringTask {
    def main(args: Array[String]): Unit = {
        val vowels: Set[Char] = "aeiouy".toSet

        var line: String = readLine().toLowerCase()
        line = line.filterNot(vowels.contains(_))
        val dotted: String = line.mkString(".")
        println(f".${dotted}%s")
    }
}

object Solution extends App {
  val vowel = List('a', 'e', 'o', 'u', 'i', 'y')
  println(readLine().toLowerCase.filterNot(vowel.contains).mkString(".", ".", ""))
}

import scala.collection.immutable.IndexedSeq

object Problem118A {
  def main(a: Array[String]) = {
    val vowels = Set('A', 'O', 'Y', 'E', 'U', 'I', 'a', 'o', 'y', 'e', 'u', 'i')

    val vowelsDeleted: String = readLine().filter(c => ! vowels.contains(c))
    val pointsToLowerCase: IndexedSeq[String] = vowelsDeleted.map(c => "." + c.toLower.toString())
    val result: String = pointsToLowerCase.foldLeft("")((s: String, t: String) => s + t)

    println(result)
  }
}

object Cf118a extends App {
  val vowels = List('a', 'o', 'y', 'e', 'u', 'i')
  val word = readLine
  val result = word.toLowerCase.filterNot(vowels.contains).mkString(".", ".", "")
  println(result)
}

object Main {
	import java.{util=>ju}
	import scala.annotation._
	import scala.collection._
	import scala.collection.{mutable => mu}
	import scala.collection.JavaConverters._
	import scala.math._

	def main(args:Array[String])
	{
		val sc = new ju.Scanner(System.in)
		val input = sc.next();

		input.map{
			case n if n == 'A' => ""
			case n if n == 'O' => ""
			case n if n == 'Y' => ""
			case n if n == 'E' => ""
			case n if n == 'U' => ""
			case n if n == 'I' => ""
			case n if n == 'a' => ""
			case n if n == 'o' => ""
			case n if n == 'y' => ""
			case n if n == 'e' => ""
			case n if n == 'u' => ""
			case n if n == 'i' => ""
			case n if n.isLowerCase => "."+n
			case n if n.isUpperCase => "."+n.toLowerCase
			case n => n
		}.foreach{
			print(_)
		}

	}
}

/**
 * Created by mikhailvarnavskikh on 04.04.15.
 */
object Main {

  def main(args: Array[String]) {
    val std = scala.io.StdIn
    val n = std.readLine()
    val vowels = "aoiuey"
    val res = n.toLowerCase.filter( x => !vowels.contains( x ) ).foldLeft( "" )( (r, c) => r + "." + c )
    println( res )
  }

}

import scala.io.StdIn

object StringTask extends App {

  val input = StdIn.readLine()
  print(impl(input))

  def impl(word: String) = {
    val wordReform = new StringBuilder
    for (char <- word) {
      val lower = char.toLower
      if (isConsonant(lower)) {
        wordReform.append(".").append(lower)
      }
    }
    wordReform.toString()
  }

  private
  def isConsonant(char: Char): Boolean = {
    char match {
      case 'a' | 'e' | 'i' | 'o' | 'u' | 'y' => false
      case _ => true
    }
  }
}

import scala.io.StdIn
object solution extends App{

   val text = StdIn.readLine
   val vowels = "aeiouy"

   val output = text.foldLeft("")((a,b) => {
        val lower = b.toString.toLowerCase
        if(vowels.contains(lower)) a+""
        else a +"."+ lower
   } )
    println(output)
}

object CF118A extends App {
  import scala.io.Source
  //val src = Source.fromFile("data.txt")
  val src = Source.stdin
  val lines = src.getLines

  def readString(): String =  {
    val line = if (lines.hasNext) lines.next else null
    if (line == null) throw new RuntimeException("Premature end of source encountered")
    line
  }

  val st = readString().toLowerCase().
             filterNot(x => x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u' || x == 'y').
              toList.map(x => s".$x").mkString

  println(st)

}

object A118 {
  @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 input = scala.io.StdIn.readLine
    def isVowel(char: Char) = {
      Array('A', 'E', 'I', 'O', 'U', 'Y').contains(char) || Array('A', 'E', 'I', 'O', 'U', 'Y').map(_.toLower).contains(char)
    }
    println(input
      .filter(!isVowel(_))
      .toCharArray
      .map(x => if (x.isUpper) x.toLower else x)
      .flatMap{x => Array('.', x)}.mkString(""))
  }
}

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

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

  val Vowels = List('a', 'o', 'y', 'e', 'u', 'i')
  def solve: String = "." + sc.nextLine.toLowerCase.filterNot(Vowels.contains(_)).mkString(".")

  out.println(solve)
  out.close
}

import java.util.Scanner
import scala.collection.mutable.StringBuilder

object R118_A extends App {
  val sc = new Scanner(System.in)

  val w = sc.nextLine()
  println(process(w))
  def process(w:String):String = {
    val nw = w.toLowerCase().replaceAll("[aiueoy]", "")
    val b = new StringBuilder
    nw.foreach(c=>{
      b.append('.')
      b.append(c)
    })
    b.result
  }
}

object StringTask {
  	def main (args: Array[String]) {
		val scanner = new java.util.Scanner(System.in)
				val word = scanner.nextLine().toLowerCase()
				word.toCharArray()
				var output : String = ""
				for (i <- 0 to word.length()-1) {
				  val current =
				  word(i) match {
				    case 'a' | 'e' | 'y' | 'u' | 'i' | 'o' => ""
				    case whatever => "."+whatever
				  }
				  output = output + current
				}
				println(output)
	}
}

import scala.io.StdIn._

object ScalaTest{
  def main(args: Array[String]): Unit = {

    val list = List('a','e','i','o','u','y')
    val input = readLine().toLowerCase.filterNot{ch =>
        list.contains(ch)
    }.mkString(".")
    println("." + input)
  }
}

object A118 {
	def main(args: Array[String]) = {
		val vow = List('a', 'e', 'i', 'u', 'y', 'o')
		for (c <- readLine.toLowerCase.toCharArray)
			if (!vow.exists(c == _))
				print("." + c)
	}
}

import scala.io.StdIn._

object test {
  def main(args: Array[String]): Unit = {
    val input = readLine()

    println(codeForees(input))

  }

  def codeForees(text: String) = {
      text.toLowerCase.filterNot (a => a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o' ||a == 'y').map(a => s".$a" ).mkString
  }
}

import java.util.Scanner

object Try1 {
  def main(args: Array[String]) {
    val in = new Scanner(System.in)
    var len,x, m, k, n, j, i: Int = 0
//    var a = new Array[Int](51)
//    n = in.nextInt()
//    k = in.nextInt()
//    x=0
    var line = in.nextLine()
    val al = "AOYEUIaeiouy"
    val b = "abcdefghijklmnopqrstuvwxyz"
    n=line.length()
    for (i <- 0 until n) {
      j=0
      while (j<12 && al(j)!=line(i)) j+=1
      if (j==12) {
        print('.')
        if (line(i)>='A' && line(i)<='Z') print(b(line(i)-'A'))
        else print(line(i))
      }
    }
  }
}

import java.io._

object Main {
  val in = new BufferedReader(new InputStreamReader(System.in))
  def main(args: Array[String]) {
    println(in.readLine().toLowerCase().filterNot(c => "aeiuyo".contains(c)).map("." + _).mkString)
  }
}

object StringTask {
  val vowels = Set('A', 'O', 'Y', 'E', 'U', 'I')
  def isVowel(c:Char) = vowels.contains(c.toUpper)
  def main(args: Array[String]): Unit = {
    val s = io.StdIn.readLine()
    var rs = ""

    for {c <- s} {
      c match {
        case _ if isVowel(c) =>
        case _ => rs += "." + c.toLower
      }
    }
    Console.println(rs)
  }
}

object Codeforces118A extends App{

  def WordConvert(word:String):String={
    val restrictedlist:String="aAeEiIoOuUyY"
    var ans:Array[Char]=new Array[Char](0)
    for (i<-word){
      if (!restrictedlist.contains(i)){
        ans=ans:+'.'
        ans=ans:+i.toLower
      }
    }
    return String.valueOf(ans)
  }

  val s:String=scala.io.StdIn.readLine
  println(WordConvert(s))

}

import scala.io.StdIn

object H {
  def main(args: Array[String]): Unit = {
//    var Array(n) = StdIn.readLine().split(" ").map(_.toInt)

    val pp = (s: Char) => {
      if (s == 'a' || s == 'e' || s == 'i' || s == 'o' || s == 'u' || s == 'y') {

      }
      else {
        print('.')
        print(s)
      }
    }

    var s = StdIn.readLine()
    for (c <- s.toLowerCase().toCharArray)
      pp(c)
  }
}

import java.io._

object Easy {
  val reader = new BufferedReader(new InputStreamReader(System.in))
  def main(args: Array[String]) {
    println(reader.readLine().toLowerCase().filterNot(c => "aeiuyo".contains(c)).map("." + _).mkString)
  }
}

/**
 * Created by vol on 9/16/14.
 */
object A118 extends App{
  val vowels = List('A', 'O', 'Y', 'E', 'U', 'I')
  val str:String = readLine()
  val noVowels = str.filter((e:Char) =>  !vowels.contains(e.toUpper))

  println(noVowels.map((e:Char) => "." + e.toLower).mkString)

}

object Main {
  def main(args: Array[String]) {
    val str = readLine()
    val replaced = str.toLowerCase.replaceAll("[aoyeui]", "").replaceAll("([^aoyeiu])", ".$1")
    println(replaced)
  }
}

object _118A extends App {
  def is_vowel(c: Char): Boolean =
    c == 'a' || c == 'o' || c == 'y' || c == 'e' || c == 'u' || c == 'i'

  val string = readLine()
  println(
    string.map(c => c.toLower).
      filterNot(c => is_vowel(c)).
      foldLeft("")((accm, c) => accm + '.' + c))
}

object _118A_StringTask extends App {
  import scala.io.StdIn._

  val s = readLine()

  def solve = {
    s filterNot { c =>
      Array('a', 'o', 'y', 'e', 'u', 'i').contains(c.toLower)
    } flatMap { c =>
      "." + c.toLower.toString
    }
  }

  println(solve)

}

object Main extends App{
    var t = readLine().toLowerCase().replaceAll("[aeyuio]","")
    t.foreach( (c) => print("." + c ) )
}

import scala.io.StdIn

object Main {

  val vowels = Array('A', 'I', 'U', 'E', 'O', 'I')

  def isVowel(char: Char) : Boolean =  {
    vowels contains char
  }

  def main(args: Array[String]): Unit = {
    val s = StdIn.readLine()

    println(s.map(_.toUpper).filter(!isVowel(_)).map("."+ _.toLower).mkString)
  }
}

object Main extends App {
  val vowels = List('A', 'O', 'Y', 'E', 'U', 'I') ++ List('a', 'o', 'y', 'e', 'u', 'i')
  def isVowel(c: Char): Boolean = vowels exists { _ == c }
  def isConsonant(c: Char): Boolean = !isVowel(c)
  def insertDot(c: Char): String = "."+ c
  def solve(s: String): String = s filterNot isVowel flatMap insertDot toLowerCase

  assert(solve("tour") == ".t.r")
  assert(solve("Codeforces") == ".c.d.f.r.c.s")
  assert(solve("aBAcAba") == ".b.c.b")
}

object StringTask {
  val vowels = Array('a', 'e', 'i', 'o', 'u')

  def main(args: Array[String]) {
    val sb = new StringBuilder

    Console.readLine.foreach { ch =>
      val lower = ch.toLower
      if (!vowels.contains(lower)) {
        sb.append(".").append(lower)
      }
    }

    println(sb.toString)
  }
}

object test
{
    def main(args : Array[String])
    {
        print(readLine.toLowerCase.replaceAll("[aeiou]","").map("."+_).mkString)
    }
}

object A00118 extends App {
  println(Console.readLine().filterNot("aeiouAEIOU".contains(_)).map(x => "." + x).map(x => x.toLowerCase()).mkString)
}

/*input
Tata
*/

import java.util.Scanner
import scala.io.StdIn

object Solution {
	def main(args: Array[String]): Unit = {

		val str = StdIn.readLine().map(_.toLower);
		str.foreach((x: Char) => {
			if(!("aeiou".contains(x))) {
				print('.');
				print(x);
			}
		})

	}

}

object CF118A extends App {
    import scala.io.StdIn.readLine
    import scala.collection.immutable.HashSet
    val s = readLine.toLowerCase.toCharArray
    val vowels:HashSet[Char] = HashSet('a','e','i','o','u')
    s.filter(!vowels(_)).foreach(x => print("."+x.toString))
}

object StringTask extends App {

	val vowels = List("a", "o", "y", "e", "u", "i")
	val input = scala.io.StdIn.readLine().toLowerCase()

	val output = input.foreach(x =>
		if (vowels.contains(x)) input.replaceAll(x.toString(), "")
		else input.replaceAll(x.toString(), s"\\.$x")
	)

	println(output)

}

object StringTask extends App {

	val input = scala.io.StdIn.readLine().toLowerCase()

    val noVowel = input.replaceAll("([aeiou])+", "")
    val output = noVowel.map(x => s".$x").mkString

	println(output)

}

object Main extends App {
  val inputString = readLine.toList

  def replaceLiterals(list: List[Char]): List[Char] = list match {
    case List() => List()
    case e :: rest =>
      e match {
        case 'a' | 'e' | 'i' | 'o' | 'u' | 'A' | 'E' | 'I' | 'O' | 'U' => replaceLiterals(rest)
        case _ => '.' :: e.toLower :: replaceLiterals(rest)
      }
  }

  println(replaceLiterals(inputString).mkString)
}

object Main extends App {
  val inputString = readLine.toList

  def replaceLiterals(list: List[Char]): List[Char] = list match {
    case List() => List()
    case e :: rest =>
      e match {
        case 'a' | 'e' | 'i' | 'o' | 'u' | 'A' | 'E' | 'I' | 'O' | 'U' => '.' :: replaceLiterals(rest)
        case _ => e.toLower :: replaceLiterals(rest)
      }
  }

  println(replaceLiterals(inputString).mkString)
}

object CF0118A extends App {

  val gl = List("a", "o", "y", "e", "u", "i")

  val str = readLine()

  var result = new StringBuilder

  for (ch <- str) {
    if (!(gl contains(ch.toString))) {
      result ++= "." + ch.toString.toLowerCase
    }
  }

  println(result)

}

object HelloWorld {
  def main(args: Array[String]): Unit = {
  	var s = readLine()
  	s = s.replaceAll( "[eyuioa]", "")
  	var str = ""
  	for(i <-0 until s.length())
  		str = str + "." + s(i)
  	str = str.map(c => c.toLower)
  	println(str)
  }
}

import scala.io.StdIn._

object task1 {
  def main(args: Array[String]): Unit = {
    val input = readLine()
    val letters = List('A', 'O', 'Y', 'E', 'U', 'I').map(_.toLower)
    val result = input.filterNot(el2 => letters.contains(el2)).map{ el =>
      s".$el"
    }.mkString("").toLowerCase
    println(result)
  }

}

object cf extends App{
  val vowels = Set('a', 'e', 'i', 'o', 'u', 'y')
  var s = readLine().toLowerCase()
  var res = ""
  for (i <- 0 to s.length()-1) {
    if (!vowels(s(i))) {
      res += "." + s(i)
    }
  }
}

object Solution {
    val vowels = Array("A", "O", "Y", "E", "U", "I") map (_ charAt 0)
    def isVowel(c: Char) = vowels contains (Character.toUpperCase(c))
    def consonants(chars: Seq[Char]) = chars filter isVowel
    def withDots(chars: Seq[Char]) = chars flatMap (c => List('.', c))
    def solve(line: String) = withDots (consonants (line toLowerCase)) mkString
    def main(args: Array[String]) = println(solve(readLine))
}

object Solution extends App {
  val vowel = List('a', 'e', 'o', 'u', 'i')
  println(readLine().toLowerCase.filterNot(vowel.contains).mkString("."))
}

object Solution extends App {
  val vowel = List('a', 'e', 'o', 'u', 'i')
  println(readLine().toLowerCase.filterNot(vowel.contains).mkString(".", ".", ""))
}

object Main {
	import java.{util=>ju}
	import scala.annotation._
	import scala.collection._
	import scala.collection.{mutable => mu}
	import scala.collection.JavaConverters._
	import scala.math._

	def main(args:Array[String])
	{
		val sc = new ju.Scanner(System.in)
		val input = sc.next();

		input.map{
			case n if n == 'A' => ""
			case n if n == 'O' => ""
			case n if n == 'Y' => ""
			case n if n == 'E' => ""
			case n if n == 'I' => ""
			case n if n == 'a' => ""
			case n if n == 'o' => ""
			case n if n == 'y' => ""
			case n if n == 'e' => ""
			case n if n == 'u' => ""
			case n if n == 'i' => ""
			case n if n.isLowerCase => "."+n
			case n if n.isUpperCase => "."+n.toLowerCase
			case n => n
		}.foreach{
			print(_)
		}

	}
}

import scala.io.StdIn
object solution extends App{

   val text = StdIn.readLine
   val vowels = "aeiouy"

   text.foldLeft("")((a,b) => {
        val lower = b.toString.toLowerCase
        if(vowels.contains(lower)) a
        else a +"."+ b
   } )

}

import scala.io.StdIn
object solution extends App{

   val text = StdIn.readLine
   val vowels = "aeiouy"

   text.foldLeft("")((a,b) => {
        val lower = b.toString.toLowerCase
        if(vowels.contains(lower)) a+""
        else a +"."+ b
   } )

}

import scala.io.StdIn
object solution extends App{

   val text = StdIn.readLine
   val vowels = "aeiou"

   text.foldLeft("")((a,b) => {
        val lower = b.toString.toLowerCase
        if(vowels.contains(lower)) a+""
        else a +"."+ b
   } )

}

import scala.io.StdIn
object solution extends App{

   val text = StdIn.readLine
   val vowels = "aeiouy"

  val output =  text.foldLeft("")((a,b) => {
        val lower = b.toString.toLowerCase
        if(vowels.contains(lower)) a+""
        else a +"."+ b
   } )

   println(output)

}

import scala.io.StdIn
object solution extends App{

   val text = StdIn.readLine
   val vowels = "aeiouy"

   text.foldLeft("")((a,b) => {
        val lower = b.toString.toLowerCase
        if(vowels.contains(lower)) a+""
        else a +"."+ lower
   } )

}

import scala.io.StdIn._

object ScalaTest{
  def main(args: Array[String]): Unit = {

    val list = List('a','e','i','o','u')
    val input = readLine().toLowerCase.filterNot{ch =>
        list.contains(ch)
    }.mkString(".")
    println("." + input)
  }
}

import scala.io.StdIn._

object ScalaTest{
  def main(args: Array[String]): Unit = {

    val list = List('A','a','E','e','I','i','O','o','U','u')
    val input = readLine().filterNot{ch =>
      list.contains(ch)
    }.mkString(".")
    println("." + input)
  }
}

import scala.io.StdIn

object H {
  def main(args: Array[String]): Unit = {
//    var Array(n) = StdIn.readLine().split(" ").map(_.toInt)

    val pp = (s: Char) => {
      if (s == 'a' || s == 'e' || s == 'i' || s == 'o' || s == 'u') {

      }
      else {
        print('.')
        print(s)
      }
    }

    var s = StdIn.readLine()
    for (c <- s.toLowerCase().toCharArray)
      pp(c)
  }
}


Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (https://en.wikipedia.org/wiki/Seven-segment_display).  Max starts to type all the values from a to b. After typing each number Max resets the calculator. Find the total number of segments printed on the calculator.For example if a = 1 and b = 3 then at first the calculator will print 2 segments, then — 5 segments and at last it will print 5 segments. So the total number of printed segments is 12.

The only line contains two integers a, b (1 ≤ a ≤ b ≤ 106) — the first and the last number typed by Max.

Print the only integer a — the total number of printed segments.

import scala.io.Source

object Solution extends App {
  val map = Map('0' -> 6, '1' -> 2, '2' -> 5, '3' -> 5, '4' -> 4, '5' -> 5, '6' -> 6, '7' -> 3, '8' -> 7, '9' -> 6)

  val in = Source.stdin.getLines()
  val Array(a, b) = in.next().split(' ').map(_.toInt)
  println((a to b).foldLeft(0l) {
    case (acc, i) => acc + i.toString.map(map).sum
  })
}

import io.StdIn._
import scala.collection.mutable._

object Solution {

  @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)) }

  @inline def segments(a: Int): Int = {
    val s = Array(6, 2, 5, 5, 4, 5, 6, 3, 7, 6)
    var n = a
    var res = 0
    while (n > 0) {
      res += s(n%10)
      n /= 10
    }
    res
  }
  def main(args: Array[String]) {
    val Array(a, b) = readInts(2)

    println((a to b).foldLeft(0)( _ + segments(_)))

//    Console.withOut(new java.io.BufferedOutputStream(Console.out))
//    println(res.mkString("\n"))
//    Console.flush
  }
}

import scala.math._
import scala.Console
object Object {

  def main(args : Array[String]){

    val Array(a, b) = readLine.split(" ").map{_.toInt }
    var tl = 0

    for(i <- a to b){
     val li = i.toString.map(_.asDigit)
     li.map { i => i match{
        case 1 => tl += 2
        case 2|3|5 => tl += 5
        case 6|9|0 => tl += 6
        case 4 => tl += 4
        case 7 => tl += 3
        case 8 => tl += 7
        }
     }
    }
    println(tl)
  }
}

import io.StdIn._
import scala.collection.mutable._

object Solution extends App {
  val nks = readLine().split(" ")
  val nk = nks.map(_.toInt)
  val TempArr = Array( 6 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 )

  val a = nk(0)
  val b = nk(1)
  var ans = 0

  for ( i <- a to b ) {

    var temp = i

    while ( temp != 0 ) {
      ans = ans + TempArr( temp % 10 )
      temp = temp / 10
    }

  }

  println ( ans )

}

import scala.io.Source

object Solution extends App {
  val map = Map('0' -> 6, '1' -> 2, '2' -> 5, '3' -> 5, '4' -> 4, '5' -> 5, '6' -> 6, '7' -> 3, '8' -> 7, '9' -> 6)

  val in = Source.stdin.getLines()
  val Array(a, b) = in.next().split(' ').map(_.toInt)
  (a to b).foldLeft(0l) {
    case (acc, i) => acc + i.toString.map(map).sum
  }
}