import java.util.StringTokenizer

import scala.collection.mutable.Queue

object _450A extends App {
  var token = new StringTokenizer("")
  def next = {
    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)
    token.nextToken()
  }
  val n = next.toInt
  val m = next.toInt
  val a = (1 to n).map(i => next.toInt).toArray

  def f(q: Queue[Int]): Int = {
    if (q.tail == Nil) q.head + 1
    else {
      val i = q.head
      if (a(i) <= m) f(q.tail)
      else {
        a(i) = a(i) - m
        f(q.tail :+ i)
      }
    }
  }
  println(f(Queue[Int]() ++ (0 until n)))
}

import scala.annotation.tailrec

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n,m = sc.nextInt
  val input = List.fill(n)(sc.nextInt)

  def solve( m: Int, input: List[Int] ): Int = {

    @tailrec
    def dist(children: List[(Int, Int)]): Int = {
      children match {

        case List(x) =>  // size == 1
          x._2 + 1

        case x :: xs =>
          val diff = x._1 - m
          if (diff <= 0)
            dist(xs)
          else
            dist( ( (diff, x._2) :: xs.reverse ).reverse )
      }
    }

    dist( input.zipWithIndex )
  }

  println( solve( m, input ) )
}

import scala.annotation.tailrec
import scala.collection.mutable.ListBuffer

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n,m = sc.nextInt
  val children = List.fill(n)(sc.nextInt).zipWithIndex

  @tailrec
  def dist(children: List[(Int,Int)]): Unit = {
    children match {
      case Nil =>
      case List(x) => println(x._2 + 1)
      case x::xs =>
        val diff = x._1 - m
        if( diff <= 0 )
          dist(xs)
        else
          dist( xs :+ (diff, x._2) )
    }
  }

  dist(children)
}

object HelloWorld{
  def giveCandies(xs: List[(Int, Int)], m:Int, lastSatisfied:Int):Int = xs match {
    case Nil => lastSatisfied
    case x::xs => if (x._1<=m) giveCandies(xs, m, x._2) else giveCandies(xs++List((x._1-m, x._2)), m, lastSatisfied)
  }
  def main(args: Array[String]){
    val in = new java.util.Scanner(System.in)
    val n = in.nextInt
    val m = in.nextInt
    in.nextLine
    val q = in.nextLine.split(" ").map(_.toInt).zipWithIndex.toList
    print(giveCandies(q, m, -1)+1)
  }
}

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

/**
 * Created by arseny on 19.07.14.
 */
object A 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 n = nextInt
    val m = nextInt
    val a = new Array[Int](n)
    for (i <- 0 until n) {
      val t = nextInt
      a(i) = t / m
      if (t % m != 0) {
       a(i) = a(i) + 1
      }
    }
    //println(a.toList)
    var max = 0
    for (i <- 0 until n) {
      if (a(i) >= a(max)) {
        max = i
      }
    }
    out.println(max + 1)
  }

  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 CF257A extends App {
  def Process(m:Int, a:Seq[Int]):Int = {
    val dvd = a.map(v => math.ceil(v / m.toDouble).toInt)
    var maxi = -1
    var max = -1
    for(i <- 0 until dvd.length){
      if(dvd(i) >= max){
        max = dvd(i)
        maxi = i
      }
    }
    maxi + 1
  }
  val in = new Scanner(System.in)
  val n = in.nextInt()
  val m = in.nextInt()
  val ai = (1 to n).map(_=>in.nextInt())
  println(Process(m,ai.toArray))
}

object A450 {

  import IO._

  def main(args: Array[String]): Unit = {
    val Array(n, m) = readInts(2)
    val in = readInts(n).zipWithIndex
    val q = collection.mutable.Queue[(Int, Int)]()
    in.foreach(q.enqueue(_))
    while(q.size > 1) {
      var (cand, pos) = q.dequeue()
      cand -= m
      if(cand > 0)
        q.enqueue((cand, pos))
    }
    println(q.dequeue._2 + 1)
  }

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

  def splitter(as: String) = as.split("\\s+") match {
    case Array(n, m) => List(n.toInt, m.toInt)
    case arr: Array[String] => arr.map(_.toInt).toList
  }

  def solve(l: List[(Int, Int)], m: Int): Int = l match {
    case h :: Nil => h._2
    case h :: t if (h._1 <= m) => solve(t, m)
    case h :: t => solve(t :+ (h._1 - m, h._2), m)
  }

  def main(args: Array[String]) {
    val List(nmStr, asStr) = io.Source.stdin.getLines.take(2).toList
    val List(n, m) = splitter(nmStr)
    val as = splitter(asStr).zipWithIndex
    println(solve(as, m) + 1)
  }
}

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

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

  val as: Array[Int] = readLine()
    .split(" ")
    .map(_.toInt)

  val max: Int = as.max

  val res: Int =
    if (max > m) {val bs = as.map(a => (a.toDouble / m).ceil.toInt); bs.lastIndexOf(bs.max)+1}

    else
      as.length

  println(res)

}}

object Main {
  def main(args: Array[String]): Unit = {
    val nm = io.StdIn.readLine().split(" ").map(x => Integer.parseInt(x))
    val nums = io.StdIn.readLine().split(" ").map { x=>
      val i = Integer.parseInt(x)
      if  (i % nm(1) != 0) i/nm(1) + 1 else i/nm(1)
    }

    def indexOfMax( maxIndex: Int, index: Int): Int = {
      if (index < 0) maxIndex
      else indexOfMax(if (nums(index) > nums(maxIndex)) index else maxIndex, index - 1)
    }

    println(indexOfMax(nm(0)-1, nm(0)-1) + 1)
  }
}

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

/**
 * Created by arseny on 19.07.14.
 */
object A 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 n = nextInt
    val m = nextInt
    val a = new Array[Int](n)
    for (i <- 0 until n) {
       a(i) = Math.max(nextInt / m, 1)
    }
    var max = 0
    for (i <- 0 until n) {
      if (a(i) >= a(max)) {
        max = i
      }
    }
    out.println(max + 1)
  }

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

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

/**
 * Created by arseny on 19.07.14.
 */
object A 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 n = nextInt
    val m = nextInt
    val a = new Array[Int](n)
    for (i <- 0 until n) {
       a(i) = (nextInt) / m
    }
    var max = 0
    for (i <- 0 until n) {
      if (a(i) >= a(max)) {
        max = i
      }
    }
    out.println(max + 1)
  }

  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 CF257A extends App {
  def Process(m:Int, a:Seq[Int]):Int = {
    val dvd = a.map(_ / m)
    var maxi = -1
    var max = -1
    for(i <- 0 until dvd.length){
      if(dvd(i) >= max){
        max = dvd(i)
        maxi = i
      }
    }
    maxi + 1
  }
  val in = new Scanner(System.in)
  val n = in.nextInt()
  val m = in.nextInt()
  val ai = (1 to n).map(_=>in.nextInt())
  println(Process(m,ai))
}

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

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

  val as: Array[Int] = readLine()
    .split(" ")
    .map(_.toInt)

  val max: Int = as.max

  val res: Int =
    if (max > m) {val bs = as.map(_ / m); bs.lastIndexOf(bs.max)+1}

    else
      as.length

  println(res)

}}

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

  val line: String = readLine()

  val asString: String = readLine()
  val as: Array[Int] = asString.split(" ")
    .map(_.toInt)

  val of: Int = as.lastIndexOf(as.max)

  println(of+1)

}}

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

  val line: String = readLine()

  val asString: String = readLine()
  val as: Array[Int] = asString.split(" ")
    .map(_.toInt)

  val of: Int = as.lastIndexOf(as.max)

  println(of)

}}

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

  val line: String = readLine()
  val Array(n, m) = line.split(" ").map(_.toInt)

  val asString: String = readLine()
  val as: Array[Int] = asString.split(" ")
    .map(_.toInt)

  val max: Int = as.max
  val of: Int =
    if (max > m)
      as.lastIndexOf(max)
    else
      as.length-1

  println(of+1)

}}

object Main {
  def main(args: Array[String]): Unit = {
    val nm = io.StdIn.readLine().split(" ").map(x => Integer.parseInt(x))
    val nums = io.StdIn.readLine().split(" ")
    def indexOfMax( maxIndex: Int, index: Int): Int = {
      if (index < 0) maxIndex
      else indexOfMax(if (nums(index) > nums(maxIndex)) index else maxIndex, index - 1)
    }
    println(indexOfMax(nm(0)-1, nm(0)-1) + 1)
  }
}

import scala.annotation.tailrec

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n,m = sc.nextInt
  val children = List.fill(n)(sc.nextInt).zipWithIndex

  @tailrec
  def dist(children: List[(Int,Int)]): Unit = {
    children match {
      case Nil =>
      case List(x) => println(x._2 + 1)
      case x::xs =>
        val diff = x._1 - m
        if( diff < 0 )
          dist(xs)
        else
          dist( ( (diff, x._2) :: xs).reverse )
    }
  }

  dist(children)
}


object P131C extends App {

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

  def fac(a:BigInt,n:Int):BigInt = if (n<=2) a*math.max(n,1) else fac(a*n,n-1)
  def mofn(m:Int,n:Int) = fac(1,n) / fac(1,n-m) / fac(1,m)

  val combs = (for(boys <- 4 to n; girls <- 1 to m) yield((boys,girls))) filter ((x) => x._1 + x._2 == t)

  println(combs.map((x) => mofn(x._1,n) * mofn(x._2,m)).sum)

}

object P131C extends App {
  val Array(n,m,t) = readLine.split(" ").map(_.toInt)
  def f(a:BigInt, n:Int):BigInt = if (n<=2) a*math.max(n,1) else f(a*n, n-1)
  def m(m:Int, n:Int) = f(1,n)/f(1,n-m)/f(1,m)
  val c = (for(b <- 4 to n; g <- 1 to m) yield((b,g))) filter ((x)=>x._1+x._2==t)
  println(c.map((x) => m(x._1,n) * m(x._2,m)).sum)
}

import scala.io.Source

object Solution extends App {
  val in = Source.stdin.getLines()
  val arr@Array(n, m, t) = in.next().split(' ').map(_.toInt)
  val max = arr.max
  val binom = Array.ofDim[Long](max + 1, max + 1)
  (0 to max).foreach { i =>
    binom(i)(0) = 1
    (1 to i).foreach {j =>
      binom(i)(j) = binom(i - 1)(j) + binom(i - 1)(j - 1)
    }
  }
//  println(binom.map(_.mkString(" ")).mkString("\n"))

  println((1 to t - 4).foldLeft(0l) {
    case(sum, i) =>
      sum + binom(m)(i) * binom(n)(t - i)
  })
}

object Main {

    def mkComb(n:Int) = {
        val a = Array.ofDim[Long](n, n)
        for (i <- 0 until n) {
            a(i)(0) = 1L
            a(i)(i) = 1L
            for (j <- 1 until i)
                a(i)(j) = a(i-1)(j) + a(i-1)(j-1)
        }
        a
    }

    def main(args: Array[String]) {
        val comb = mkComb(31)
        val n = nextInt()
        val m = nextInt()
        val actors = nextInt()
        val ans = for ( boys <- 0 to actors;
                        girls = actors - boys
                        if boys >= 4 && boys <= n
                        if girls >= 1 && girls <= m
                      ) yield (comb(n)(boys) * comb(m)(girls))
        println(ans.sum)
    }

    val in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
    var st = new java.util.StringTokenizer("");

    def next() = {
        while (!st.hasMoreTokens())
            st = new java.util.StringTokenizer(in.readLine());
        st.nextToken();
    }

    def nextInt() = java.lang.Integer.parseInt(next());
    def nextDouble() = java.lang.Double.parseDouble(next());
    def nextLong() = java.lang.Long.parseLong(next());
}

object C131 {
	def fact(t: Int): BigInt = if (t <= 1) BigInt(1) else t * fact(t - 1)
	implicit def implfact(t: Int) = new { def ! = fact(t)}

	def c(n: Int, k: Int): BigInt = (n!)/((k!) * ((n - k)!))

	def main(args: Array[String]) {
		val s = readLine.split(" ")
		val n = Integer.parseInt(s(0))
		val m = Integer.parseInt(s(1))
		val t = Integer.parseInt(s(2))
		var res = BigInt(0)
		for (i <- 4 to n)
			for (j <- 1 to m)
				if (i + j == t)
					res += c(n, i) * c(m, j)
		println(res)
	}
}

object Main {
  val cache: Array[Array[Long]] = (1 to 61).map(_ => (1L to 61L).toArray).toArray
  for{
    i <- 0 to 60
    j <- 0 to 60
  } {
    (i, j) match {
      case (n, 0) => cache(n)(0) = 1
      case (0, k) => cache(0)(k) = 0
      case (n, k) => cache(n)(k) = cache(n - 1)(k - 1) + cache(n - 1)(k)
    }
  }

  def main(args: Array[String]) {
    val Array(n, m, k) = readLine().split(" ").map(_.toInt)
    val sum = (4 to n.min(k - 1)).map(i => cache(n)(i) * cache(m)(k - i)).sum
    println(sum)
  }
}

import scala.io.Source

object Solution extends App {

  def factorial(n: Int) = (1 to n).foldLeft(1l) { case(acc, i) => acc * i }

  def combinations(k: Int, n: Int) = factorial(n) / (factorial(k) * factorial(n - k))

  val in = Source.stdin.getLines()
  val Array(n, m, t) = in.next().split(' ').map(_.toInt)
  println((1 to t - 4).foldLeft(0l) {
    case(sum, i) => sum + combinations(i, m) * combinations(t - i, n)
  })
}


import scala.io.StdIn._

object B extends App {
  val Array(n) = readLine().split(" ").map(_.toInt)

  val M = 1000000007

  def countMod(base: Int, power: Int): Long = {
    var curr: Long = base
    for (i <- 2 to power) {
      curr *= base
      if (curr > M) curr %= M
    }
    curr
  }

//  def countMod2(base: Int, power: Int): Long = {
//    BigInt(base).modPow(power, M).toLong
//  }

  val answer = countMod(27, n) - countMod(7, n)
  println(if (answer < 0) M + answer else answer)

}

/**
 * @author netman
 */

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

object HelloWorld {

  class InputReader(reader: BufferedReader) {

    var tokenizer: StringTokenizer = null;

    def this(stream: InputStream) = {
      this(new BufferedReader(new InputStreamReader(stream), (1 << 20)));
    }

    def this(f: File) = {
      this(new BufferedReader(new FileReader(f), (1 << 20)));
    }

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

    def nextInt(): Int = next().toInt

    def nextDouble(): Double = next().toDouble

    def close() = reader.close();
  }

  class OutputWriter(writer: PrintWriter) {
    def this(stream: OutputStream) {
      this(new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream))));
    }

    def this(f: File) = {
      this(new PrintWriter(new BufferedWriter(new FileWriter(f))));
    }

    def print(x: Any) = writer.print(x);

    def println(x: Any) = writer.println(x);

    def close() = writer.close();
  }

  val in = new InputReader(System.in)
  val out = new OutputWriter(System.out)

  val P = 1000 * 1000 * 1000L + 7

  def main(args: Array[String]): Unit = {
    val n = in.nextInt

    var f = new Array[Long](2)
    var fn = new Array[Long](2)

    f(0) = 1

    val coef = 7L
    val all = 3 * 3 * 3L

    for (i <- 0 until n) {
      fn(0) = f(0) * coef
      fn(1) = f(1) * all + f(0) * (all - coef)
      fn(0) %= P
      fn(1) %= P
      var tmp = f
      f = fn
      fn = tmp
    }

    out.println(f(1))

    out.close
  }
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()

  val n = in.next().toInt
  var ans = (BigInt(3).pow(3 * n) - BigInt(7).pow(n)) % 1000000007
  println(ans.toLong)
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()

  val n = in.next().toLong
  println((Math.pow(3, 3 * n) - Math.pow(7, n)).toLong % 1000000007)
}

import scala.io.StdIn._

object B extends App {
  val Array(n) = readLine().split(" ").map(_.toInt)

  val M = 1000000007

  def countMod(base: Int, power: Int): Long = {
    var curr: Long = base
    for (i <- 2 to power) {
      curr *= base
      if (curr > M) curr %= M
    }
    curr
  }

  println(countMod(27, n) - countMod(7, n))

}

import scala.io.StdIn._

object B extends App {
  val Array(n) = readLine().split(" ").map(_.toInt)

  val M = 1000000007

  def countMod(base: Int, power: Int): Long = {
    var curr: Long = base
    for (i <- 2 to power) {
      curr *= base
      if (curr > M) curr %= M
    }
    curr
  }

  val answer = countMod(27, n) - countMod(7, n)
  println(if (answer < 0) M - answer else answer)

}

import scala.io.StdIn._

object B extends App {
  val Array(n) = readLine().split(" ").map(_.toInt)

  val M = 1000000007

  def countMod(base: Int, power: Int): Long = {
    var curr: Long = base
    for (i <- 2 to power) {
      curr *= base
      if (curr > M) curr %= M
    }
    curr
  }

  def countMod2(base: Int, power: Int): Long = {
    BigInt(base).modPow(power, M).toLong
  }

  val answer = countMod2(27, n) - countMod2(7, n)
  println(if (answer < 0) M - answer else answer)

}


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

object Main extends App {
  readLine()
  val a = readLine().split("0", -1)
  var res = ""
  a.foreach(x => res += x.length)
  println(res)
}

object Main extends App {
  val n = io.StdIn.readInt()
  var s: String = io.StdIn.readLine()

  var result = ""
  while(!s.isEmpty){
    if (s.head == '0') s = s.tail
    val (head, tail) = s.span(_ == '1')
    result += head.length.toString
    s = tail
  }
  println(result)
}

object Main extends App {
  scala.io.StdIn.readLine()
  print(scala.io.StdIn.readLine().split("0", -1).map(_.length).mkString(""))
}

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

object Main extends App {
  readLine()
  val a = readLine().split('0')
  var res = ""
  a.foreach(x => res += x.length)
  println(res)
}

object Main extends App {
  scala.io.StdIn.readLine()
  print(scala.io.StdIn.readLine().split("0").map(_.length).mkString(""))
}


object A586 {

  import IO._

  def main(args: Array[String]): Unit = {
    val Array(n) = readInts(1)
    val in = readInts(n).dropWhile(_ == 0).reverse.dropWhile(_ == 0).reverse
    var res = 0
    var curr = 0
    for(i <- in.indices) {
      if(in(i) == 0) {
        curr += 1
        res += 1
      } else {
        res += 1
        if(curr > 1)
          res -= curr
        curr = 0
      }
    }
    println(res)
  }

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

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

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

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

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

}

import java.io._

//32A, 586A
object A_AlenaSchedule {

  def main(args: Array[String]): Unit = {
    val bis = new BufferedInputStream(System.in);
    val br = new BufferedReader(new InputStreamReader(bis));

    val number = br.readLine().trim().toInt
    val pairsSrc = br.readLine().trim().split(" ")

//    val number = 5
//    val pairsSrc = "0 1 0 1 1".split(" ")

//    val number = 7
//    val pairsSrc = "1 0 1 0 0 1 0".split(" ")

    var pairs = List[Int]()
    var break = true
    var breakCandidate = false;

    for (i <- 0 until number) {
      val value = pairsSrc(i).toInt
      if (breakCandidate && value == 0) {
        break = true
        breakCandidate = false
      } else if (break && value == 0) {
        //skip
      } else if (value == 1) {
        break = false
        if (breakCandidate) {
          pairs = 0 :: pairs
          breakCandidate = false
        }
        pairs = value :: pairs
      } else if (!break && value == 0) {
        if(!breakCandidate) {
          breakCandidate = true
        }
      }
    }

    println(pairs.size)

  }
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val n = in.next().toInt
  val data = in.next().split(" ").map(_.toInt).dropWhile(_ == 0).reverse.dropWhile(_ == 0).reverse
  val res = data.foldLeft((0, 0)){
    case((soFar, zeros), 1) if zeros < 2 => (soFar + zeros + 1, 0)
    case((soFar, zeros), 1) => (soFar + 1, 0)
    case((soFar, zeros), 0) => (soFar, zeros + 1)
  }

  println(res._1)

}

import scala.io.StdIn._

object A extends App {
  readInt()

  val pairs = readLine().split(" ").map(_.toInt).dropWhile(_ == 0).reverse.dropWhile(_ == 0)

  var lastlast = 1
  var last = 1
  var zeros = 0
  for (p <- pairs) {
    if (p == 0) {
      if (last == 0 && lastlast == 0) zeros += 1
      else if (last == 0) zeros += 2
    }

    lastlast = last
    last = p
  }

  println(pairs.length - zeros)
}


import scala.collection._

object B extends App {

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

  val Array(n, k) = readInts(2)

  var res = 0L

  val lim = math.min(k, n / 2)
  for (i <- 1 to lim) {
    val x = n - 2 * i
    res += 2 * x + 1
  }

  println(res)
}

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

object _645B extends CodeForcesApp {
  override def apply(io: IO) = {
    val n, k = io[Long]
    io += solve(n, k, 0)
  }

  @tailrec
  def solve(n: Long, k: Long, acc: Long): Long = {
    //debug(n, k)
    (n, k) match {
      case (_, 0) => acc
      case (1, _) | (0, _) => acc
      case _ =>  solve(n - 2, k - 1, acc + (n - 2) + (n - 1))
    }
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: Any): Unit = if (!isOnlineJudge) println(x)
  def apply(io: IO): io.type
  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()
}
object Utils {
  import scala.collection.mutable, mutable.{Map => Dict}
  implicit class GenericExtensions[A](val a: A) extends AnyVal {
    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a
  }
  implicit class TraversableExtensions[A](val t: Traversable[A]) extends AnyVal {
    def onlyElement: A = t.head.ensuring(t.size == 1)
    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)
    def duplicates: Traversable[A] = {
      val elems = mutable.Set.empty[A]
      t collect {case i if !elems.add(i) => i}
    }
    def zipWith[B](f: A => B): Traversable[(A, B)] = t map {i => i -> f(i)}
    def mapTo[B](f: A => B): Map[A, B] = zipWith(f).toUniqueMap
    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)
    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}
    def toMutableMultiSet: Dict[A, Int] = {
      val c = map[A] to 0
      t.foreach(i => c(i) += 1)
      c
    }
    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap
  }
  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)
  }
  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)
  }
  implicit class IndexedSeqExtensions[A](val s: IndexedSeq[A]) extends AnyVal {
    def withOffset(offset: Int): IndexedSeq[A] = Iterator.fill(offset)(null.asInstanceOf[A]) ++: s
  }
  implicit class PairsExtensions[A, B](val t: Traversable[(A, B)]) extends AnyVal {
    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_._1).mapValues(_._2)
    def toMultiMap: Map[A, Traversable[B]] = t.groupBy(_._1).mapValues(_.map(_._2))
    def swap: Traversable[(B, A)] = t.map(_.swap)
  }
  implicit class MapExtensions[K, V](val m: Map[K, V]) extends AnyVal {
    def invert: Map[V, Set[K]] = m.swap.toMultiMap.mapValues(_.toSet)
    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}
  }
  implicit class LongExtensions(val x: Long) extends AnyVal {
    def bitCount: Int = java.lang.Long.bitCount(x)
  }
  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {
    import Numeric.Implicits._
    def ^^(i: Int): A = if (i == 0) n.one else {
      val h = x ^^ (i/2)
      if (i%2 == 0) h * h else h * h * x
    }
    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)
    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students.indexOf("Greg").whenNegative Int.MaxValue
  }
  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {
    import scala.collection.immutable.NumericRange, Integral.Implicits._
    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x
    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(n.min(x, y), n.max(x, y), n.one)
  }
  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)
  def  asc[A](implicit order: Ordering[A]): Ordering[A] = order
  def map[K] = new {
    def to[V](default: V): Dict[K, V] = Dict.empty[K, V] withDefaultValue default
  }
  def memoize[I] = new {
    def apply[O](f: I => O): I => O = new mutable.HashMap[I, O]() {
      override def apply(key: I) = getOrElseUpdate(key, f(key))
    }
  }
  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) Some(f) else None
  def repeat(n: Int)(f: => Unit): Unit = (1 to n).foreach(_ => f)
  val mod: Int = (1e9 + 7).toInt
}
/***********************************[Scala I/O]*********************************************/
import Utils._, java.io._, java.util.StringTokenizer, scala.collection.generic.CanBuild

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

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

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

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

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

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

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

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

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


object Main extends App{
  val in= readLine
  val n =in.toInt
  if(List(4,7,44,47,74,77,444,447,474,477,744,747,774,777).exists(t => n % t ==0))
    println("YES")else println("NO")
}

object Divider{

  def main(args: Array[String]): Unit = {
    val n = readInt()

    val list = List(4,7,47,74,444,447,474,477,744,774,747,777)

    if(list.contains(n) || list.exists(x => n % x == 0) ) println("YES") else print("NO")
  }
}

object One22A extends App {

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

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

	val n = in.nextInt

	lucky(n) match {
		case true => yes
		case false =>
			(4 to n - 1).exists(lucky) match {
				case true => yes
				case false => no
			}
	}

	in.close()
	out.close()

	def yes = out.println("YES")
	def no = out.println("NO")
	def lucky(str: Int) = n % str == 0 && str.toString.forall(x => x == '4' || x == '7')

}

object CF0122A extends App {

  val l = List(4, 7, 47, 74, 444, 447, 474, 744, 774, 747, 777)

  def del(v: Int): Boolean = {

    var t = false

    l.foreach(n => {
      if (v%n == 0) {
        t = true
      }
    })

    t
  }

  val str = readLine()
  val value = str.toInt
  if (value % 4 == 0 || value % 7 == 0 || del(value)) {
    println("YES")
  } else {
    val status = str.getBytes.forall(b => {
      b == '4' || b == '7'
    })

    if (status) {
      println("YES")
    } else {
      println("NO")
    }
  }

}

import scala.io.StdIn

object Task {

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

    val x: Int = StdIn.readInt()
    if (solve(x)) {
      println("YES")
    }
    else {
      println("NO")
    }

  }

  private def solve(x: Int): Boolean = {

    val lucky: Array[Int] = Array(4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777)
    for (l <- lucky) {
      if (x % l == 0) {
        return true
      }
    }
    return false

  }

}

import scala.collection.immutable

object Hello extends App {

  import scala.io.StdIn._

  val k = readInt()

  def countNums(n: Int): Int = n.toString.length

  def permutationsWithRepetitions[T](input : List[T], n : Int) : List[List[T]] = {
    require(input.nonEmpty && n > 0)
    n match {
      case 1 => for (el <- input) yield List(el)
      case _ => for (el <- input; perm <- permutationsWithRepetitions(input, n - 1)) yield el :: perm
    }
  }

  def allPermutationsWithRepetitions[T](input : List[T], n : Int, result: List[List[List[T]]]): List[List[List[T]]] =
    if (n == 0) result
    else allPermutationsWithRepetitions(input, n - 1, result :+ permutationsWithRepetitions(input, n))

  val nums: immutable.Seq[Int] = allPermutationsWithRepetitions(List(4, 7), countNums(k), List()).flatten.map(_.mkString("")).map(Integer.parseInt)

  if (nums.exists(k % _ == 0) || nums.contains(k)) println("YES") else println("NO")
}

import scala.io.StdIn._

object HappyNum extends App {
  val num = readInt
  var ok = false

  val list = List(4, 7, 44, 47, 74, 77, 444, 447, 477, 474, 744, 747, 774, 777)

  if (list.contains(num)) {
    ok = true
  }else {
    for(i <- list){
      if (num % i == 0) ok = true
    }
  }

  if (ok) print("YES")
  else print("NO")

}

object a {
	def main(args: Array[String]) {
	    val a = scala.io.StdIn.readInt()
        var ans = List(4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777).
            map(arg => a%arg).
	        exists(arg => arg == 0)

        print(if (ans) "YES" else "NO")
	}
}

import scala.io.StdIn
import scala.util.control.Breaks

/**
  * @author traff
  */

object Main extends App {
  val n = StdIn.readLine().toInt

  Breaks.breakable {
    for (i <- 2 to n) {
      if (n % i == 0 && !i.toString.exists(!"47".contains(_))) {
        println("YES")
        Breaks.break()
      }
    }
    println("NO")
  }
}

object Solution extends App{
  val in = scala.io.Source.stdin.getLines()
  val n = in.next().toInt
  if (List(4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777).exists(t => n % t == 0))
    println("YES") else println("NO")
}

import scala.collection.mutable.ArrayBuffer

object Main {

  def generateLuckyMumbers(buf: ArrayBuffer[Int], maxValue: Int, currentValue: Int): Unit = {
    if (currentValue <= maxValue) {
      buf.append(currentValue)
      generateLuckyMumbers(buf, maxValue, currentValue * 10 + 4)
      generateLuckyMumbers(buf, maxValue, currentValue * 10 + 7)
    }
  }

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

    val luckyNumbers = ArrayBuffer.empty[Int]
    generateLuckyMumbers(luckyNumbers, number, 4)
    generateLuckyMumbers(luckyNumbers, number, 7)
    val result = luckyNumbers.exists(x => number % x == 0)
    if (result) {
      println("YES")
    }
    else {
      println("NO")
    }
  }
}

import scala.io.StdIn

/**
 * Created by richard on 2015/6/10.
 */
object cf112a {
  def main(args: Array[String]): Unit = {
    val num = Array(4,7,47,74,447,474,477,744,747,774,777)
    val n = StdIn.readInt()
    println(if (num.exists(n%_==0)) "YES" else "NO")
  }
}

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

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

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

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

  def main(args: Array[String]): Unit = {
    val Array(num) = readBigs(1)
    val lucky = Array("4", "7", "44", "47", "74", "77", "444", "447", "474", "477", "744", "747", "774", "777").map(BigInt.apply)
    if(lucky.exists{n => (num % n) == 0}) {
      println("YES")
    } else {
      println("NO")
    }
  }
}

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

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

  val luckyNumbers = (1 to 1000).filter { n =>
      n.toString.forall(c => c == '4' || c == '7')
    }

  def isAlmostLucky(i: Int): Boolean =
    luckyNumbers.find(i % _ == 0) match {
      case None => false
      case Some(_) => true
    }

  def solve: String =
    if (isAlmostLucky(sc.nextInt)) "YES"
    else "NO"

  out.println(solve)
  out.close
}

object LuckyDivision {
	def main (args: Array[String]) {
		val scanner = new java.util.Scanner(System.in);
		val input = scanner.nextInt();
		if (isLucky(input)) {
			println("YES")
			System.exit(0)
		}
		for (i <- 1 to input / 2) {
			if (input % i == 0 && isLucky(i)) {
				println("YES")
				System.exit(0)
			}
		}
		println("NO")
	}

	def isLucky(in: Int) : Boolean = {
			var lucky = true;
			var tmp = in;
			while (lucky && tmp > 0) {
				val rem = tmp % 10;
				if (rem != 4 && rem != 7) {
					lucky = false
				}
				tmp /= 10
			}
			lucky
	}
}

import scala.io.StdIn._

object LuckyDivision extends App {

  def isLucky(i: Int): Boolean = i match {
    case 0 => true
    case _ => (i%10 == 4 || i%10 == 7) && isLucky(i / 10)
  }

  def isAlmostLucky(i: Int, d: Int): Boolean = d match {
    case 0 => false
    case _ => (i%d == 0 && isLucky(d)) || isAlmostLucky(i, d-1)
  }

  val s = readInt
  println(if(isAlmostLucky(s, s)) "YES" else "NO")
}

object Codeforces122A extends App{

  def CreateLuckyNumberSet:List[Int] = {
    var luckyset:List[Int] = List()
    luckyset = List(4,7,44,47,74,77,444,447,474,477,744,747,774,777)
    return luckyset
  }
  def TestAlmostLuckyNumber(query:Int):Boolean={
    val luckyset:List[Int] = CreateLuckyNumberSet
    for (i <- luckyset){
      if (query%i == 0){
        return true
      }
    }
    return false
  }
  var query:Int=scala.io.StdIn.readInt
  var ans:Boolean = TestAlmostLuckyNumber(query)
  if (ans == true){
    println("YES")
  }
  else {
    println("NO")
  }
}

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

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

  def limitedStream(cur: Int, sqr: Int): Stream[Int] = if(cur * cur > sqr) Stream.Empty else cur #:: limitedStream(cur + 1, sqr)
  def dividersStream(n: Int) = limitedStream(1, n).filter(n % _ == 0)
  def allDividersStream(n: Int) = dividersStream(n).flatMap { x =>
    Stream(x, n / x)
  }
  def beautifulInt(x: Int) = x.toString.forall("47".contains(_))
  def beautifulDividersStream(n: Int) = allDividersStream(n).filter(beautifulInt)

  def main(a: Array[String]) {
    println(if(beautifulDividersStream(readInt).isEmpty) "NO" else "YES")
  }
}

object Main {
  val happy: Stream[Int] = {
    def nextGen(ls: List[Int], gen: Int): Stream[Int] = {
      val nextLs = List(4, 7).flatMap(e => ls.map(e * gen +))
      nextLs.toStream #::: nextGen(nextLs, gen * 10)
    }
    nextGen(List(0), 1)
  }

  def main(args: Array[String]) {
    val num = readInt()
    var isHappy = false
    for(h <- happy.takeWhile(_ <= num)) {
      if (num % h == 0) isHappy |= true
    }
    if (isHappy) println("YES")
    else println("NO")
  }
}

// Codeforces 122A

object _122A extends App {
  val scanner = new java.util.Scanner(System.in)
  val lucky_numbers = List(4, 7, 47, 74, 447, 474, 477, 747)
  val n = scanner.nextInt
  println(
    if (lucky_numbers.exists(n%_ == 0)) "YES" else "NO"
  )
}

import scala.io.StdIn._

object A_122 extends App {
  val n = readInt()

  def isLucky(x: Int) = x.toString.toCharArray.toSet.forall(x => x == '4' || x == '7')

  val L = 1 to 1000 filter isLucky

  if (L.contains(n) || L.exists(l => n % l == 0)) println("YES")
  else println("NO")
}

import scala.io.StdIn.readLine
object problem {
  def main(args: Array[String]) {
    val s = readLine.toInt
  println(if(List(4,7,47,74,447,477,744,747).exists(s%_ == 0)) "YES" else "NO")
  }
}

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

        import scala.io.StdIn

        var number: Int = Integer.parseInt(StdIn.readLine())
        var string: String = ""
        var out: String = "NO"

        string = String.valueOf(number)
        string = string.replace("4","")
        string = string.replace("7","")
        if (string.equals("")){
            out = "YES"
        }

        for (i <- 4 to number){

            string = String.valueOf(i)
            string = string.replace("4","")
            string = string.replace("7","")
            if (string.equals("") && number%i == 0){
              out = "YES"
            }
        }

        println(out)

  }
}

import scala.io.StdIn._

object HelloWorldMain {

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

    val luckOrNot = readInt()

    val allLuckies = for( i <- 1 to 1000 if i.toString.matches("(4|7)*") )  yield i

    var result = "NO"
    allLuckies.foreach(i => if(luckOrNot % i == 0 ) result = "YES" )

    println(result)

  }
}

import scala.io.StdIn.readInt

object LuckyNumbers {

   def main(args: Array[String]) {
     val n = readInt
     if (Range(1,n).inclusive.
        filter { p => p.toString().toSet subsetOf Set('4','7') }.
        exists(n%_ == 0))
       println("YES")
     else
       println("NO")
   }

}

import scala.io.StdIn._

object cf extends App
{
    val v = readInt
    print(if(List(4,7,44,47,74,77,444,447,474,477,744,747,774,777).exists(kuy => v%kuy==0)) "YES" else "NO")
}

import scala.io.StdIn._

object Task extends App{
	val N = readLine.split(" ").map{_.toInt}.head

	def isLucky(n:Int):Boolean = {
    def aux(n:Int, div:String):Boolean = {
      val d = div.toInt

      if(n < d)
        false
      else if(n % d == 0)
        true
      else {
        aux(n, div + "4") || aux(n, div + "7")
      }
    }

    aux(n, "4") || aux(n, "7")
	}

	if(isLucky(N))
	  println("YES")
	else
	  println("NO")
}

import scala.io.StdIn._

object Solution {

	var n = readInt

	def isLucky(n:Int):Boolean = {
		var nst = n.toString
		var ret = true
		for(i <- 0 until nst.size) {
			if(nst(i) != '4' && nst(i) != '7') ret = false
		}
		ret
	}

	def main(args:Array[String]):Unit = {
		var almostLucky = false
		for(i <- 1 to n) {
			if(isLucky(i) && !almostLucky && n%i == 0) {
				println("YES")
				almostLucky = true
			}
		}
		if(!almostLucky) println("NO")
	}

}

object HappyNum extends App {
  val num = readLine()
  val numnum = num.toInt
  val listNum = num.toList
  var ok = true

  for(i <- listNum){
    if (i != '4' && i != '7'){
      ok = false
    }
  }
  if (!ok && numnum % 7 == 0 || numnum % 4 == 0){
    ok = true
  }
  if (ok) print("YES")
  else print("NO")
}

import scala.io.StdIn._

object HappyNum extends App {
  val num = readInt
  var ok = false

  val list = List(4, 7, 44, 47, 74, 77, 444, 447, 474, 744, 747, 774, 777)

  if (list.contains(num)) {
    ok = true
  }else {
    for(i <- list){
      if (num % i == 0) ok = true
    }
  }

  if (ok) print("YES")
  else print("NO")

}

object LuckyDivision {
	def main (args: Array[String]) {
		val scanner = new java.util.Scanner(System.in);
		val input = scanner.nextInt();
		if (isLucky(input)) {
			println("YES")
			System.exit(0)
		}
		val sqrtInput = Math.round (Math.sqrt(input))
				for (i <- 1 to sqrtInput.toInt) {
					if (isLucky(i) && input % i == 0) {
						println("YES")
						System.exit(0)
					}
				}
		println("NO")
	}

	def isLucky(in: Int) : Boolean = {
			var lucky = true
					var tmp = in
					while (lucky && tmp > 0) {
						val rem = tmp % 10
								if (rem != 4 && rem != 7) {
									lucky = false
								}
						tmp = tmp / 10
					}
			lucky
	}
}

object LuckyDivision {
	def main (args: Array[String]) {
		val scanner = new java.util.Scanner(System.in);
		val input = scanner.nextInt();
		if (isLucky(input)) {
			println("YES")
			System.exit(0)
		}
		val sqrtInput = Math.round (Math.sqrt(input))
				for (i <- 1 to sqrtInput.toInt + 1) {
					if (isLucky(i) && input % i == 0) {
						println("YES")
						System.exit(0)
					}
				}
		println("NO")
	}

	def isLucky(in: Int) : Boolean = {
			var lucky = true
					var tmp = in
					while (lucky && tmp > 0) {
						val rem = tmp % 10
								if (rem != 4 && rem != 7) {
									lucky = false
								}
						tmp = tmp / 10
					}
			lucky
	}
}

object CF0122A extends App {

  val str = readLine()
  val value = str.toInt
  if (value % 4 == 0 || value % 7 == 0) {
    println("YES")
  } else {
    val status = str.getBytes.forall(b => {
      b == '4' || b == '7'
    })

    if (status) {
      println("YES")
    } else {
      println("NO")
    }
  }

}


object A extends App {

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

  val Array(n) = readInts(1)
  val s = readLine

  val ok = (!(s.contains("CC") || s.contains("YY") || s.contains("MM"))) &&
    (s.startsWith("?") || s.endsWith("?") || s.contains("??") ||
      s.contains("C?C") || s.contains("Y?Y") || s.contains("M?M"))

  println(if (ok) "Yes" else "No")
}

object objecta {
    import java.io.{BufferedReader, FileInputStream, InputStreamReader}
    import scala.collection.mutable
    import scala.util.control.Breaks._

    val source = System.in
    //new FileInputStream("D://in.txt")
    implicit val reader = new BufferedReader(new InputStreamReader(source))

    def read()(implicit reader: BufferedReader): String = reader.readLine().split(" ")(0)
    def readArray()(implicit reader: BufferedReader): Array[String] = reader.readLine().split(" ")
    def readString()(implicit reader: BufferedReader): String = reader.readLine()

    def main(args: Array[String]): Unit = {
        val n = read.toInt
        val s = readString

        for (i <- 0 until n - 1)
            if (s(i) != '?' && s(i) == s(i + 1)){
                print("NO")
                return
            }

        if (s(0) == '?' || s(n - 1) == '?') {
            print("YES")
            return
        }

        for (i <- 1 until n - 2)
            if (s(i) == '?') {
                if (s(i + 1) == '?') {
                    print("YES")
                    return
                } else if (s(i - 1) == s(i + 1)) {
                                print("YES")
                                return
                            }
            }
        print("NO")
    }
}

object objecta {
    import java.io.{BufferedReader, FileInputStream, InputStreamReader}
    import scala.collection.mutable
    import scala.util.control.Breaks._

    val source = System.in
    //new FileInputStream("D://in.txt")
    implicit val reader = new BufferedReader(new InputStreamReader(source))

    def read()(implicit reader: BufferedReader): String = reader.readLine().split(" ")(0)
    def readArray()(implicit reader: BufferedReader): Array[String] = reader.readLine().split(" ")
    def readString()(implicit reader: BufferedReader): String = reader.readLine()

    def main(args: Array[String]): Unit = {
        val n = read.toInt
        val s = readString

        for (i <- 0 until n - 1)
            if (s(i) == '?') {
                if (s(i + 1) == '?') {
                    print("YES")
                    return
                } else if (i > 0 && s(i - 1) == s(i + 1)) {
                    print("YES")
                    return
                }
            } else if (s(i) == s(i + 1)){
                print("NO")
                return
            }
        print("NO")
    }
}

object objecta {
    import java.io.{BufferedReader, FileInputStream, InputStreamReader}
    import scala.collection.mutable
    import scala.util.control.Breaks._

    val source = System.in
    //new FileInputStream("D://in.txt")
    implicit val reader = new BufferedReader(new InputStreamReader(source))

    def read()(implicit reader: BufferedReader): String = reader.readLine().split(" ")(0)
    def readArray()(implicit reader: BufferedReader): Array[String] = reader.readLine().split(" ")
    def readString()(implicit reader: BufferedReader): String = reader.readLine()

    def main(args: Array[String]): Unit = {
        val n = read.toInt
        val s = readString

        for (i <- 0 until n - 1)
            if (s(i) != '?' && s(i) == s(i + 1)){
                print("NO")
                return
            }
        for (i <- 0 until n - 1)
            if (s(i) == '?') {
                if (s(i + 1) == '?') {
                    print("YES")
                    return
                } else if (i ==0) {
                            print("YES")
                            return
                        } else if (s(i - 1) == s(i + 1)) {
                                print("YES")
                                return
                            }
            }
        print("NO")
    }
}

object objecta {
    import java.io.{BufferedReader, FileInputStream, InputStreamReader}
    import scala.collection.mutable
    import scala.util.control.Breaks._

    val source = System.in
    //new FileInputStream("D://in.txt")
    implicit val reader = new BufferedReader(new InputStreamReader(source))

    def read()(implicit reader: BufferedReader): String = reader.readLine().split(" ")(0)
    def readArray()(implicit reader: BufferedReader): Array[String] = reader.readLine().split(" ")
    def readString()(implicit reader: BufferedReader): String = reader.readLine()

    def main(args: Array[String]): Unit = {
        val n = read.toInt
        val s = readString

        if (n == 1)
            if (s(0) == '?') {
                print("YES")
                return
            } else {
                print("NO")
                return
            }

        for (i <- 0 until n - 1)
            if (s(i) != '?' && s(i) == s(i + 1)){
                print("NO")
                return
            }
        for (i <- 0 until n - 1)
            if (s(i) == '?') {
                if (s(i + 1) == '?') {
                    print("YES")
                    return
                } else if (i ==0) {
                            print("YES")
                            return
                        } else if (s(i - 1) == s(i + 1)) {
                                print("YES")
                                return
                            }
            }
        print("NO")
    }
}

object objecta {
    import java.io.{BufferedReader, FileInputStream, InputStreamReader}
    import scala.collection.mutable
    import scala.util.control.Breaks._

    val source = System.in
    //new FileInputStream("D://in.txt")
    implicit val reader = new BufferedReader(new InputStreamReader(source))

    def read()(implicit reader: BufferedReader): String = reader.readLine().split(" ")(0)
    def readArray()(implicit reader: BufferedReader): Array[String] = reader.readLine().split(" ")
    def readString()(implicit reader: BufferedReader): String = reader.readLine()

    def main(args: Array[String]): Unit = {
        val n = read.toInt
        val s = readString

        for (i <- 0 until n - 1)
            if (s(i) == s(i + 1)){
                print("NO")
                return
            }
        for (i <- 0 until n - 1)
            if (s(i) == '?') {
                if (s(i + 1) == '?') {
                    print("YES")
                    return
                } else if (i ==0) {
                            print("YES")
                            return
                        } else if (s(i - 1) == s(i + 1)) {
                                print("YES")
                                return
                            }
            }
        print("NO")
    }
}

object objecta {
    import java.io.{BufferedReader, FileInputStream, InputStreamReader}
    import scala.collection.mutable
    import scala.util.control.Breaks._

    val source = System.in
    //new FileInputStream("D://in.txt")
    implicit val reader = new BufferedReader(new InputStreamReader(source))

    def read()(implicit reader: BufferedReader): String = reader.readLine().split(" ")(0)
    def readArray()(implicit reader: BufferedReader): Array[String] = reader.readLine().split(" ")
    def readString()(implicit reader: BufferedReader): String = reader.readLine()

    def main(args: Array[String]): Unit = {
        val n = read.toInt
        val s = readString

        for (i <- 0 until n - 1)
            if (s(i + 1) != '?' && s(i) == s(i + 1)) {
                print("NO")
                return
            }
        print("YES")
    }
}

object objecta {
    import java.io.{BufferedReader, FileInputStream, InputStreamReader}
    import scala.collection.mutable
    import scala.util.control.Breaks._

    val source = System.in
    //new FileInputStream("D://in.txt")
    implicit val reader = new BufferedReader(new InputStreamReader(source))

    def read()(implicit reader: BufferedReader): String = reader.readLine().split(" ")(0)
    def readArray()(implicit reader: BufferedReader): Array[String] = reader.readLine().split(" ")
    def readString()(implicit reader: BufferedReader): String = reader.readLine()

    def main(args: Array[String]): Unit = {
        val n = read.toInt
        val s = readString

        for (i <- 0 until n - 1)
            if (s(i) == '?') {
                if (s(i + 1) == '?') {
                    print("YES")
                    return
                } else if (i ==0) {
                            print("YES")
                            return
                        } else if (s(i - 1) == s(i + 1)) {
                                print("YES")
                                return
                            }
            } else if (s(i) == s(i + 1)){
                print("NO")
                return
            }
        print("NO")
    }
}


import annotation.tailrec, collection.mutable, util.control.Breaks._, math.Ordering.Implicits._
import CodeForcesApp._
object _560B extends CodeForcesApp[Boolean]({scanner => import scanner._
  val List(a1, b1, a2, b2, a3, b3) = List.fill(6)(nextInt)
  def fit(r: R) = {
    val (x, y) = r
    //debug(x, y, a1, b1)
    (x <= a1 && y <= b1) || (x <= b1 && y <= a1)
  }
  type R = (Int, Int)
  def join(r1: R, r2: R): R = (r1._1 + r2._1, r1._2 max r2._2)
  def allSwapJoin(r1: R, r2: R): List[R] = join(r1, r2) :: join(r1, r2.swap) :: join(r1.swap, r2) :: join(r1.swap, r2.swap) :: Nil
  def allJoin(r1: R, r2: R): List[R] = allSwapJoin(r1, r2) ::: allSwapJoin(r2, r1)
  allJoin((a2, b2), (a3, b3)) exists fit
}) {
  override def format(result: Boolean) = if (result) "YES" else "NO"
}
import java.util.Scanner
abstract class CodeForcesApp[A](solver: Scanner => A) {
  final def apply(problem: String): String = apply(new Scanner(problem))
  final def apply(scanner: Scanner): String = format(solver(scanner))
  def format(result: A): String = result.toString
  final def main(args: Array[String]): Unit = println(apply(new Scanner(System.in)))
}
object CodeForcesApp {
  final def isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  final def debug(x: Any): Unit = if (!isOnlineJudge) println(x)
  final val modulus: Int = 1000000007
  final val eps: Double = 1e-9
  final def when[B](x: Boolean)(f: => B): Option[B] = if (x) Some(f) else None
  final def counter[A] = collection.mutable.Map.empty[A, Int] withDefaultValue 0
}

import io.StdIn._

object Solution {
  def main(args: Array[String]) {
    val p = readLine().split(" ").map(_.toInt).sortBy(-_)
    val a = readLine().split(" ").map(_.toInt).sortBy(-_)
    val b = readLine().split(" ").map(_.toInt).sortBy(-_)

    var found = false
    if (p(0)-a(0)>=0 && p(1)-a(1)>=0) {
      val r1 = Array(p(0)-a(0), p(1)).sortBy(-_)
      if (r1(0)>=b(0) && r1(1)>=b(1)) found = true
      else {
        val r2 = Array(p(0), p(1)-a(1)).sortBy(-_)
        if (r2(0)>=b(0) && r2(1)>=b(1)) found = true
      }
    }
    if (p(0)-a(1)>=0 && p(1)-a(0)>=0) {
      val r1 = Array(p(0)-a(1), p(1)).sortBy(-_)
      if (r1(0)>=b(0) && r1(1)>=b(1)) found = true
      else {
        val r2 = Array(p(0), p(1)-a(0)).sortBy(-_)
        if (r2(0)>=b(0) && r2(1)>=b(1)) found = true
      }
    }

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

import annotation.tailrec, collection.mutable, util.control.Breaks._, math.Ordering.Implicits._
import CodeForcesApp._
object _560B extends CodeForcesApp[Boolean]({scanner => import scanner._
  val List(a1, b1, a2, b2, a3, b3) = List.fill(6)(nextInt)
  def fit(r: R) = {
    val (x, y) = r
    //debug(x, y, a1, b1)
    (x <= a1 && y <= b1) || (x <= b1 && y <= a1)
  }
  type R = (Int, Int)
  def join(r1: R, r2: R): R = (r1._1 + r2._1, r1._2 min r2._2)
  def allSwapJoin(r1: R, r2: R): List[R] = join(r1, r2) :: join(r1, r2.swap) :: join(r1.swap, r2) :: join(r1.swap, r2.swap) :: Nil
  def allJoin(r1: R, r2: R): List[R] = allSwapJoin(r1, r2) ::: allSwapJoin(r2, r1)
  allJoin((a2, b2), (a3, b3)) exists fit
}) {
  override def format(result: Boolean) = if (result) "YES" else "NO"
}
import java.util.Scanner
abstract class CodeForcesApp[A](solver: Scanner => A) {
  final def apply(problem: String): String = apply(new Scanner(problem))
  final def apply(scanner: Scanner): String = format(solver(scanner))
  def format(result: A): String = result.toString
  final def main(args: Array[String]): Unit = println(apply(new Scanner(System.in)))
}
object CodeForcesApp {
  final def isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  final def debug(x: Any): Unit = if (!isOnlineJudge) println(x)
  final val modulus: Int = 1000000007
  final val eps: Double = 1e-9
  final def when[B](x: Boolean)(f: => B): Option[B] = if (x) Some(f) else None
  final def counter[A] = collection.mutable.Map.empty[A, Int] withDefaultValue 0
}


import scala.io.Source

object Solution extends App {

  def ceil(a: Long): String = {
    val str = a.toBinaryString
    val zeroCount = str.count(_ == '0')
    if (zeroCount == 1) str
    else if (zeroCount == 0) "10" + "1" * (str.length - 1)
    else {
      val ones = str.takeWhile(_ == '1').length
      "1" * ones + "0" + "1" * (str.length - ones - 1)
    }
  }

  def floor(a: Long): String = {
    val str = a.toBinaryString
    val zeroCount = str.count(_ == '0')
    if (zeroCount == 1) str
    else if (zeroCount == 0) str.dropRight(1) + '0'
    else {
      val ones = str.takeWhile(_ == '1').length
      if (ones == 1)
        "1" * (str.length - 2) + "0"
      else
        "1" * (ones - 1) + "0" + "1" * (str.length - ones)
    }
  }

  def count(aSize: Int, aZeroPosition: Int, bSize: Int, bZeroPosition: Int): Int = {
    if (aSize > bSize || (aZeroPosition > bZeroPosition && aSize == bSize)) 0
    else if (aSize == bSize && aZeroPosition == bZeroPosition) 1
    else if (aZeroPosition == aSize) count(aSize + 1, 1, bSize, bZeroPosition)
    else 1 + count(aSize, aZeroPosition + 1, bSize, bZeroPosition)
  }

  val in = Source.stdin.getLines()
  val Array(a, b) = in.next().split(' ').map(_.toLong)
  val c = ceil(a)
  val f = floor(b)
//  println(a.toBinaryString)
//  println(c)
//  println(b.toBinaryString)
//  println(f)
  println(count(c.length, c.indexOf('0'), f.length, f.indexOf('0')))
}

import scala.collection._

object B extends App {

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

  val Array(a, b) = readLongs(2)
  var res = 0L

  for (l <- 1 to 62) {
    val x = (1L << l) - 1
    for (j <- 0 until l - 1) {
      val y = x ^ (1L << j)
      if (a <= y && y <= b) {
        res += 1
      }
    }
  }
  println(res)
}

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

object Solution {

  def main(args: Array[String]) {
    val Array(n, m) = readLine().split(" ").map(_.toLong)

    var num = 0

    for (i <- 2 to 63) {
      for (j <- 0 to i-2) {
        val y = ((1.toLong<<i) - 1) ^ (1.toLong<<j)

        if (y >= n && y <= m) {
          num += 1
//          println(i+".."+j+".."+y)
        }
      }
    }

    println(num)

  }
}

import java.util.Scanner
import java.lang.Long.parseLong

object Main{
  def main (args: Array[String]){
    val sc = new Scanner(System.in)
    val a = sc.nextLong()
    val b = sc.nextLong()

    //
    val a_2 = a.toBinaryString
    val b_2 = b.toBinaryString

    val a_2l = a_2.length
    var shaku = "10"
    var flag = true
    var ans = 0L
    var digi_cnt = 1
    while(flag){
      val tn = parseLong(shaku, 2)

      if(a <= tn){
        if(b >= tn)
          ans += 1
        else
          flag = false
      }

      digi_cnt += 1
      val sl = shaku.length
      if(sl == digi_cnt){
        shaku = shaku.updated(digi_cnt - 1, '1')
        shaku = shaku ++ "1"
        shaku = shaku.updated(1, '0')
        digi_cnt = 1
      }
      else{
        shaku = shaku.updated(digi_cnt - 1, '1')
        shaku = shaku.updated(digi_cnt, '0')
      }
    }

    println(ans)
  }
}

import scala.io.Source

object Solution extends App {

  def ceil(a: Long): String = {
    val str = a.toBinaryString
    val zeroCount = str.count(_ == '0')
    if (zeroCount == 1) str
    else if (zeroCount == 0) str + '0'
    else {
      val ones = str.takeWhile(_ == '1').length
      "1" * ones + "0" + "1" * (str.length - ones - 1)
    }
  }

  def floor(a: Long): String = {
    val str = a.toBinaryString
    val zeroCount = str.count(_ == '0')
    if (zeroCount == 1) str
    else if (zeroCount == 0) str.dropRight(1) + '0'
    else {
      val ones = str.takeWhile(_ == '1').length
      if (ones == 1)
        "1" * (str.length - 2) + "0"
      else
        "1" * (ones - 1) + "0" + "1" * (str.length - ones)
    }
  }

  def count(aSize: Int, aZeroPosition: Int, bSize: Int, bZeroPosition: Int): Int = {
    if (aSize > bSize || (aZeroPosition > bZeroPosition && aSize == bSize)) 0
    else if (aSize == bSize && aZeroPosition == bZeroPosition) 1
    else if (aZeroPosition == aSize) count(aSize + 1, 0, bSize, bZeroPosition)
    else 1 + count(aSize, aZeroPosition + 1, bSize, bZeroPosition)
  }

  val in = Source.stdin.getLines()
  val Array(a, b) = in.next().split(' ').map(_.toLong)
  val c = ceil(a)
  val f = floor(b)
  println(count(c.length, c.indexOf('0'), f.length, f.indexOf('0')))
}

import scala.io.Source

object Solution extends App {

  def ceil(a: Long): String = {
    val str = a.toBinaryString
    val zeroCount = str.count(_ == '0')
    if (zeroCount == 1) str
    else if (zeroCount == 0) str + '0'
    else {
      val ones = str.takeWhile(_ == '1').length
      "1" * ones + "0" + "1" * (str.length - ones - 1)
    }
  }

  def floor(a: Long): String = {
    val str = a.toBinaryString
    val zeroCount = str.count(_ == '0')
    if (zeroCount == 1) str
    else if (zeroCount == 0) str.dropRight(1) + '0'
    else {
      val ones = str.takeWhile(_ == '1').length
      if (ones == 1)
        "1" * (str.length - 2) + "0"
      else
        "1" * (ones - 1) + "0" + "1" * (str.length - ones)
    }
  }

  def count(aSize: Int, aZeroPosition: Int, bSize: Int, bZeroPosition: Int): Int = {
    if (aSize > bSize) 0
    else if (aSize == bSize && aZeroPosition == bZeroPosition) 1
    else if (aZeroPosition == aSize) count(aSize + 1, 1, bSize, bZeroPosition)
    else 1 + count(aSize, aZeroPosition + 1, bSize, bZeroPosition)
  }

  val in = Source.stdin.getLines()
  val Array(a, b) = in.next().split(' ').map(_.toLong)
  val c = ceil(a)
  val f = floor(b)
  println(count(c.length, c.indexOf('0'), f.length, f.indexOf('0')))
}

import scala.io.Source

object Solution extends App {

  def ceil(a: Long): String = {
    val str = a.toBinaryString
    val zeroCount = str.count(_ == '0')
    if (zeroCount == 1) str
    else if (zeroCount == 0) str + '0'
    else {
      val ones = str.takeWhile(_ == '1').length
      "1" * ones + "0" + "1" * (str.length - ones - 1)
    }
  }

  def floor(a: Long): String = {
    val str = a.toBinaryString
    val zeroCount = str.count(_ == '0')
    if (zeroCount == 1) str
    else if (zeroCount == 0) str.dropRight(1) + '0'
    else {
      val ones = str.takeWhile(_ == '1').length
      if (ones == 1)
        "1" * (str.length - 2) + "0"
      else
        "1" * (ones - 1) + "0" + "1" * (str.length - ones)
    }
  }

  def count(aSize: Int, aZeroPosition: Int, bSize: Int, bZeroPosition: Int): Int = {
    if (aSize > bSize || (aZeroPosition > bZeroPosition && aSize == bSize)) 0
    else if (aSize == bSize && aZeroPosition == bZeroPosition) 1
    else if (aZeroPosition == aSize) count(aSize + 1, 1, bSize, bZeroPosition)
    else 1 + count(aSize, aZeroPosition + 1, bSize, bZeroPosition)
  }

  val in = Source.stdin.getLines()
  val Array(a, b) = in.next().split(' ').map(_.toLong)
  val c = ceil(a)
  val f = floor(b)
  println(count(c.length, c.indexOf('0'), f.length, f.indexOf('0')))
}

import scala.io.Source

object Solution extends App {

  def ceil(a: Long): String = {
    val str = a.toBinaryString
    val zeroCount = str.count(_ == '0')
    if (zeroCount == 1) str
    else if (zeroCount == 0) str + '0'
    else {
      val ones = str.takeWhile(_ == '1').length
      "1" * ones + "0" + "1" * (str.length - ones - 1)
    }
  }

  def floor(a: Long): String = {
    val str = a.toBinaryString
    val zeroCount = str.count(_ == '0')
    if (zeroCount == 1) str
    else if (zeroCount == 0) str.dropRight(1) + '0'
    else {
      val ones = str.takeWhile(_ == '1').length
      if (ones == 1)
        "1" * (str.length - 2) + "0"
      else
        "1" * (ones - 1) + "0" + "1" * (str.length - ones)
    }
  }

  def count(aSize: Int, aZeroPosition: Int, bSize: Int, bZeroPosition: Int): Int = {
    if (aSize > bSize || (aZeroPosition < bZeroPosition && aSize == bSize)) 0
    else if (aSize == bSize && aZeroPosition == bZeroPosition) 1
    else if (aZeroPosition == aSize) count(aSize + 1, 1, bSize, bZeroPosition)
    else 1 + count(aSize, aZeroPosition + 1, bSize, bZeroPosition)
  }

  val in = Source.stdin.getLines()
  val Array(a, b) = in.next().split(' ').map(_.toLong)
  val c = ceil(a)
  val f = floor(b)
  println(count(c.length, c.indexOf('0'), f.length, f.indexOf('0')))
}


import java.io._
import java.util.Scanner
import scala.language.implicitConversions

object AcmICPC {

  class Lazy[A](x: => A) {
    lazy val value = x
    override def toString(): String = value.toString()
  }

  object Lazy {
    def apply[A](x: => A) = new Lazy(x)
    implicit def fromLazy[A](z: Lazy[A]): A = z.value
    implicit def toLazy[A](x: => A): Lazy[A] = Lazy(x)
  }

  import Lazy._

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

    val A = sc.nextLine().split(" ").map(str => str.toInt)
    val sum = A.sum
    val answer = A.combinations(3).exists(combination => combination.sum * 2 == sum)

    println(if(answer) "YES" else "NO")

  }
}

object A extends App {

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

  val as = readInts(6)

  var can = false
  for (bs <- as.permutations) {
    if (bs.take(3).sum == bs.drop(3).sum) can = true
  }

  println(if (can) "YES" else "NO")

  Console.flush
}

/**
  * @see http://codeforces.com/contest/890/problem/A
  */

object AACM extends App {
  val a = scala.io.StdIn.readLine().split(" ").map(_.toInt)
  val s = a sum
  val n = 6

  val vs = for {
    i <- 0 to 5
    j <- i to 5
    k <- j to 5
    if i != j && j != k && i != k && s - a(i) - a(j) - a(k) == a(i) + a(j) + a(k)
  } yield (i, j, k)

  if (vs.isEmpty) println("NO")
  else println("YES")
}

import scala.annotation.tailrec

object A extends App {
  val a = scala.io.StdIn.readLine().split(" ").map(_.toInt)
  val n = 6
  val s = a.sum

  @tailrec
  def check(i: Int = 0, j: Int = 0, k: Int = 0): Boolean =
    if (i == n || j == n || k == n) false
    else if (s - a(i) - a(j) - a(k) == a(i) + a(j) + a(k)) true
    else check(i + (j + (k + 1) / n) / n, (j + (k + 1) / n) % n, (k + 1) % n)

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


object CF915B extends App{
  val sc = new java.util.Scanner(System.in)
  val n, pos, l, r = sc.nextInt
  val move = if (l == 1) {
    if (r == n) 0 else (r-pos abs) + 1
  } else {
    if (r == n) (pos-l abs) + 1 else  ((pos-l min  r-pos) abs) + (r - l) + 2
  }
  println(move)
}

object B extends App {
  val Array(n, pos, l, r) = scala.io.StdIn.readLine().split(" ").map(_.toInt)

  def seconds(i: Int, a: Int, b: Int, t: Int = 0): Int =
    if (a == l && b == r) t
    else if (a == l) seconds(r, a, r, t + (r - i).abs + 1)
    else if (b == r) seconds(l, l, b, t + (i - l).abs + 1)
    else {
      if (i <= l) seconds(l, l, b, t + l - i + 1)
      else if (i >= r) seconds(r, a, r, t + i - r + 1)
      else {
        if (r - i < i - l) seconds(r, a, b, t + r - i)
        else seconds(l, a, b, t + i - l)
      }
    }

  println(seconds(pos, 1, n))
}

object B extends App {
  val Array(n, pos, l, r) = scala.io.StdIn.readLine().split(" ").map(_.toInt)

  def seconds(i: Int, a: Int, b: Int, t: Int = 0): Int =
    if (a == l && b == r) t
    else if (a == l) seconds(r, a, r, t + r - i + 1)
    else if (b == r) seconds(l, l, b, t + i - l + 1)
    else {
      if (i <= l) seconds(l, l, b, t + l - i + 1)
      else if (i >= r) seconds(r, a, r, t + i - r + 1)
      else {
        if (r - i < i - l) seconds(r, a, b, t + r - i)
        else seconds(l, a, b, t + i - l)
      }
    }

  println(seconds(pos, 1, n))
}

object CF915B extends App{
  val sc = new java.util.Scanner(System.in)
  val n, pos, l, r = sc.nextInt
  val move = if (l == 1) {
    if (r == n) 0 else r-pos + 1
  } else {
    if (r == n) pos-l + 1 else (pos-l min  r-pos) + (r - l) + 2
  }
  println(move)
}


/**
  * Created by octavian on 18/02/2016.
  */
object Game {

  def main(args: Array[String]) {
   // System.setIn(new FileInputStream("src/game.in"))
    //System.setOut(new PrintStream(new FileOutputStream("src/game.out")))

    var n = readLong()
    if(n % 2 == 0) {
      println(2)
    }
    else {
      println(1)
    }

  }

}

import scala.io.StdIn

object Game {

  def main(args: Array[String]) {
    val n = StdIn.readLong()
    print(2 - (n % 2))
  }

}

import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

object Main {

  def sqr(x: Long) = x * x

  def powmod(x: Long, n: Long, p: Long): Long = {
    if (n == 1) x
    else if (n % 2 == 1) (powmod(x, n - 1, p) * x) % p
    else sqr(powmod(x, n / 2, p)) % p
  }

  def C(n: Int, k: Int) = {
    var res = BigInt(1)
    for (i <- n - k + 1 to n) {
      res = res * i
    }
    for (i <- 1 to k.toInt) {
      res = res / i
    }
    res
  }

  def fact(n: Int) = {
    var res = BigInt(1)
    for (i <- 1 to n) {
      res = res * i
    }
    res
  }

  def gcd(a: Long, b: Long): Long = if (b == 0) a else gcd(b, a % b)

  def lcm(a: Long, b: Long) = a / gcd(a, b) * b

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

    val n = in.nextLong()

    println((n + 1) % 2 + 1)
  }
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  println(2 - in.next().last.asDigit % 2)
}


import scala.io.StdIn.readLine
object problem {
  def main(args: Array[String]) {
  val s = readLine
    println(if(s.distinct.size%2 ==0) "CHAT WITH HER!" else "IGNORE HIM!")
  }
}

object Main {

  def distinct(x: List[Char]): List[Char] = {
    x.foldLeft(List.empty[Char])((acc, c) => if (acc.contains(c)) acc else c :: acc)
  }

  def gender(nick: String): String = {
    val chars = distinct(nick.toList)
    if (chars.size % 2 == 0) "CHAT WITH HER!"
    else "IGNORE HIM!"
  }

  def main(args: Array[String]) = {
    print (gender(readLine))
  }
}

object a{def main(args:Array[String]){if(readLine.distinct.size%2==0)print("CHAT WITH HER!")else print("IGNORE HIM!")}}

//2.12 | CodeForces.Com
object Solution {
    def main(args: Array[String]) {
        if(readLine.distinct.size % 2 == 0)
            print("CHAT WITH HER!")
        else
            print("IGNORE HIM!")
    }
}

//rextester.com:2.11.7--codeforces.com:2.11.8
object a extends App{
    if(readLine.distinct.size%2==0)print("CHAT WITH HER!")else print("IGNORE HIM!")
}

import scala.io.StdIn._

object Task extends App{
	val name = readLine.toSet

	if(name.size % 2 == 0)
	  println("CHAT WITH HER!")
	else
	  println("IGNORE HIM!")
}

object A00236 extends App {
  val str = Console.readLine()
  val message = if (str.distinct.length % 2 == 1) "IGNORE HIM!" else "CHAT WITH HER!"
  println(message)
}

object JuanDavidRobles236A {

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

    import scala.io.StdIn
    import java.util

    var string: String = StdIn.readLine()
    var words: Array[Char] = new Array[Char](30)
    var count: Int = 0

    for (i <- 0 until string.length){
      if (!arrayContains(words, string.charAt(i))){
        words(count) = string.charAt(i)
        count += 1
      }
    }

    if (count%2 == 0){
      println("CHAT WITH HER!")
    } else {
      println("IGNORE HIM!")
    }

  }

  def arrayContains(myString: Array[Char], char: Char): Boolean ={
    var boolean: Boolean = false
    for (i <- 0 until myString.length){

      if (myString.charAt(i) == char){
        boolean = true
      }
    }

    boolean
  }
}

import scala.io.StdIn.readLine

object BoyOrGirl {
  def main(args: Array[String]) {
    if (readLine.toSet.size % 2 == 0)
      println("CHAT WITH HER!")
    else
      println("IGNORE HIM!")
  }

}

object Main extends App{
    if(readLine.distinct.size %2==0)
    println("CHAT WITH HER!")else
    println("IGNORE HIM!")
}

import scala.collection.immutable.Set
object TEST extends App{
    var al = Set[Char]()
    readLine.foreach(i => al += i)
    print (if(al.size%2==0) "CHAT WITH HER!" else "IGNORE HIM!")
}

object test5 extends App {
    val name=readLine
    if(name.distinct.size%2==0)
    	println("CHAT WITH HER!")
    else
    	println("IGNORE HIM!")

}

/**
 * Created by richard on 2015/6/10.
 */
import scala.io.StdIn
object cf236a {
  def main(args: Array[String]): Unit = {
    val name = StdIn.readLine()
    println(if (name.distinct.size%2==1) "IGNORE HIM!" else "CHAT WITH HER!")
  }
}

object I {

  def main(args : Array[String]): Unit = {
    var s = readLine
    var used=false
    var cnt = 1
    for (i <- 1 to s.length()-1; j <- i-1 to 0 by -1){
    	if (s.charAt(i)==s.charAt(j))used = true
    	if (j==0){
    	  if (!used)cnt += 1
    	 used = false
    	}
      }
//    println(cnt)
    if (cnt % 2 == 0)
      println("CHAT WITH HER!")
     else println("IGNORE HIM!")
  }

}

object A236 extends App {
  var name: String = readLine
  var count = 0;
  while (!name.isEmpty()) {
    name = name.filterNot((a: Char) => a == name.charAt(0))
    count += 1;
  }
  if (count % 2 == 0)
    println("CHAT WITH HER!")
  else println("IGNORE HIM!")
}

object Main {
  def main(args: Array[String]): Unit = {
    val s = readLine
    if (s.toList.distinct.length % 2 == 0) {
      println("CHAT WITH HER!")
    } else {
      println("IGNORE HIM!")
    }
  }
}

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val name = sc.next()

  println(if (name.toSet.size % 2 == 0) "CHAT WITH HER!" else "IGNORE HIM!")
}

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

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

  val name = sc.nextLine

  def solve: String =
    if (name.groupBy(identity[Char]).size % 2 == 0) "CHAT WITH HER!"
    else "IGNORE HIM!"

  out.println(solve)
  out.close
}

object BoyOrGirl {
	def main (args: Array[String]) {
		val scanner = new java.util.Scanner(System.in);
		val input = scanner.nextLine;
		var theList: List[Char] = Nil
		for (c <- input) {
		  if (!theList.contains(c)) {
		    theList = c::theList;
		  }
		}
		if (theList.size % 2 == 0) {
		  println("CHAT WITH HER!")
		}
		else {
		  println("IGNORE HIM!")
		}
	}
}

object A {
  def main(args: Array[String]) {
    val input = readLine()
    val chars = input.iterator.toSet
    print(
      if ((chars.iterator.length % 2) == 0)
        "CHAT WITH HER!"
      else
        "IGNORE HIM!")
  }

}

// codeforces 236A

object DevYun extends App {
  val nm = Console.readLine()
  val sch: Set[Char] = nm toSet
  val devush = (sch.size % 2) == 0
  val answer = if (devush) "CHAT WITH HER!" else "IGNORE HIM!"
  println(answer)
}

object Main {
  def main(args: Array[String]): Unit = {
      val str = readLine()
      if (str.distinct.length % 2 == 0) println("CHAT WITH HER!") else println("IGNORE HIM!")
  }
}

object Two36A extends App {
	val str = readLine
	val a = 'a'
	val arr = new Array[Int](26)
	str.foreach { x =>
		arr(x - a) += 1
	}
	val size = arr.filter(_ > 0).size
	if (size % 2 != 0) {
		println("IGNORE HIM!")
	} else {
		println("CHAT WITH HER!")
	}
}

import scala.io.StdIn._

object BoyorGirl {
  def main(args: Array[String]): Unit = {
    val name = readLine().toSet
    val ans = if (name.size % 2 == 0) "CHAT WITH HER!" else "IGNORE HIM!"
    println(ans)
  }
}

object BoyGirl extends App {

	val uniqueCharacters =
		scala.io.StdIn.readLine()
		.toSet.size

	if (uniqueCharacters % 2 != 0) println("IGNORE HIM!")
		else println("CHAT WITH HER!")

}

import java.util.Scanner

object Try1 {
  def main(args: Array[String]) {
    val in = new Scanner(System.in)
    var a,b,len,x, m, k, n, j, i: Int = 0

//    val lb = "abcdefghijklmnopqrstuvwxyz"
//    val lc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    var v = new Array[Int](26)
    i=0
    while (i<26){
      v(i)=0
      i+=1
    }
//    n = in.nextInt()
//    k = in.nextInt()
//    x=0
    val la = in.nextLine()
    a=0
    b=0
    m = la.length()
    i=0
    while (i<m) {
      v(la(i)-'a')=1
      i+=1
    }
    i=0
    while (i<26){
      a+=v(i)
      i+=1
    }
    a=a%2
    if (a==0) println("CHAT WITH HER!")
    else println("IGNORE HIM!")
//    if (a>=b)
//      {
//        i=0
//        while (i<m)
//        {
//          if (la(i)>='a' && la(i)<='z') print(la(i))
//          else print(lb(la(i)-'A'))
//          i+=1
//        }
//      }
//    else
//      {
//        i=0
//        while (i<m)
//        {
//          if (la(i)>='a' && la(i)<='z') print(lc(la(i)-'a'))
//          else print(la(i))
//          i+=1
//        }
//      }
//    m = la.compareToIgnoreCase(lb)  //不区分大小写判断字符串是否相等

//    i=0
//    n=line.length()
//    while (i<n-2 && line(i)=='W' && line(i+1)=='U' && line(i+2)=='B') i+=3
//    while (n>2 && line(n-3)=='W' && line(n-2)=='U' && line(n-1)=='B') n-=3
//    while (i<n) {
//      if (line(i)=='W') {
//        if (i<n-2) {
//          if (line(i+1)=='U' && line(i+2)=='B') {
//            print(' ')
//           i+=2
//          }
//          else print(line(i))
//        }
//        else print(line(i))
//      }
//      else print(line(i))
//      i+=1
//    }

  }
}

object Codeforces236A extends App{

  def Check(quer:String):String={
    var ans:Int=1
    val nquer:String=quer.toArray.sorted.mkString
    for (i <- 0 until nquer.length-1){
      if (nquer(i) != nquer(i+1)) ans+=1
    }
    if (ans % 2 == 1) return "IGNORE HIM!"
    else return "CHAT WITH HER!"
  }

  val username:String=scala.io.StdIn.readLine
  println(Check(username))

}

object Main extends App {
  val str = readLine()

  val r = str.toLowerCase().groupBy(_.toChar).map { case (k, v) => (k, v.size) }

  if (r.size % 2 == 0) println("CHAT WITH HER!")
  else println("IGNORE HIM!")
}

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

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

  def ans = Array("CHAT WITH HER!", "IGNORE HIM!").apply(reader.readLine().groupBy(x => x).size % 2)

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

object Task236A {
  def main(args: Array[String]): Unit = {
    println(if (scala.io.StdIn.readLine().foldLeft(Set[Char]())((x, y) => x + y).size % 2 == 0) "CHAT WITH HER!" else "IGNORE HIM!")
  }
}

object CF0236A extends App {

  var str = readLine().toList

  val size = str.toSet.size

  if(size % 2 == 0) {
    println("CHAT WITH HER!")
  } else {
    println("IGNORE HIM!")
  }
}

object Solution236A extends App {

  val ans = Map(0 -> "CHAT WITH HER!", 1 -> "IGNORE HIM!")

  def solution() {
    println(ans(_string.groupBy(c => c).size % 2))
  }

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

import scala.io.StdIn

object BoyAndGirlMain {
  def main(args: Array[String]): Unit = {
    val userName = StdIn.readLine().toArray
    val lol = userName.groupBy(_.charValue())

    if (lol.size % 2 == 0 )
      print ("CHAT WITH HER!")
    else print("IGNORE HIM!")
  }

}

object Main {
  def main(args: Array[String]) {
    val s = readLine().toSet
    if (s.size % 2 == 0) println("CHAT WITH HER!")
    else println("IGNORE HIM!")
  }
}

// Codeforces 236A

object _236A extends App {
  val scanner = new java.util.Scanner(System.in)
  val user_name = scanner.next
  println(
    if (user_name.distinct.size % 2 == 0) "CHAT WITH HER!"
    else "IGNORE HIM!"
  )
}

import scala.io.StdIn._

object Main {
  def main(args: Array[String]): Unit = {
    val s = readLine
    if (s.toSeq.distinct.size % 2 == 0) println("CHAT WITH HER!") else println("IGNORE HIM!")
  }
}

object Solution extends App {
  if (readLine().distinct.size % 2 == 0)
    println("CHAT WITH HER!")
  else
    println("IGNORE HIM!")
}

import scala.io.StdIn._

object A_236 extends App {
  println(if (readLine().toCharArray.toSet.size % 2 == 1) "IGNORE HIM!" else "CHAT WITH HER!")
}

object Main {
  def main(args: Array[String]) {
    val std = scala.io.StdIn
    val userName = std.readLine()
    val result = if (userName.distinct.length % 2 == 0) {
      "CHAT WITH HER!"
    }
    else {
      "IGNORE HIM!"
    }
    println(result)
  }
}

import scala.io.StdIn

object BoyOrGirl extends App {

  val name = StdIn.readLine()

  if (impl(name))
    print("CHAT WITH HER!")
  else
    print("IGNORE HIM!")

  def impl(name: String): Boolean = {
    name.distinct.length % 2 == 0
  }

}

import scala.io.StdIn.readLine
object BoyOrGirl extends App
{
    val input = readLine()
    val sort = input.distinct.length
    if(sort % 2 == 0)
    {
        println("CHAT WITH HER!")
    } else println("IGNORE HIM!")
}

object Main {
  def main(args: Array[String]): Unit = {
      val str = readLine()
      println(str.distinct.length)
  }
}

object BoyGirl extends App {

	val uniqueCharacters =
		scala.io.StdIn.readLine()
		.toSet.size

	if (uniqueCharacters % 2 == 0) println("IGNORE HIM!")
		else println("CHAT WITH HER!")

}

object Main extends App {
  val str = readLine()

  val r = str.toLowerCase().groupBy(_.toChar).map { case (k, v) => (k, v.size) }.
    filter { case (k, v) => v == 1 }.filterNot { case (k, v) => k == ' ' }.size

  if (r % 2 == 0) println("IGNORE HIM!")
  else println("CHAT WITH HER!")
}

import scala.io.StdIn

object BoyAndGirlMain {
  def main(args: Array[String]): Unit = {
    val userName = StdIn.readLine().toArray
    val lol = userName.groupBy(_.charValue())

    println(lol .size)
    if (lol.size % 2 == 0 )
      print ("CHAT WITH HER!")
    else print("IGNORE HIM!")
  }

}

/**
 * Created by richard on 2015/6/10.
 */
import scala.io.StdIn
object cf236a {
  def main(args: Array[String]): Unit = {
    val name = StdIn.readLine()
    println(if (name.size%2==1) "IGNORE HIM!" else "CHAT WITH HER!")
  }
}

object Main {
  def main(args: Array[String]) {
    val s = readLine().toSet
    println(s)
    if (s.size % 2 == 0) println("CHAT WITH HER!")
    else println("IGNORE HIM!")
  }
}

// Codeforces 236A

object _236A extends App {
  val scanner = new java.util.Scanner(System.in)
  val user_name = scanner.next
  println(
    if (user_name.distinct.size % 2 == 0) "CHAT WITH HER"
    else "IGNORE HIM"
  )
}

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

    import scala.io.StdIn

    var string: String = StdIn.readLine()
    var words: Array[Char] = new Array[Char](30)

    var count: Int = 0

    for (i <- 0 until string.length; j <- 0 until words.length()){

      if (words(j).equals(string.charAt(i))){
        words(count) = string.charAt(i)
        count = count + 1
      }
    }

    if (count%2 == 0){
      println("CHAT WITH HER!")
    } else {
      println("IGNORE HIM!")
    }

  }
}