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


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

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


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


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

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("." + _))
}

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

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


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


object B450 {

  import IO._
  import collection.{mutable => cu}
  val MOD = 1000000007L
  def main(args: Array[String]): Unit = {
    val Array(x, y) = readLongs(2)
    val a = Array(x, y, y-x,-x,-y,x-y).map(x => (x + 2*MOD)% MOD)
    val Array(n) = readInts(1)
    println(a((n-1)%6))
  }

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

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

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

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

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

}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(x, y) = in.next().split(" ").map(_.toInt)
  val mod = 1000000007
  val n = (in.next().toInt - 1) % 6
  val k = n % 3
  val res = k match {
    case 0 => x
    case 1 => y
    case 2 => y - x
  }

  if (n < 3) println((res % mod + mod) % mod) else {
    println((-res % mod + mod) % mod)
  }
}

import java.util.Scanner

/**
 * Created by kshim on 25/07/2014.
 */
object CF257B extends App {
  def Process(x:Long, y:Long, n:Long):Long = {
    val fn:Long = (n-1) % 6 match {
      case 0 => x
      case 1 => y
      case 2 => y - x
      case 3 => -x
      case 4 => -y
      case 5 => -y + x
    }
    val r = fn % (1000000000L + 7L)
    if(r < 0) {
      r + (1000000000L + 7L)
    } else {
      r
    }
  }
  val in = new Scanner(System.in)
  val x = in.nextInt()
  val y = in.nextInt()
  val n = in.nextInt()
  println(Process(x, y, n))
}

object Sequences {

  def splitter(as: String) = as.split("\\s+") match {
    case Array(n, m) => List(n.toLong, m.toLong)
  }

  def solve(x: Long, y: Long, n: Long): Long = (n % 6) match {
    case 1 => x
    case 2 => y
    case 3 => y-x
    case 4 => -x
    case 5 => -y
    case 0 => x-y
  }

  def main(args: Array[String]) {
    val N = 1e9.toLong + 7
    val List(xyStr, nStr) = io.Source.stdin.getLines.take(2).toList
    val List(x, y) = splitter(xyStr)
    val n = nStr.toLong
    val f = solve(x, y, n)
    val fModN = f % N
    val res: Long = if (fModN>=0) fModN else fModN + N
    println(res)
  }
}

/**
 * @author Oleg Arshinsky
 */
object B extends App {{

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

  def _1 = x
  def _2 = y
  def _3 = y-x
  def _4 = -x
  def _5 = -y
  def _6 = x-y

  val functions = Array(_1, _2, _3, _4, _5, _6)

  val intermediate = n % 6

  val function_n = if (intermediate == 0) 6-1 else intermediate-1

  val f_n = functions(function_n)

  val a = f_n
  val b = 1000000007

  println((a - (a.toDouble/b).floor * b).toInt)

}}

object Main {
  def main(args: Array[String]): Unit = {
    val N = 1000000007
    val halfN = 500000003
    val xy = io.StdIn.readLine().split(" ").map { s =>
      val i = Integer.parseInt(s)
      if (i < 0 ) i + N else i
    }
    val n = (io.StdIn.readInt() -1) % 6
    def compute(k: Int): Long = {
      if (k > 2) -1 * compute(k - 3)
      else if (k ==2) xy(1) - xy(0)
      else xy(k)
    }
    val fn = compute(n) % N
    println(if (fn < 0) fn + N else fn)
  }
}

import scala.math.BigInt

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val x, y, n = sc.nextInt

  def solve( x: Int, y: Int, n: Int ): Int = {
    val M: Int = 1e9.toInt + 7

    val newN = (n-1) % 6

    def tail(a: BigInt, b: BigInt): Stream[BigInt] = a #:: tail(b, b - a)
    val res = tail(x, y)(newN)
    ( ( ( res % M ) + M ) mod M ).toInt
  }

  println( solve( x, y, n ) )
}

import scala.math.BigInt

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val x, y, n = sc.nextInt

  def solve2( x: Int, y: Int, n: Int ): Int = {
    val M: Int = 1e9.toInt + 7

    val newN = (n-1) % 6

    def tail(a: BigInt, b: BigInt): Stream[BigInt] = a #:: tail(b, b - a)
    val res = tail(x, y)(newN)
    ( ( ( res % M ) + M ) mod M ).toInt
  }

  def solve( x: Int, y: Int, n: Int ): Int = {
    val M: Int = 1e9.toInt + 7

    val newN = (n-1) % 6

    var memo = new Array[Int](6)
    memo(0) = x
    memo(1) = y
    for( i <- (2 until 6) ) {
      memo(i) = ( memo(i-1) - memo(i-2) ) % M
    }

    ( ( memo(newN) % M ) + M ) % M
  }

  println( solve( x, y, n ) )
}

object HelloWorld{
  def computeSeq(x: Int, y:Int, l:Int):List[Int] = l match {
    case 0 => List()
    case _ => (y-x)::computeSeq(y, y-x, l-1)
  }
  def main(args: Array[String]){
    val in = new java.util.Scanner(System.in)
    val x = in.nextInt
    val y = in.nextInt
    val n = in.nextInt-1
    val seq = x::y::computeSeq(x, y, 4)
    println(floorMod(1000*1000*1000+7)(seq(n%6)))
  }
  def floorMod(m: Int)(n: Int) = (((n % m) + m) % m)
}

import java.io.PrintWriter
import java.util.Scanner

/**
 * Created by arseny on 19.07.14.
 */
object B extends App {
  val home = true
  val in = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  def nextInt = in.nextInt
  def nextLong = in.nextLong
  def nextDouble = in.nextDouble
  def nextString = in.next

  def solve() = {
    val x = nextLong
    val y = nextLong
    val p: Long = 1000 * 1000 * 1000 + 7
    val n = nextLong % 6
    val ans: Long = n match {
      case 0 => x - y
      case 1 => x
      case 2 => y
      case 3 => y - x
      case 4 => -x
      case 5 => - y
    }
    out.println((ans + 3 * p) % p)
  }

  try {
    solve()
  } catch {
    case _: Exception => sys.exit(9999)
  } finally {
    out.flush()
    out.close()
  }
}

import java.util.Scanner

/**
 * Created by kshim on 25/07/2014.
 */
object CF257B extends App {
  def Process(x:Long, y:Long, n:Long):Long = {
    val fn:Long = (n-1) % 6 match {
      case 0 => x
      case 1 => y
      case 2 => y - x
      case 3 => -x
      case 4 => -y
      case 5 => -y + x
    }
    if(fn < 0) {
      (fn % (1000000000L + 7L)) + (1000000000L + 7L)
    } else {
      fn % (1000000000L + 7L)
    }
  }
  val in = new Scanner(System.in)
  val x = in.nextInt()
  val y = in.nextInt()
  val n = in.nextInt()
  println(Process(x, y, n))
}

object B450 {

  import IO._
  import collection.{mutable => cu}
  val MOD = 100000007L
  def main(args: Array[String]): Unit = {
    val Array(x, y) = readLongs(2)
    val a = Array(x, y, y-x,-x,-y,x-y).map(x => (x + 2*MOD)% MOD)
    val Array(n) = readInts(1)
    println(a((n-1)%6))
  }

  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 Sequences {

  def splitter(as: String) = as.split("\\s+") match {
    case Array(n, m) => List(n.toLong, m.toLong)
  }

  def solve(x: Long, y: Long, n: Long): Long = (n % 6) match {
    case 1 => x
    case 2 => y
    case 3 => y-x
    case 4 => -x
    case 5 => -y
    case 0 => x-y
  }

  def main(args: Array[String]) {
    val N = 1e9.toLong + 7
    val List(xyStr, nStr) = io.Source.stdin.getLines.take(2).toList
    val List(x, y) = splitter(xyStr)
    val n = nStr.toLong
    val f = solve(x, y, n)
    val res: Long = if (f>=0) f % N else (f + N) % N
    println(res)
  }
}

object Sequences {

  def splitter(as: String) = as.split("\\s+") match {
    case Array(n, m) => List(n.toLong, m.toLong)
  }

  def solve(x: Long, y: Long, n: Long): Long = (n % 6) match {
    case 1 => x
    case 2 => y
    case 3 => y-x
    case 4 => -x
    case 5 => -y
    case 0 => x-y
  }

  def main(args: Array[String]) {
    val N = 1e9.toLong + 7
    val List(xyStr, nStr) = io.Source.stdin.getLines.take(2).toList
    val List(x, y) = splitter(xyStr)
    val n = nStr.toLong
    val f = solve(x, y, n)
    val res: Long = if (f>=0) f % N else (f % N) + N
    println(res)
  }
}

object Main {
  def main(args: Array[String]): Unit = {
    val N = 1000000007
    val halfN = 500000003
    val xy = io.StdIn.readLine().split(" ").map { s =>
      val i = Integer.parseInt(s)
      if (i > halfN) i - N else i
    }
    val n = (io.StdIn.readInt() -1) % 6
    def compute(k: Int): Long = {
      if (k > 2) -1 * compute(5 - k)
      else if (k == 0) xy(0)
      else if (k == 1) xy(1)
      else xy(1) - xy(0)
    }
    val fn = compute(n) % N
    println(if (fn < 0) fn + N else fn)
  }
}

object Main {
  def main(args: Array[String]): Unit = {
    val N = 1000000007
    val halfN = 500000003
    val xy = io.StdIn.readLine().split(" ").map { s =>
      val i = Integer.parseInt(s)
      if (i > halfN) i - N else i
    }
    val n = io.StdIn.readLong()
    val fn = (xy(1) - ((n - 2) % N) * xy(0)) % N
    println(if (fn < 0) fn + N else fn)
  }
}

import scala.math.BigInt

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val x, y, n = sc.nextInt

  def solve( x: Int, y: Int, n: Int ): Int = {
    val M: Int = 1e9.toInt + 7

    val newN = (n-1) % 6

    def tail(a: BigInt, b: BigInt): Stream[BigInt] = a #:: tail(b, b - a)
    val res = tail(x, y)(newN-1)
    ( ( ( res % M ) + M ) mod M ).toInt
  }

  println( solve( x, y, n ) )
}

import scala.math.BigInt

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val x, y, n = sc.nextInt

  def solve( x: Int, y: Int, n: Int ): Int = {
    val M: Int = 1e9.toInt + 7

    val newN = (n-1) % 6

    def tail(a: BigInt, b: BigInt): Stream[BigInt] = a #:: tail(b, b - a)
    val res = tail(x, y)(newN)
    ( ( ( res % M ) + M ) mod M ).toInt
  }

  def solve2( x: Int, y: Int, n: Int ): Int = {
    val M: Int = 1e9.toInt + 7

    val newN = (n-1) % 6

    var memo = new Array[Int](6)
    memo(0) = x
    memo(1) = y
    for( i <- (2 until 6) ) {
      memo(i) = ( ( ( memo(i-1) + memo(i-2) ) % M ) + M ) % M
    }

    memo(newN)
  }

  println( solve2( x, y, n ) )
}

import scala.math.BigInt

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val x, y, n = sc.nextInt

  def solve( x: Int, y: Int, n: Int ): Int = {
    val M: Int = 1e9.toInt + 7

    val newN = (n-1) % 6

    def tail(a: BigInt, b: BigInt): Stream[BigInt] = a #:: tail(b, b - a)
    val res = tail(x, y)(newN)
    ( ( ( res % M ) + M ) mod M ).toInt
  }

  def solve2( x: Int, y: Int, n: Int ): Int = {
    val M: Int = 1e9.toInt + 7

    val newN = (n-1) % 6

    var memo = new Array[Int](6)
    memo(0) = x
    memo(1) = y
    for( i <- (2 until 6) ) {
      memo(i) = ( ( ( memo(i-1) - memo(i-2) ) % M ) + M ) % M
    }

    memo(newN)
  }

  println( solve2( x, y, n ) )
}


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

object A {

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

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

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

  def nextLong: Long = {
    return Long.parseLong(next)
  }

  def solve = {
    val y = nextInt
    val w = nextInt
    val x = 6 - Math.max(y, w) + 1
    if (x % 6 == 0) {
      out.println(x / 6 + "/" + 1)
    } else if (x % 3 == 0) {
      out.println(x / 3 + "/" + 2)
    } else if (x % 2 == 0) {
      out.println(x / 2 + "/" + 3)
    } else {
      out.println(x + "/" + 6)
    }
  }

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

//package me.jetblack.cf

import java.util.Scanner

object DiceRoll extends App {

  val s = new Scanner(System.in)

  val y = s.nextInt()
  val w = s.nextInt()

  val t = 6 - (math.max(y, w) - 1)
  if (t == 4) {
    println("2/3")
  } else if (t == 3) {
    println("1/2")
  } else if (t == 2) {
    println("1/3")
  } else if (t == 6) {
    println("1/1")
  } else {
    println(s"$t/6")
  }

}

import scala.io._
import scala.collection.mutable._
import java.util.StringTokenizer

object HelloWorld {

  def main(args: Array[String]): Unit = {
    var Array(y, w) = readLine.split(" ").map(_.toInt);
    var max = math.max(y, w);
    if (max == 1) {
      println("1/1");
    } else if (max == 2) {
      println("5/6");
    } else if (max == 3) {
      println("2/3");
    } else if (max == 4) {
      println("1/2");
    } else if (max == 5) {
      println("1/3");
    } else {
      println("1/6");
    }
  }

}

object Main {
  def main(args: Array[String]) {
    val max = readLine.split(" ").map(_.toInt).max
    max match {
      case 1 => println("1/1")
      case 2 => println("5/6")
      case 3 => println("2/3")
      case 4 => println("1/2")
      case 5 => println("1/3")
      case 6 => println("1/6")
      case _ => // to make scalac happy
    }
  }
}

object P9A {
    import io.StdIn._

    def main(args:Array[String]) {
        println(readLine.split(' ').map{_.toInt}.max match {
            case 1 => "1/1"
            case 2 => "5/6"
            case 3 => "2/3"
            case 4 => "1/2"
            case 5 => "1/3"
            case 6 => "1/6"
        })
    }
}

object dieroll extends App {
  val Array(a, b) = readLine split ' ' map (_.toInt)

  @scala.annotation.tailrec def gcd(a: Int, b: Int): Int = b match {
    case 0 => a
    case _ => gcd(b, a % b)
  }

  val total = 7 - math.max(a, b)
  val g = gcd(total, 6)

  println(s"${total/g}/${6/g}")
}

import java.util.StringTokenizer

object _9A extends App {
  var token = new StringTokenizer("")
  def next = {
    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)
    token.nextToken()
  }
  val cb = 7 - (next.toInt max next.toInt)
  if (cb == 0) println("0/1")
  else if (cb == 1) println("1/6")
  else if (cb == 2) println("1/3")
  else if (cb == 3) println("1/2")
  else if (cb == 4) println("2/3")
  else if (cb == 5) println("5/6")
  else println("1/1")
}

object A9 {

  import IO._

  def main(args: Array[String]): Unit = {
    val score = readInts(2)
    val max = score.max
    val ans = Array("0/1", "1/1", "5/6", "2/3", "1/2", "1/3", "1/6")
    println(ans(max))
  }

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

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

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

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

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

}

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

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

  def solve(): String = {
    val target: Int = List.fill(2)(sc.nextInt).max
    List("dummy", "1/1", "5/6", "2/3", "1/2", "1/3", "1/6")(target)
  }

  out.println(solve)
  out.close
}

import java.util.StringTokenizer

object _9A extends App {
  var token = new StringTokenizer("")
  def next = {
    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)
    token.nextToken()
  }
  val cb = 6 - next.toInt max next.toInt + 1
  if (cb == 0) println("0/1")
  else if (cb == 1) println("1/6")
  else if (cb == 2) println("1/3")
  else if (cb == 3) println("1/2")
  else if (cb == 4) println("2/3")
  else if (cb == 5) println("5/6")
  else println("1/1")
}

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

object A {

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

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

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

  def nextLong: Long = {
    return Long.parseLong(next)
  }

  def solve = {
    val y = nextInt
    val w = nextInt
    val x = 6 - Math.max(y, w) + 1
    if (x % 2 == 0) {
      out.println(x / 2 + "/" + 3)
    } else if (x % 3 == 0) {
      out.println(x / 3 + "/" + 2)
    } else if (x % 6 == 0) {
      out.println(x / 6 + "/" + 1)
    } else {
      out.println(x / 6)
    }
  }

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

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

object A {

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

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

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

  def nextLong: Long = {
    return Long.parseLong(next)
  }

  def solve = {
    val y = nextInt
    val w = nextInt
    val x = 6 - Math.max(y, w) + 1
    if (x % 2 == 0) {
      out.println(x / 2 + "/" + 3)
    } else if (x % 3 == 0) {
      out.println(x / 3 + "/" + 2)
    } else if (x % 6 == 0) {
      out.println(x / 6 + "/" + 1)
    } else {
      out.println(x + "/" + 6)
    }
  }

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

object P9A {
    import io.StdIn._

    def main(args:Array[String]) {
        println(readLine.split(' ').map{_.toInt}.max match {
            case 1 => "1/0"
            case 2 => "5/6"
            case 3 => "2/3"
            case 4 => "1/2"
            case 5 => "1/3"
            case 6 => "1/6"
        })
    }
}


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

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

  val f: PartialFunction[List[Int], String] = {
    case List(p, q, r, s) if p + q > r || q + r > s => "TRIANGLE"
    case List(p, q, r, s) if p + q == r || q + r == s => "SEGMENT"
    case _ => "IMPOSSIBLE"
  }
  val res: String = f(List.fill(4)(sc.nextInt).sorted)

  out.println(res)
  out.close
}

object Solution6A extends Application {

  def isTriangle(a: Int, b: Int, c: Int): Boolean = a + b > c && a + c > b && b + c > a

  def isSegment(a: Int, b: Int, c: Int): Boolean = a + b == c || a + c == b || b + c == a

  def solution() {
    val a1 = _int
    val a2 = _int
    val a3 = _int
    val a4 = _int

    if (isTriangle(a1, a2, a3)) {
      println("TRIANGLE")
      return
    }
    if (isTriangle(a1, a2, a4)) {
      println("TRIANGLE")
      return
    }
    if (isTriangle(a1, a4, a3)) {
      println("TRIANGLE")
      return
    }
    if (isTriangle(a4, a2, a3)) {
      println("TRIANGLE")
      return
    }

    if (isSegment(a1, a2, a3)) {
      println("SEGMENT")
      return
    }
    if (isSegment(a1, a2, a4)) {
      println("SEGMENT")
      return
    }
    if (isSegment(a1, a4, a3)) {
      println("SEGMENT")
      return
    }
    if (isSegment(a4, a2, a3)) {
      println("SEGMENT")
      return
    }

    println("IMPOSSIBLE")
  }

  //////////////////////////////////////////////////
  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 Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  var data = in.next().split(" ").map(_.toInt).toList.sorted

  def triangle(list: Seq[Int]): Int = {
    val sorted = list.sorted
    if (sorted(0) + sorted(1) == sorted(2)) 1
    else if (sorted(0) + sorted(1) > sorted(2)) 2
    else 0
  }

  val max = data.combinations(3).map(triangle).max
  if (max == 2)
    println("TRIANGLE")
  else if (max == 1)
    println("SEGMENT")
  else
    println("IMPOSSIBLE")
}

import java.util.Scanner

object ATriangle extends App {

  val scanner = new Scanner(System.in)

  val in = (0 until 4).map(i => scanner.nextInt().toDouble)

  val res = (0 until 4).foldLeft("IMPOSSIBLE")((r: String, c: Int) =>
    r match {
      case "TRIANGLE" => "TRIANGLE"
      case t if t =="IMPOSSIBLE" || t == "SEGMENT"  =>
        val s = co(in.remove(c).toList)
        if (math.abs(s) == 1.0) "SEGMENT"
        else if (t == "SEGMENT" && math.abs(s) > 1.0) "SEGMENT"
        else if (math.abs(s) < 1.0) "TRIANGLE"
        else "IMPOSSIBLE"

    }
  )

  println(res)

  implicit class ListExt[T](src: Seq[T]) {
    def remove(idx: Int): Seq[T] = src.take(idx) ++ src.drop(idx + 1)
  }

  def co(a:List[Double]): Double = (math.pow(a(0), 2) + math.pow(a(1), 2) - math.pow(a(2), 2)) / (2 * a(0) * a(1))

}

object A6 {

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

  def main(args: Array[String]): Unit = {
    val in = readInts(4)
    val tri = in.permutations.exists{ arr =>
      val t = arr.take(3)
      arr(0)+arr(1) > arr(2) && arr(1)+arr(2) > arr(0) && arr(0)+arr(2) > arr(1)
    }
    if(tri) {
      println("TRIANGLE")
    } else {
      val deg = in.permutations.exists{ arr =>
        val t = arr.take(3)
        arr(0)+arr(1) >= arr(2) && arr(1)+arr(2) >= arr(0) && arr(0)+arr(2) >= arr(1)
      }
      if(deg) {
        println("SEGMENT")
      } else {
        println("IMPOSSIBLE")
      }
    }
  }

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

}

import java.util.Scanner
import scala.util.Sorting.quickSort
import scala.math.max;

object Main {

  val TRIANGLE = 2
  val SEGMENT = 1
  val IMPOSSIBLE = 0
  val map = Array("IMPOSSIBLE", "SEGMENT", "TRIANGLE")

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

    println(map(canMakeTriangle(Array(next, next, next, next))))
  }

  def canMakeTriangle(sides: Array[Int]): Int = {
    quickSort(sides)
    max(classifyTriangle(sides(0), sides(1), sides(2)), classifyTriangle(sides(1), sides(2), sides(3)))
  }

  def classifyTriangle(s0: Int, s1: Int, s2: Int) = {
    val s = s0 + s1;
    if (s < s2) IMPOSSIBLE
    else if (s == s2) SEGMENT
    else TRIANGLE
  }
}

/**
 * Created by yangchaozhong on 3/10/15.
 */
object CF6A extends App {
  import java.util.{Scanner}
  import java.io.{PrintWriter}

  val in = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  def nextInt = in.nextInt
  def nextLong = in.nextLong
  def nextDouble = in.nextDouble
  def nextString = in.next
  def nextLine = in.nextLine

  def solve = {
    val lines = Array.ofDim[Int](4)

    (0 until 4).foreach { i =>
      lines(i) = nextInt
    }

    val combinations = lines.combinations(3)
    var c1 = 0
    var c2 = 0
    combinations.foreach { arr =>
      val sortedArr = arr.sortWith(_ > _)
      if (sortedArr(1) + sortedArr(2) > sortedArr(0)) {
        c1 += 1
      } else if (sortedArr(1) + sortedArr(2) == sortedArr(0)) {
        c2 += 1
      }
    }

    if (c1 > 0) {
      out.println("TRIANGLE")
    } else if (c2 > 0) {
      out.println("SEGMENT")
    } else {
      out.println("IMPOSSIBLE")
    }
  }

  try {
    solve
  } catch {
    case _: Exception => sys.exit(9999)
  } finally {
    out.flush
    out.close
  }
}

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

object A {

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

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

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

  def nextLong: Long = {
    return Long.parseLong(next)
  }

  def solve = {
    val len = new Array[Int](4)
    for (i <- 0 until 4) {
      len(i) = nextInt
    }
    var flag = false
    for (i <- 0 until 4) {
      for (j <- 0 until 4) {
        for (k <- 0 until 4) {
          if (i != j && j != k && i != k) {
            if (len(i) < len(j) + len(k) &&
              len(j) < len(i) + len(k) &&
              len(k) < len(j) + len(i) && !flag) {
              out.println("TRIANGLE")
              flag = true
            }
          }
        }
      }
    }
    if (!flag) {
      for (i <- 0 until 4) {
        for (j <- 0 until 4) {
          for (k <- 0 until 4) {
            if (i != j && j != k && i != k) {
              if ((len(i) <= len(j) + len(k) &&
                len(j) <= len(i) + len(k) &&
                len(k) <= len(j) + len(i)) && !flag) {
                out.println("SEGMENT")
                flag = true
              }
            }
          }
        }
      }
    }
    if (!flag) {
      out.println("IMPOSSIBLE")
    }
  }

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

object P6A {
    def main(args : Array[String]) {
        val a = readLine split ' ' map {_.toInt}
        val answer = () match {
            case _ if (a combinations 3) exists {
                case Array(u, v, w) => u + v > w && v + w > u && w + u > v
            } => "TRIANGLE"
            case _ if (a combinations 3) exists {
                case Array(u, v, w) => u + v >= w && v + w >= u && w + u >= v
            } => "SEGMENT"
            case _ => "IMPOSSIBLE"
        }
        println(answer)
    }
}

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

object HelloWorld {
  def main(args: Array[String]) = {
    var arr = readLine.split(" ").map(_.toInt);
    var result = 0;
    val buffer = ArrayBuffer[Int](arr(0), arr(1), arr(2), arr(3)).sorted;
    for (i <- 0 until buffer.length) {
      val temp = buffer.clone;
      temp.remove(i);
      if (temp(0) + temp(1) > temp(2)) {
        result = math.max(result, 2);
      } else if (temp(0) + temp(1) == temp(2)) {
        result = math.max(result, 1);
      } else {
        result = math.max(result, 0);
      }
    }
    if (result == 0) {
      println("IMPOSSIBLE");
    } else if (result ==1) {
      println("SEGMENT");
    } else {
      println("TRIANGLE");
    }
  }

}

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

object HelloWorld {
  def main(args: Array[String]) = {
    var arr = readLine.split(" ").map(_.toInt);
    val list = List(arr(0), arr(1), arr(2), arr(3)).sorted;
    var result = 0;
    val buffer = ArrayBuffer[Int](arr(0), arr(1), arr(2), arr(3)).sorted;
    for (i <- 0 until buffer.length) {
      val temp = buffer.clone;
      temp.remove(i);
//      println("LIST_LENGTH = " + buffer.length);
//      println("TEMP = " + temp.toString);
//      println("LIST = " + buffer.toString);
      if (temp(0) + temp(1) > temp(2)) {
        result = math.max(result, 2);
      } else if (temp(0) + temp(1) == temp(2)) {
    	result = math.max(result, 1);
      } else {
        result = math.max(result, 0);
      }
    }
    if (result == 0) {
      println("IMPOSSIBLE");
    } else if (result ==1) {
      println("SEGMENT");
    } else {
      println("TRIANGLE");
    }
  }

}

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

    var traingle = false
    var segment = false
    for{
      i <- 0 to 3
      j <- i + 1 to 3
      k <- j + 1 to 3
    } {
      if (a(i) + a(j) > a(k)) traingle = true
      else if (a(i) + a(j) == a(k)) segment = true
    }
    if (traingle ) println("TRIANGLE")
    else if (segment) println("SEGMENT")
    else println("IMPOSSIBLE")
  }
}

object Main{
  def main(args: Array[String]) {
    def solve(list: List[Int]): String ={

      (list(0), list(1), list(2), list(3)) match {
        case _ if list(0) + list(1) > list(2) => "TRIANGLE"
        case _ if list(0) + list(1) > list(3) => "TRIANGLE"
        case _ if list(0) + list(2) > list(3) => "TRIANGLE"
        case _ if list(1) + list(2) > list(3) => "TRIANGLE"

        case _ if list(0) + list(1) == list(2) => "SEGMENT"
        case _ if list(0) + list(1) == list(3) => "SEGMENT"
        case _ if list(0) + list(2) == list(3) => "SEGMENT"
        case _ if list(1) + list(2) == list(3) => "SEGMENT"

        case _ => "IMPOSSIBLE"
      }
    }

    val line = scala.io.StdIn.readLine()
    val nums = line.split(" ").map(x => x.toInt).toList.sorted

    println(solve(nums))
  }
}

object Solution6A extends Application {

  def isTriangle(a: Int, b: Int, c: Int): Boolean = a + b > c && a + c > b && b + c > a

  def isSegment(a: Int, b: Int, c: Int): Boolean = !isTriangle(a, b, c) && a + b == c && a + c == b && b + c == a

  def solution() {
    val a1 = _int
    val a2 = _int
    val a3 = _int
    val a4 = _int

    if (isTriangle(a1, a2, a3)) {
      println("TRIANGLE")
      return
    }
    if (isTriangle(a1, a2, a4)) {
      println("TRIANGLE")
      return
    }
    if (isTriangle(a1, a4, a3)) {
      println("TRIANGLE")
      return
    }
    if (isTriangle(a4, a2, a3)) {
      println("TRIANGLE")
      return
    }

    if (isSegment(a1, a2, a3)) {
      println("SEGMENT")
      return
    }
    if (isSegment(a1, a2, a4)) {
      println("SEGMENT")
      return
    }
    if (isSegment(a1, a4, a3)) {
      println("SEGMENT")
      return
    }
    if (isSegment(a4, a2, a3)) {
      println("SEGMENT")
      return
    }

    println("IMPOSSIBLE")
  }

  //////////////////////////////////////////////////
  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()
}

/**
 * Created by yangchaozhong on 3/10/15.
 */
object CF6A extends App {
  import java.util.{Scanner}
  import java.io.{PrintWriter}

  val in = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  def nextInt = in.nextInt
  def nextLong = in.nextLong
  def nextDouble = in.nextDouble
  def nextString = in.next
  def nextLine = in.nextLine

  def solve = {
    val lines = Array.ofDim[Int](4)

    (0 until 4).foreach { i =>
      lines(i) = nextInt
    }

    val combinations = lines.combinations(3)
    var c1 = 0
    var c2 = 0
    combinations.foreach { x =>
      x.permutations.foreach { y =>
        if (y(0) + y(1) > y(2) && y(0) + y(1) < y(2)) {
          c1 += 1
        } else if (y(0) + y(1) == y(2)) {
          c2 += 1
        }
      }
    }

    if (c1 > 0) {
      out.println("TRIANGLE")
    } else if (c2 > 0) {
      out.println("SEGMENT")
    } else {
      out.println("IMPOSSIBLE")
    }
  }

  try {
    solve
  } catch {
    case _: Exception => sys.exit(9999)
  } finally {
    out.flush
    out.close
  }
}

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

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

  val isTriangle: PartialFunction[List[Int], Boolean] = {
    case List(x, y, z) => x + y > z
  }

  val res = List.fill(4)(sc.nextInt).sorted.sliding(3).find(isTriangle) match {
      case Some(x) => "TRIANGLE"
      case None    => "SEGMENT"
    }

  out.println(res)
  out.close
}

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

object A {

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

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

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

  def nextLong: Long = {
    return Long.parseLong(next)
  }

  def solve = {
    val len = new Array[Int](4)
    for (i <- 0 until 4) {
      len(i) = nextInt
    }
    var flag = false
    for (i <- 0 until 4) {
      for (j <- 0 until 4) {
        for (k <- 0 until 4) {
          if (i != j && j != k && i != k) {
            if (len(i) < len(j) + len(k) &&
              len(j) < len(i) + len(k) &&
              len(k) < len(j) + len(i) && !flag) {
              out.println("TRIANGLE")
              flag = true
            }
          }
        }
      }
    }
    if (!flag) {
      for (i <- 0 until 4) {
        for (j <- 0 until 4) {
          for (k <- 0 until 4) {
            if (i != j && j != k && i != k) {
              if ((len(i) <= len(j) + len(k) &&
                len(j) <= len(i) + len(k) ||
                len(k) <= len(j) + len(i)) && !flag) {
                out.println("SEGMENT")
                flag = true
              }
            }
          }
        }
      }
    }
    if (!flag) {
      out.println("IMPOSSIBLE")
    }
  }

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