object Solution extends App {
  val Array(n, m) = readLine().split(" ").map(_.toInt)
  println(Range(0, 1000).flatMap(i => Range(0, 1000).map(t => (i, t))).count{
    case(a, b) => a * a + b == n && a + b * b == m
  })

}

object Round131A2 {

  def main(args: Array[String]): Unit = {
    val Array(n, m) = readLine().split(" ").map(_.toInt)
    var res = 0
    for (a <- 0 to 1000)
      for (b <- 0 to 1000)
        if (a * a + b == n && a + b * b == m)
          res = res + 1
    println(res)
  }

}

import java.util.StringTokenizer

object _214A 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 ans = for {
    a <- 0 to m
    val b = n - a * a
    if (b >= 0 && a + b * b == m)
  } yield 1
  println(ans.sum)
}

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

object P214A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)
  val N, M = sc.nextInt

  val answer = {
    for {
      i <- 0 until 32
      j <- 0 until 32
      if i * i + j == N && i + j * j == M
    } yield 1
  }.sum

  out.println(answer)
  out.close
}

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

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

  val Array(n, m) = readInts
  def sqr(x: Int) = x * x
  def ans = (0 to n).filter(n - sqr(_) >= 0).count(a => a + sqr(n - sqr(a)) == m)

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

object Main {
  def main(args: Array[String]) {
    val mn = readLine().split(" ").map(_.toInt)
    val m = mn(0)
    val n = mn(1)
    var count = 0
    val s = for {
      a <- 0 to (Math.sqrt(m).toInt + 1)
      b <- 0 to (Math.sqrt(n).toInt + 1)
      if a * a + b == m && a + b * b == n
    } yield (1)
    println(s.size)
  }
}

object A{
  def main(args: Array[String]){

    val (n,m)={
      val sp=readLine.split(" ")
      (sp(0).toInt, sp(1).toInt)
    }

    println(
      0 to 1000 count{a=>
        val b= n-a*a
        b>=0 && a+b*b==m
      }
    )
  }
}

import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val Array(n, m) = StdIn.readLine().split(" ").map(_.toInt)
    println(f(n, m))
  }

  def f(n: Int, m: Int): Int = {
    var r = 0
    for {
      a <- 0 to 100
      b <- 0 to 100
      if a * a + b == n && a + b * b == m
    } yield {
      r += 1
    }
    r
  }
}

object Round131A2 {

  def main(args: Array[String]): Unit = {
    val Array(n, m) = readLine().split(" ").map(_.toInt)
    var res = 0
    for (a <- 1 to 1000)
      for (b <- 1 to 1000)
        if (a * a + b == n && a + b * b == m)
          res = res + 1
    println(res)
  }

}

object Solution extends App {
  val Array(n, m) = readLine().split(" ").map(_.toInt)
  println(Range(0, 1000).flatMap(i => Range(0, i).map(t => (i, t))).count{
    case(a, b) => a * a + b == n && a + b * b == m
  })

}

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

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

  val N, M = sc.nextInt

  out.println(List(N, M).mkString(" "))

  val answer = {
    for {
      a <- 0 to math.sqrt(N).floor.toInt
      b = math.sqrt(M - a).floor.toInt
      if a + b * b == M && a * a + b == N
    } yield 1
  }.size

  out.println(answer)
  out.close
}

object A{
  def main(args: Array[String]){

    val (n,m)={
      val sp=readLine.split(" ")
      (sp(0).toInt, sp(1).toInt)
    }

    println(
      0 to 1000 count{a=>
        val b= n-a*a
        a+b*b==m
      }
    )
  }
}


import scala.util.matching.Regex

object A extends App {
  def ms2s(ms: (Int, Int)) = { ms._1*60 + ms._2 }
  def s2ms(s: Int) = { (s/60, s%60) }
  def str2ms(s: String): (Int, Int) = {
    val p: Regex = """([0-9][0-9]):([0-9][0-9])""".r
    val m: Regex.Match = p.findFirstMatchIn(s).get
    return (m.group(1).toInt, m.group(2).toInt)
  }

  var ta, tb = ms2s(str2ms(readLine()))
  val ans = s2ms(ta+(if (ta < tb) 24*60 else 0) - tb)
  println("%02d:%02d".format(ans._1, ans._2))
}

object ThreeEightSevenA {

	def main(args: Array[String]): Unit = {
		var to=readLine.split(':').map(_.toInt)
		var from=readLine.split(':').map(_.toInt)

		if(to(0)==from(0) && to(1)==from(1)){
			println("00:00")
			return
		}

		if(to(0)==0 && to(1)==0){
			to(0)=24
		}

		var h=to(0)-from(0)
		var min=to(1)-from(1)

		if(min<0)
		{
			h=h-1
			min+=60
		}
		if(h<0){
			h+=24
		}
		if(h<10)
			print("0"+h)
		else
			print(h)

		print(":")

		if(min<10)
			println("0"+min)
		else
			println(min)

	}
}

import java.util.StringTokenizer

object _387A extends App {
  var token = new StringTokenizer("")

  def next = {
    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)
    token.nextToken()
  }

  val cb = next.split(":").map(s => s.toInt)
  val wb = next.split(":").map(s => s.toInt)

  var h = cb(0)
  var m = cb(1)
  val h1 = wb(0)
  val m1 = wb(1)

  if (h < h1 || h == h1 && m < m1) h += 24

  if (m < m1) {
    m += 60
    h -= 1
  }

  println("%02d:%02d".format(h - h1, m - m1))
}

object Solution extends App {

  val in = scala.io.Source.stdin.getLines()
  val k = in.next()
  val t = in.next()
  var hourNow = k.take(2).toInt
  var minutesNow = k.drop(3).toInt
  val hours = t.take(2).toInt
  val minutes = t.drop(3).toInt
  if (minutesNow < minutes) {
    minutesNow += 60
    hourNow -= 1
  }
  if (hourNow < hours)
    hourNow += 24
  hourNow -= hours
  minutesNow -= minutes
  println(f"$hourNow%02d:$minutesNow%02d")

}

import java.util.Scanner

object P387A {
    class Time(timeString: String) {
        val splitTime = timeString.split(":")
        val hour = splitTime(0).toInt
        val minute = splitTime(1).toInt
        val totalMinute = hour * 60 + minute
        def -(that: Time): Time = {
            val t = (this.totalMinute - that.totalMinute + 60 * 24) % (60 * 24)
            new Time(t / 60 + ":" + t % 60)
        }
        override def toString =
            "0" * (2 - hour.toString.length) + hour + ":" + "0" * (2 - minute.toString.length) + minute
    }

    def main(args: Array[String]) {
        val scanner = new Scanner(System.in)
        val wakeUpTime = new Time(scanner.next())
        val sleepTime = new Time(scanner.next())
        val bedInTime = wakeUpTime - sleepTime
        println(bedInTime)
    }
}

object A387 {

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

  def main(args: Array[String]): Unit = {
    val curr = read.split(":").map(_.toInt)
    val time = read.split(":").map(_.toInt)

    val start = Array(((if(curr(1)-time(1) < 0) -1 else 0) + 24+curr(0)-time(0))%24, (60+curr(1)-time(1))%60)

    out.println(s"${"%02d".format(start(0))}:${"%02d".format(start(1))}")
    out.close()
  }

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

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

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

    def readInt: Int = tokenizeLine.nextToken.toInt

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

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

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

}

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

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

  object Clock {
    def apply(m: Int): String = {
      val hour = m / 60
      val min  = m % 60
      f"$hour%02d:$min%02d"
    }

    def unapply(s: String): Option[Int] = {
      val parts = s split ":"
      if (parts.length == 2) Some(parts(0).toInt * 60 + parts(1).toInt)
      else None
    }
  }

  def solve(): String = {
    val Clock(t0) = sc.nextLine
    val Clock(t1) = sc.nextLine
    if (t0 >= t1) Clock(t0 - t1)
    else Clock(t0 - t1 + 1440)
  }

  out.println(solve)
  out.close
}

import java.util.Scanner

/**
 * Created by Kuang.Ru on 14-10-10.
 */
object A387 {
  def main(args: Array[String]) {
    val sc = new Scanner(System.in)
    val s, t = sc.next()
    var st = s.split(":").map(_.toInt)
    val tt = t.split(":").map(_.toInt)
    var goBedMin = st(1) - tt(1)

    if (goBedMin < 0) {
      st(0) -= 1
      goBedMin = 60 + goBedMin
    }

    var goBedHour = st(0) - tt(0)

    if (goBedHour < 0) {
      goBedHour = 24 + goBedHour
    }

    printf("%02d:%02d", goBedHour, goBedMin)
  }
}

import scala.util.matching.Regex

object A extends App {
  def ms2s(ms: (Int, Int)) = { ms._1*60 + ms._2 }
  def s2ms(s: Int) = { (s/60, s%60) }
  def str2ms(s: String): (Int, Int) = {
    val p: Regex = """([0-9][0-9]):([0-9][0-9])""".r
    val m: Regex.Match = p.findFirstMatchIn(s).get
    return (m.group(1).toInt, m.group(2).toInt)
  }

  val a = readLine()
  val b = readLine()

  var ta = ms2s(str2ms(a))
  val tb = ms2s(str2ms(b))

  if (ta < tb) ta += 24*60
  val ans = s2ms(ta - tb)
  println("%02d:%02d".format(ans._1, ans._2))
}

object ThreeEightSevenA {

	def main(args: Array[String]): Unit = {
		var to=readLine.split(':').map(_.toInt)
		var from=readLine.split(':').map(_.toInt)
		if(to(0)==from(0) && to(1)==from(1)){
			println("00:00")
			return
		}
		if(to(0)==0 && to(1)==0){
			to(0)=24
		}
		var h=to(0)-from(0)
		var min=to(1)-from(1)

		if(min<0)
		{
			h=h-1
			min=min+60
		}

		if(h<10)
			print("0"+h)
		else
			print(h)
		print(":")
		if(min<10)
			println("0"+min)
		else
			println(min)

	}
}

object ThreeEightSevenA {

	def main(args: Array[String]): Unit = {
		var to=readLine.split(':').map(_.toInt)
		var from=readLine.split(':').map(_.toInt)
		if(to(0)==0 && to(1)==0){
			to(0)=24
		}
		var h=to(0)-from(0)
		var min=to(1)-from(1)
		if(min<0)
		{
			h=h-1
			min=min+60
		}
		if(h<10)
			print("0"+h)
		else
			print(h)
		print(":")
		if(min<10)
			println("0"+min)
		else
			println(min)
	}

}

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

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

  object Clock {
    def apply(m: Int): String = {
      val hour = m / 60
      val min  = m % 60
      f"$hour%02d:$min%02d"
    }

    def unapply(s: String): Option[Int] = {
      val parts = s split ":"
      if (parts.length == 2) Some(parts(0).toInt * 60 + parts(1).toInt)
      else None
    }
  }

  def solve(): String = {
    val Clock(t0) = sc.nextLine
    val Clock(t1) = sc.nextLine
    if (t0 > t1) Clock(t0 - t1)
    else Clock(t0 - t1 + 1440)
  }

  out.println(solve)
  out.close
}


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

object HelloWorld {

  def main(args: Array[String]): Unit = {
    var s = readLine;
    var result = "";
    var ind = 0;
    while (ind < s.length) {
      if (s.startsWith(".", ind)) {
        result += "0";
        ind += 1;
      } else if (s.startsWith("-.", ind)) {
        result += "1";
        ind += 2;
      } else if (s.startsWith("--", ind)) {
        result += "2";
        ind += 2;
      }
    }
    println(result);
  }

}

object P032B extends App {
  def f(a: List[Char]):Unit = a match {
    case '.'::tail => print(0); f(tail)
    case '-'::'.'::tail => print(1); f(tail)
    case '-'::'-'::tail => print(2); f(tail)
    case Nil =>
  }
  f(readLine.toList)
}

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val text = in.next().foldLeft(None: Option[Char], List.empty[Int]) {
    case((None, list), '.') => (None, 0 :: list)
    case((None, list), '-') => (Some('-'), list)
    case((Some('-'), list), '-') => (None, 2 :: list)
    case((Some('-'), list), '.') => (None, 1 :: list)
  }

  println(text._2.reverse.mkString)

}

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

  val ans = readLine()
    .foldLeft((List.empty[Int], "")) {
      case ((codes, code), part) =>
        code + part match {
          case "."  => (0 :: codes, "")
          case "-." => (1 :: codes, "")
          case "--" => (2 :: codes, "")
          case _    => (codes, part.toString)
        }
    }
    ._1
    .reverse

  println(ans.mkString(""))
}

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

  val ans = readLine().replace("--", "2").replace("-.", "1").replace(".", "0")

  println(ans.mkString(""))
}

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

object HelloWorld {

  def main(args: Array[String]): Unit = {
    var s = readLine;
    var result = "";
    while (s.length > 0) {
      if (s.startsWith(".")) {
        result += "0";
        s = s.replaceFirst(".", "");
      } else if (s.startsWith("-.")) {
        result += "1";
        s = s.replaceFirst("-.", "");
      } else if (s.startsWith("--")) {
        result += "2";
        s = s.replaceFirst("--", "");
      }
    }
    println(result);
  }

}


object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val data = (1 to 4).map(_ => in.next().map{t => if (t == '#') 1 else 0}).toArray
  val r = (1 to 3).map(i =>
    (1 to 3).map{
      j =>
        val sum = data(i)(j) + data(i - 1)(j) + data(i)(j - 1) + data(i - 1)(j - 1)
        Math.max(sum, 4 - sum)
    }.max
  ).max
  if (r < 3)
    println("NO")
  else
    println("YES")
}

object IQ {

  def main (args : Array[String]){
    var a = new Array[String](4)
    for (i <- 0 to 3)
      a(i) = readLine
     for (i <- 1 to 3; j <- 1 to 3){
         var ans = 0
         if (a(i).charAt(j)=='.')ans +=1
         if (a(i-1).charAt(j-1)=='.')ans +=1
         if (a(i).charAt(j-1)=='.')ans +=1
         if (a(i-1).charAt(j)=='.')ans +=1
         if (ans!=2){
        	 println("YES");return
        	 }
         }
     println("NO")
  }

}

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

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

  type Grid = Array[Array[Char]]
  val grid: Grid = Array.fill(4)(sc.nextLine.toArray)

  def solve(): String = {
    def test(i: Int, j: Int): Boolean = {
      val cells = List(List(i, j), List(i + 1, j), List(i, j + 1), List(i + 1, j + 1))
      cells.count {
        case List(x, y) => grid(x)(y) == '#'
      } != 2
    }

    if ((for (i <- 0 until 3; j <- 0 until 3) yield test(i, j)).exists(_ == true)) "YES"
    else "NO"
  }

  out.println(solve)
  out.close
}

object A {
  def R = readLine().split(" ") map(_.toInt)

  def main(args: Array[String]) {
    var a = Array.ofDim[Boolean](4,4)
    def check(b:Boolean):Boolean = {
      for (x <- 0 until 3; y <- 0 until 3 if (a(x)(y) == b &&a(x+1)(y) ==b &&a(x)(y+1) == b &&a(x+1)(y+1) == b)) return true;
      return false;
    }
    for (i <- 0 until 4)
      a(i) = readLine().toCharArray() map(x => if (x == '#') true else false)

    if (check(true) || check(false)) {
      println("YES")
      return;
    }
    for (b <- List(false, true); i <- 0 until 4; j <- 0 until 4 if (a(i)(j) != b)) {
      a(i)(j) = b;
      if (check(b)) {
        println("YES")
        return;
      }
      a(i)(j) = !b;
    }
    println("NO")

  }

}

import annotation.tailrec
import java.io._

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

  val board = for(_ <- 1 to 4) yield reader.readLine().map {
    case '.' => 0
    case _ => 1
  }
  def ans = (for(i <- 0 to 2) yield (for(j <- 0 to 2) yield {
    val sum = board(i)(j) + board(i + 1)(j) + board(i)(j + 1) + board(i + 1)(j + 1)
    sum != 2
  }).contains(true)).contains(true)
  def yesNoAns = Map(true -> "YES", false -> "NO")

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

object A
{
	def main(args: Array[String]) {
		val sz = 4
		val maze = Array.ofDim[Int](sz, sz)
		for (i <- 0 until sz) {
			maze(i) = readLine.split("").tail.map( x => if(x == "#") 1 else 0 )
		}
		val result = (for (i <- 0 until sz - 1; j <- 0 until sz - 1) yield(i, j)).map( pos => {
							val (x, y) = pos
							val ss = maze(x)(y) + maze(x+1)(y) + maze(x)(y+1) + maze(x+1)(y+1)
							if(ss >= 3 || ss<=1) true else false
						}) reduceLeft(_ || _)
		println(if(result) "YES" else "NO")
	}
}

object Main {
  def main(args: Array[String]) {
    val al = new Array[String](4)
    al(0) = readLine()
    al(1) = readLine()
    al(2) = readLine()
    al(3) = readLine()

    val sqs = for {
      i <- 0 to 2
      j <- 0 to 2
    } yield(Seq(al(i)(j), al(i)(j + 1), al(i + 1)(j), al(i + 1)(j + 1)))
    if (sqs.count{ s =>
      val bl = s.count(_ == '#')
      bl <= 1 || bl >= 3
    } >= 1) println("YES")
    else println("NO")
  }
}

object CFContest176Div2A {
  def main(args: Array[String]){
    var inp = new Array[Array[Char]](4);
    inp = inp.map(_ => readLine().toCharArray())
    var result = false;
    var i =0; var j = 0;
    for(i <- 0 to 2; j <- 0 to 2){
      var b=0;
      for(k<- 0 to 1; l<- 0 to 1){
        if(inp(i+k)(j+l) == '#') b+=1;

      }
      result = result || (b<=1 || b>=3)
    }
    if(result) println("YES") else println("NO")

  }
}

object CFContest176Div2A {
  def main(args: Array[String]){
    var inp = new Array[Array[Char]](4);
    inp = inp.map(_ => readLine().toCharArray())
    var result = false;
    var i =0; var j = 0;
    for(i <- 0 to 2; j <- 0 to 2){
      var b=0;
      for(k<- 0 to 1; l<- 0 to 1){
        if(inp(i+k)(j+l) == '#') b+=1;

      }
      result = result || (b==1 || b==3)
    }
    if(result) println("YES") else println("NO")

  }
}

object IQ {

  def main (args : Array[String]){
    var a = new Array[String](4)
    for (i <- 0 until 4)
      a(i) = readLine
     var ans = 0
     for (i <- 1 to 3; j <- 1 to 3){
         if (a(i).charAt(j)=='.')ans +=1
         if (a(i-1).charAt(j-1)=='.')ans +=1
         if (a(i-1).charAt(j+1)=='.')ans +=1
         if (a(i+1).charAt(j-1)=='.')ans +=1
         if (ans!=2){
        	 println("YES");return}
         }
     println("No")
  }

}

object IQ {

  def main (args : Array[String]){
    var a = new Array[String](4)
    for (i <- 0 until 4)
      a(i) = readLine
     var ans = 0
     for (i <- 0 to 1)
       for (j <- 0 to 1)
         if (a(i).charAt(j)=='.')ans +=1
     if (ans==3 || ans==1){
       println("YES");return}
     ans = 0
     for (i <- 2 to 3)
       for (j <- 0 to 1)
         if (a(i).charAt(j)=='.')ans +=1
      if (ans==3 || ans==1){
       println("YES");return}
     ans = 0
     for (i <- 2 to 3)
       for (j <- 2 to 3)
         if (a(i).charAt(j)=='.')ans +=1
      if (ans==3 || ans==1){
       println("YES");return}
     ans = 0
     for (i <- 0 to 1)
       for (j <- 2 to 3)
         if (a(i).charAt(j)=='.')ans +=1
      if (ans==3 || ans==1){
       println("YES");return}
     println("NO")

  }

}

object A {
  def R = readLine().split(" ") map(_.toInt)

  def main(args: Array[String]) {
    var a = Array.ofDim[Boolean](4,4)
    def check:Boolean = {
      for (x <- 0 until 3; y <- 0 until 3 if (a(x)(y)&&a(x+1)(y)&&a(x)(y+1)&&a(x+1)(y+1))) return true;
      return false;
    }
    for (i <- 0 until 4)
      a(i) = readLine().toCharArray() map(x => if (x == '#') true else false)

    for (i <- 0 until 4; j <- 0 until 4 if (!a(i)(j))) {
      a(i)(j) = true;
      if (check) {
        println("YES")
        return;
      }
      a(i)(j) = false;
    }
    println("NO")

  }

}

object A {
  def R = readLine().split(" ") map(_.toInt)

  def main(args: Array[String]) {
    var a = Array.ofDim[Boolean](4,4)
    def check(b:Boolean):Boolean = {
      for (x <- 0 until 3; y <- 0 until 3 if (a(x)(y) == b &&a(x+1)(y) ==b &&a(x)(y+1) == b &&a(x+1)(y+1) == b)) return true;
      return false;
    }
    for (i <- 0 until 4)
      a(i) = readLine().toCharArray() map(x => if (x == '#') true else false)

    for (b <- List(false, true); i <- 0 until 4; j <- 0 until 4 if (a(i)(j) != b)) {
      a(i)(j) = b;
      if (check(b)) {
        println("YES")
        return;
      }
      a(i)(j) = !b;
    }
    println("NO")

  }

}

object CFContest176Div2A {
  def main(args: Array[String]){
    var inp = new Array[Array[Char]](4);
    inp = inp.map(_ => readLine().toCharArray())
    var result = false;
    var i =0; var j = 0;
    for(i <- 0 to 2; j <- 0 to 2){
      var b=0;
      for(k<- 0 to 1; l<- 0 to 1){
        if(inp(i+k)(j+l) == '#') b+=1;

      }
      result = result || (b<1 || b>3)
    }
    if(result) println("YES") else println("NO")

  }
}


//package codeforces.contest1091

object NewYearAndTheChristmasOrnament {
  def main(args: Array[String]): Unit = {
    val Array(y, b, r) = io.StdIn.readLine.split(" ").map(_.toInt)
    println(sumOfMaxPossibleIncrementalSequence(y, b, r))
  }

  def sumOfMaxPossibleIncrementalSequence(y: Int, b: Int, r: Int): Int = {
    if (!requiresFix(y, b) && !requiresFix(b, r)) y + b + r
    else {
      if (requiresFix(b, r)) {
        val f = fix(b, r)
        sumOfMaxPossibleIncrementalSequence(y, f._1, f._2)
      } else {
        val f = fix(y, b)
        sumOfMaxPossibleIncrementalSequence(f._1, f._2, r)
      }
    }
  }

  def requiresFix(x: Int, y: Int): Boolean = x + 1 != y

  def fix(x: Int, y: Int): (Int, Int) = {
    if (x < y) (x, x + 1)
    else (y - 1, y)
  }
}

import scala.io.StdIn

object A1091 {
  def main(args: Array[String]): Unit = {
    val Array (y_, b_, r_) = StdIn.readLine().split(' ').map{_.toInt}
    println(
      (for { y <-  y_ to 1 by -1
             b <-  b_  to 2 by -1
             r <-  r_ to 3 by -1
             if r == b+1 && b == y+1 }
        yield y+b+r).take(1).head
    )
  }
}

import scala.io.StdIn

object NewYearAndTheChristmasOrnament extends App {

  val line = StdIn.readLine().split(" ").map(_.toInt)

  val (y, b, r) = (line(0), line(1), line(2))

  val resY = Iterator
    .iterate(y)(_ - 1)
    .takeWhile(_ >= 1)
    .find(y1 => {
      val b1 = y1 + 1
      val r1 = b1 + 1

      b1 <= b && r1 <= r
    })
    .get

  println(resY + resY + 1 + resY + 2)
}

object A extends App {

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

  val Array(y, b, r) = readInts(3)

  val y2 = y min (b - 1) min (r - 2)
  val b2 = y2 + 1
  val r2 = b2 + 1

  println(y2 + b2 + r2)

  Console.flush
}


import scala.annotation.tailrec
import scala.io.StdIn.readLine
import scala.math.ceil

object Main extends App {
  def read(): List[Int] = readLine().split(' ').map(_.toInt).toList
  @tailrec def f(marks: List[Int], need: Int, ans: Int = 0): Int = {
    if (need > 0) marks match {
      case _ :: Nil => ans + 1
      case x :: xs => f(xs, need - 5 + x, ans + 1)
    } else ans
  }
  val List(n) = read()
  val marks = read().sorted
  val need = ceil(n * 4.5).toInt - marks.sum
  println(f(marks, need))
}

import math._
object Main extends App {
    val n = readInt
    val m = ceil(4.5 * n).toInt
    val array = readLine.split(" ").map(_.toInt).sorted
    val dif = m - array.sum
    if (dif <= 0) println(0)
    else {
        val a_2 = array.count(_ == 2)
        if (dif <= a_2 * 3) {
            println(ceil(dif / 3.0).toInt)
        } else {
            val r = dif - 3 * a_2
            val a_3 = array.count(_ == 3)
            if (r <= a_3 * 2) {
                println(ceil(r / 2.0).toInt + a_2)
            } else {
                println(dif - 2 * a_2 - a_3)
            }
        }
    }
}

import scala.annotation.tailrec
import scala.io.StdIn.readLine

object Task2 extends App {
  val n = readLine().split(' ').map(_.toInt).head

  val marks = readLine().split(' ').map(_.toInt).toList.sorted

  @tailrec
  def sol(n: Int, marks: List[Int], index: Int = 0, res: Int = 0): Int =
    if (marks.sum.toDouble / n >= 4.5) res else sol(n, marks.updated(index, 5), index + 1, res + 1)

  println(sol(n, marks))

}

object Main{
  def main(arr: Array[String]): Unit ={
    val n = readInt()
    val a = readLine.split(" ").map(_.toInt).map(_ * 10)

    val totReq = n * 45

    val as = a.sorted
    var ctot = as.sum
    var changes = 0
    var i = 0
    while(totReq > ctot && i < n){
      ctot += (50 - as(i))
      changes += 1
      i += 1
    }

    println(changes)
  }
}

import math._
object Main extends App {
    val n = readInt
    val m = 5 * n - n / 2
    val array = readLine.split(" ").map(_.toInt).sorted
    val dif = m - array.sum
    if (dif <= 0) println(0)
    else {
        val a_3 = array.count(_ == 3)
        if (dif <= a_3 * 2){
            println(ceil(dif / 2))
        } else {
            println(dif - a_3)
        }
    }
}

import math._
object Main extends App {
    val n = readInt
    val m = 5 * n - n / 2
    val array = readLine.split(" ").map(_.toInt).sorted
    val dif = m - array.sum
    if (dif <= 0) println(0)
    else {
        val a_3 = array.count(_ == 3)
        if (dif <= a_3 * 2){
            println(ceil(dif / 2).toInt)
        } else {
            println(dif - a_3)
        }
    }
}

import math._
object Main extends App {
    val n = readInt
    val m = ceil(4.5 * n).toInt
    val array = readLine.split(" ").map(_.toInt).sorted
    val dif = m - array.sum
    if (dif <= 0) println(0)
    else {
        val a_3 = array.count(_ == 3)
        if (dif <= a_3 * 2){
            println(ceil(dif / 2).toInt)
        } else {
            println(dif - a_3)
        }
    }
}

import math._
object Main extends App {
    val n = readInt
    val m = ceil(4.5 * n).toInt
    val array = readLine.split(" ").map(_.toInt).sorted
    val dif = m - array.sum
    if (dif <= 0) println(0)
    else {
        val a_3 = array.count(_ == 3)
        if (dif <= a_3 * 2){
            println(ceil(dif / 2.0).toInt)
        } else {
            println(dif - a_3)
        }
    }
}

import math._
object Main extends App {
    val n = readInt
    val m = 5 * n - n / 2
    val array = readLine.split(" ").map(_.toInt).sorted
    val dif = m - array.sum
    if (dif <= 0) println(0)
    else {
        val a_3 = array.count(_ == 3)
        if (dif <= a_3 * 2){
            println(dif / 2)
        } else {
            println(dif - a_3)
        }
    }
}


import scala.collection._

object C 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)
  var ls, rs = Array.ofDim[Int](n)

  for (i <- 0 until n) {
    val Array(l, r) = readInts(2)
    ls(i) = l
    rs(i) = r
  }

  var ev1, ev2 = 0d

  def probWin(x: Int, l: Int, r: Int): Double = {
    if (x < l) 0d
    else if (x > r) 1d
    else (x - l + 0d) / (r - l + 1d)
  }

  def probLose(x: Int, l: Int, r: Int): Double = {
    if (x < l) 1d
    else if (x > r) 0d
    else (r - x + 0d) / (r - l + 1d)
  }

  def probEq(x: Int, l: Int, r: Int): Double = {
    if (x < l) 0d
    else if (x > r) 0d
    else 1d / (r - l + 1d)
  }

  val maxMask = (1 << (n - 2)) - 1

  for (p1 <- 0 until n) {
    for (p2 <- 0 until n) if (p2 != p1) {
      var sumProb1 = 0d
      var sumProb2 = 0d
      for (x2 <- ls(p2) to rs(p2)) {
        for (mask <- 0 to maxMask) {
          var prob = 1d
          var i = 1
          var eqCnt = 2
          for (px <- 0 until n) if (px != p2 && px != p1) {
            if ((mask & i) == 0) prob *= probWin(x2, ls(px), rs(px))
            else {
              prob *= probEq(x2, ls(px), rs(px))
              eqCnt += 1
            }
            i *= 2
          }
         // println(p1, p2, x2, mask, prob, probLose(x2, ls(p1), rs(p1)), probEq(x2, ls(p1), rs(p1)))
          sumProb1 += x2 * prob * probLose(x2, ls(p1), rs(p1)) / (eqCnt - 1d)
          sumProb2 += x2 * prob * probEq(x2, ls(p1), rs(p1)) / (eqCnt - 1d) / eqCnt
          //sumProb2 += x2 * 0.5d * prob * probEq(x2, ls(p1), rs(p1))
        }
      }
      ev1 += sumProb1 / (rs(p2) - ls(p2) + 1d)
      ev2 += sumProb2 / (rs(p2) - ls(p2) + 1d)
    }
  }
  //println(ev1, ev2)
  println(ev1 + ev2)
}

import java.util.StringTokenizer

object _513C extends App {
  var token = new StringTokenizer("")
  def next = {
    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)
    token.nextToken()
  }

  val n = next.toInt
  val l = Array.fill(n)(0)
  val r = Array.fill(n)(0)
  for (i <- 0 until n) {
    l(i) = next.toInt
    r(i) = next.toInt
  }
  val mask = (1 to n).toArray
  val denominator = (l zip r).map(p => 1.0 * (p._2 - p._1 + 1)).reduce(_ * _)

  def calc(l: Int, r: Int, ll: Int, rr: Int): Double = {
    val lll = l max ll
    val rrr = r min rr
    if (lll <= rrr) rrr - lll + 1 else 0
  }

  var second = 1
  var numerator = 0.0
  def dfs(t: Int) {
    if (t >= n) {
      val sorted = mask.sorted
      if (sorted(n - 2) == 0) {
        var tmp = 1.0
        for (i <- 0 until n) {
          if (mask(i) == 1) tmp *= calc(l(i), r(i), second + 1, Int.MaxValue)
          else if (mask(i) == 0) tmp *= calc(l(i), r(i), second, second)
          else tmp *= calc(l(i), r(i), 0, second - 1)
        }
        numerator += second * tmp
      }
    } else {
      for (i <- -1 to 1) {
        mask(t) = i; dfs(t + 1)
      }
    }
  }
  while (second <= 10000) {
    dfs(0)
    second += 1
  }
  println("%.10f".format(numerator / denominator))
}

import java.io.FileInputStream
import java.util.Scanner
import scala.collection.mutable

object Solution {
  def main(args: Array[String]) {
    val sc = new Scanner(if (args.length > 0) new FileInputStream(args(0)) else System.in)
    val n = sc.nextInt

    val arr = Array.tabulate(n)(_ => (sc.nextInt(), sc.nextInt()))
    //val start = System.nanoTime()
    println(new Auction(n, arr).expectationOfSecond())
    //val end = System.nanoTime()
    //println("Time = " + (end - start) / 1000000L)
  }
}

class Auction(n: Int, r: Array[(Int, Int)]) {
  def low(i: Int): Int = r(i)._1
  def hi(i: Int): Int = r(i)._2
  def length(i: Int): Int = r(i)._2 - r(i)._1 + 1

  val ZERO = BigInt(0)
  val ONE = BigInt(0)
  def gcd(a: BigInt, b: BigInt): BigInt = if (b == ZERO) a else gcd(b, a % b)

  def simplify(a: BigInt, b: BigInt): (BigInt, BigInt) = {
    val g = gcd(a, b)
    if (g == ONE) (a, b) else (a / g, b / g)
  }

  def expectationOfSecond(): Double = {
    val secondFrom = (0 until n).map(low).sortWith(_ > _)(1)
    val secondTo = (0 until n).map(hi).sortWith(_ > _)(1)
    val map = new mutable.OpenHashMap[BigInt, BigInt](200000)
    //val summands =
      for {
        second <- secondFrom to secondTo
        si <- 0 until n if low(si) <= second && second <= hi(si)
        fi <- 0 until n if fi != si && (if (fi < si) second + 1 else second) <= hi(fi)
        if (0 until n).filter(i => i != si && i != fi).forall(i => low(i) <= (if (i < si) second + 1 else second))
      } {
        val a0: BigInt = second * (hi(fi) - math.max(if (fi < si) second + 1 else second, low(fi)) + 1)
        val b0: BigInt = length(si) * length(fi)
        val is = (0 until n).filter(i => i != si && i != fi && hi(i) > (if (i < si) second else second - 1))
        val a = is.map(i => (if (i < si) second else second - 1) - low(i) + 1).foldLeft(a0)(_ * _)
        val b = is.map(i => length(i)).foldLeft(b0)(_ * _)
        val x = simplify(a, b)
        map += (x._2 -> (map.getOrElse(x._2, ZERO) + x._1))
      }
      val grouped = map.toIterator.map(p => simplify(p._2, p._1))
//    val grouped = summands.foldLeft(Map[BigInt, BigInt]())((m, x) => m + (x._2 -> (m.getOrElse(x._2, ZERO) + x._1))).
//      toList.map(p => simplify(p._2, p._1))

    //println(  summands.foldLeft(Map[BigInt, BigInt]()) ( (m, x) => m + (x._2 -> (m.getOrElse(x._2, ZERO) + x._1)) )  )

    //val grouped = summands.groupBy(_._2).mapValues(_.map(_._1).sum).toList.map(p=>simplify(p._2,p._1))
    //val grouped = summands.agroupBy(_._2).map(p => (p._1,p._2.map(_._1).sum)).map(p=>simplify(p._2,p._1))
    grouped.map(p => BigDecimal(p._1) / BigDecimal(p._2)).sum.toDouble
  }
}

import java.util.Scanner
import java.io.FileInputStream

object DoubleSolution {

  def main(args: Array[String]) {
    val sc = new Scanner(if (args.length > 0) new FileInputStream(args(0)) else System.in)
    val n = sc.nextInt
    val arr = Array.tabulate(n)(_ => (sc.nextInt(), sc.nextInt()))
    //val start = System.nanoTime()
    println(new DoubleAuction(n, arr).expectationOfSecond())
    //val end = System.nanoTime()
    //println("Time = " + (end - start) / 1000000L)
  }
}

class DoubleAuction(n: Int, r: Array[(Int, Int)]) {
  def low(i: Int): Int = r(i)._1
  def hi(i: Int): Int = r(i)._2
  def length(i: Int): Int = r(i)._2 - r(i)._1 + 1

  val ZERO = BigInt(0)
  val ONE = BigInt(0)
  def gcd(a: BigInt, b: BigInt): BigInt = if (b == ZERO) a else gcd(b, a % b)

  def simplify(a: BigInt, b: BigInt): (BigInt, BigInt) = {
    val g = gcd(a, b)
    if (g == ONE) (a, b) else (a / g, b / g)
  }

  def expectationOfSecond(): Double = {
    val secondFrom = (0 until n).map(low).sortWith(_ > _)(1)
    val secondTo = (0 until n).map(hi).sortWith(_ > _)(1)
    var value = 0.0
    var second = secondFrom
    while (second<=secondTo) {
      var si = 0
      while (si < n) {
        if (low(si) <= second && second <= hi(si)) {
          var fi = 0
          while (fi<n) {
            if (fi != si && (if (fi < si) second + 1 else second) <= hi(fi)) {
              var exists = true
              var k = 0
              while (exists && k < n) {
                if (k != si && k != fi) {
                  if (!(low(k) <= (if (k < si) second + 1 else second))) exists = false
                }
                k += 1
              }
              if (exists) {
                var a0 = second * (hi(fi) - math.max(if (fi < si) second + 1 else second, low(fi)) + 1) / length(si).toDouble / length(fi)
                var i = 0
                while (i < n) {
                  if (i != si && i != fi && hi(i) > (if (i < si) second else second - 1)) {
                    a0 *= ((if (i < si) second else second - 1) - low(i) + 1)
                    a0 /= length(i)
                  }
                  i += 1
                }
                value = value + a0
              }
            }
            fi += 1
          }
        }
        si += 1
      }
      second += 1
    }
    value
  }
}

import java.util.Scanner
import java.io.FileInputStream

object DoubleSolution {

  def main(args: Array[String]) {
    val sc = new Scanner(if (args.length > 0) new FileInputStream(args(0)) else System.in)
    val n = sc.nextInt
    val arr = Array.tabulate(n)(_ => (sc.nextInt(), sc.nextInt()))
    println(new DoubleAuction(n, arr).expectationOfSecond())
  }
}

class DoubleAuction(n: Int, r: Array[(Int, Int)]) {
  def low(i: Int): Int = r(i)._1
  def hi(i: Int): Int = r(i)._2
  def length(i: Int): Int = r(i)._2 - r(i)._1 + 1

  val ZERO = BigInt(0)
  val ONE = BigInt(0)
  def gcd(a: BigInt, b: BigInt): BigInt = if (b == ZERO) a else gcd(b, a % b)

  def simplify(a: BigInt, b: BigInt): (BigInt, BigInt) = {
    val g = gcd(a, b)
    if (g == ONE) (a, b) else (a / g, b / g)
  }

  def expectationOfSecond(): Double = {
    val secondFrom = (0 until n).map(low).sortWith(_ > _)(1)
    val secondTo = (0 until n).map(hi).sortWith(_ > _)(1)
    //val summands =
    (for {
      second <- secondFrom to secondTo
      si <- 0 until n if low(si) <= second && second <= hi(si)
      fi <- 0 until n if fi != si && (if (fi < si) second + 1 else second) <= hi(fi)
      if (0 until n).filter(i => i != si && i != fi).forall(i => low(i) <= (if (i < si) second + 1 else second))

    } yield {
      val a0: Double = second * (hi(fi) - math.max(if (fi < si) second + 1 else second, low(fi)) + 1) / length(si).toDouble / length(fi)
      (0 until n).filter(i => i != si && i != fi && hi(i) > (if (i < si) second else second - 1)).
        foldLeft(a0) ((p, i) => p * ((if (i < si) second else second - 1) - low(i) + 1) / length(i))
    }).sum
  }
}

import java.util.StringTokenizer

object _513C extends App {
  var token = new StringTokenizer("")
  def next = {
    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)
    token.nextToken()
  }

  val n = next.toInt
  val l = Array.fill(n)(0)
  val r = Array.fill(n)(0)
  for (i <- 0 until n) {
    l(i) = next.toInt
    r(i) = next.toInt
  }
  val mask = (1 to n).toArray
  val denominator = (l zip r).map(p => 1.0 * (p._2 - p._1 + 1)).reduce(_ * _)

  def calc(l: Int, r: Int, ll: Int, rr: Int): Double = {
    val lll = l max ll
    val rrr = r min rr
    if (lll <= rrr) rrr - lll + 1 else 0
  }

  val numerators = for (second <- 1 to 50) yield {
    def dfs(t: Int): Double =
      if (t >= n) {
        val sorted = mask.sorted
        if (sorted(n - 2) == 0) {
          val cand = for (i <- 0 until n) yield {
            if (mask(i) == 1) calc(l(i), r(i), second + 1, Int.MaxValue)
            else if (mask(i) == 0) calc(l(i), r(i), second, second)
            else calc(l(i), r(i), 0, second - 1)
          }
          cand.reduce(_ * _) * second
        } else 0
      } else {
        val hehe = for (i <- -1 to 1) yield { mask(t) = i; dfs(t + 1) }
        hehe.sum
      }
    dfs(0)
  }
  val numerator = numerators.sum
  println("%.10f".format(numerator / denominator))
}

import scala.collection._

object C 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)
  var ls, rs = Array.ofDim[Int](n)

  for (i <- 0 until n) {
    val Array(l, r) = readInts(2)
    ls(i) = l
    rs(i) = r
  }

  var ev1, ev2 = 0d

  def probWin(x: Int, l: Int, r: Int): Double = {
    if (x < l) 0d
    else if (x > r) 1d
    else (x - l + 0d) / (r - l + 1d)
  }

  def probLose(x: Int, l: Int, r: Int): Double = {
    if (x < l) 1d
    else if (x > r) 0d
    else (r - x + 0d) / (r - l + 1d)
  }

  def probEq(x: Int, l: Int, r: Int): Double = {
    if (x < l) 0d
    else if (x > r) 0d
    else 1d / (r - l + 1d)
  }

  val maxMask = (1 << (n - 2)) - 1

  for (p1 <- 0 until n) {
    for (p2 <- 0 until n) if (p2 != p1) {
      var sumProb1 = 0d
      var sumProb2 = 0d
      for (x2 <- ls(p2) to rs(p2)) {
        for (mask <- 0 to maxMask) {
          var prob = 1d
          var i = 1
          var eqCnt = 2
          for (px <- 0 until n) if (px != p2 && px != p1) {
            if ((mask & i) == 0) prob *= probWin(x2, ls(px), rs(px))
            else {
              prob *= probEq(x2, ls(px), rs(px))
              eqCnt += 1
            }
            i *= 2
          }
         // println(p1, p2, x2, mask, prob, probLose(x2, ls(p1), rs(p1)), probEq(x2, ls(p1), rs(p1)))
          sumProb1 += x2 * prob * probLose(x2, ls(p1), rs(p1)) / (eqCnt - 1d)
          sumProb2 += x2 * prob * probEq(x2, ls(p1), rs(p1)) / (eqCnt - 1d) / eqCnt
          //sumProb2 += x2 * 0.5d * prob * probEq(x2, ls(p1), rs(p1))
        }
      }
      ev1 += sumProb1 / (rs(p2) - ls(p2) + 1d)
      ev2 += sumProb2 / (rs(p2) - ls(p2) + 1d)
    }
  }
  println(ev1, ev2)
  println(ev1 + ev2)
}

import java.util.Scanner
import java.io.FileInputStream

object DoubleSolution {

  def main(args: Array[String]) {
    val sc = new Scanner(if (args.length > 0) new FileInputStream(args(0)) else System.in)
    val n = sc.nextInt
    val arr = Array.tabulate(n)(_ => (sc.nextInt(), sc.nextInt()))
    println(new DoubleAuction(n, arr).expectationOfSecond())
  }
}

class DoubleAuction(n: Int, r: Array[(Int, Int)]) {
  def low(i: Int): Int = r(i)._1
  def hi(i: Int): Int = r(i)._2
  def length(i: Int): Int = r(i)._2 - r(i)._1 + 1

  val ZERO = BigInt(0)
  val ONE = BigInt(0)
  def gcd(a: BigInt, b: BigInt): BigInt = if (b == ZERO) a else gcd(b, a % b)

  def simplify(a: BigInt, b: BigInt): (BigInt, BigInt) = {
    val g = gcd(a, b)
    if (g == ONE) (a, b) else (a / g, b / g)
  }

  def expectationOfSecond(): Double = {
    val secondFrom = (0 until n).map(low).sortWith(_ > _)(1)
    val secondTo = (0 until n).map(hi).sortWith(_ > _)(1)
    var value = 0.0
    var second = secondFrom
    while (second<=secondTo) {
      var si = 0
      while (si < n) {
        if (low(si) <= second && second <= hi(si)) {
          var fi = 0
          while (fi < n) {
            if (fi != si && (if (fi < si) second + 1 else second) <= hi(fi)) {
              var v = second * (hi(fi) - math.max(if (fi < si) second + 1 else second, low(fi)) + 1) / length(si).toDouble / length(fi)
              var i = 0
              while (i < n) {
                if (i != si && i != fi && hi(i) > (if (i < si) second else second - 1)) {
                  v *= ((if (i < si) second else second - 1) - low(i) + 1) / length(i).toDouble
                }
                i += 1
              }
              value += v
            }
            fi += 1
          }
        }
        si += 1
      }
      second += 1
    }
    value
  }
}

import Fraction._
import java.io.FileInputStream
import java.util.Scanner

object Solution {
  def main(args: Array[String]) {
    // assert(new Auction(3, Array((4, 7), (8, 10), (5, 5))).expectationOfSecond().toDouble == 5.75)
    // assert(new Auction(3, Array((2,5), (3,4), (1,6))).expectationOfSecond().toDouble == 3.5)
    val sc = new Scanner(if (args.length > 0) new FileInputStream(args(0)) else System.in)
    val n = sc.nextInt
    val arr = Array.tabulate(n)(_ => (sc.nextInt(), sc.nextInt()))
    val expectation = new Auction(3, arr).expectationOfSecond().toDouble
    println(expectation)
  }
}

class Fraction(val a:Long, val b:Long) {
  def toDouble: Double = if (a == 0) 0.0 else a.toDouble / b

  def *(that: Fraction): Fraction = mul(this, that)

  override def toString: String =
    if (a == 0) "0"
    else if (b == 1) a.toString
    else a + "/" + b
}

object Fraction {
  val ZERO = new Fraction(0L, 1L)
  val ONE = new Fraction(1L, 1L)
  def gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)
  def fract(a: Long, b: Long): Fraction =
    if (a == 0L) ZERO
    else if (a == b) ONE
    else {
      val d = gcd(a, b)
      new Fraction(a / d, b / d)
    }

  def mul(x: Fraction, y: Fraction): Fraction =
    if (x == ZERO || y == ZERO) ZERO
    else if (x == ONE) y
    else if (y == ONE) x
    else fract(x.a * y.a, x.b * y.b)

  def mul(x: Long, y: Fraction): Fraction =
    if (x == 0 || y == ZERO) ZERO
    else if (x == 1) y
    else if (y == ONE) new Fraction(x, 1L)
    else fract(x * y.a, y.b)

  def sum(x: Fraction, y: Fraction): Fraction =
    if (x == ZERO) y
    else if (y == ZERO) x
    else if (x.b == y.b) fract(x.a + y.a, x.b)
    else fract(x.a * y.b + y.a * x.b, x.b * y.b)
}

class Auction(n: Int, r: Array[(Int, Int)]) {
  @inline def low(i: Int): Int = r(i)._1
  @inline def hi(i: Int): Int = r(i)._2
  @inline def length(i: Int): Int = r(i)._2 - r(i)._1 + 1

  def pFirst(firstFrom: Int, excluded: Int): Fraction = {
    @inline def from(i: Int) = if (i < excluded) firstFrom + 1 else firstFrom
    @inline def till(i: Int) = if (i < excluded) firstFrom else firstFrom - 1
    val fs = (0 until n).filter(i => i != excluded && from(i) <= hi(i))
    if (fs.isEmpty) ZERO
    else
      fs.map(f =>
        (0 until n).filter(i => i != excluded && i != f).
          map(i => if (hi(i) <= till(i)) ONE
                   else if (till(i) < low(i)) ZERO
                   else fract(till(i) - low(i) + 1, length(i))).
          foldLeft(fract(hi(f) - math.max(from(f), low(f)) + 1, length(f)))(mul)
      ).reduce(sum)
  }

  def expectationOfSecond(): Fraction = {
    val secondFrom = (0 until n).map(low).sortWith(_ > _)(1)
    val secondTo = (0 until n).map(hi).sortWith(_ > _)(1)
    (for {
      second <- secondFrom to secondTo
      i <- 0 until n if low(i) <= second && second <= hi(i)
    } yield fract(second, length(i)) * pFirst(second, i)) reduce sum
  }

}

import java.io.FileInputStream
import java.util.Scanner

object Solution {
  def main(args: Array[String]) {
    val sc = new Scanner(if (args.length > 0) new FileInputStream(args(0)) else System.in)
    val n = sc.nextInt
    val arr = Array.tabulate(n)(_ => (sc.nextInt(), sc.nextInt()))
    println(new Auction(n, arr).expectationOfSecond())
  }
}
class Auction(n: Int, r: Array[(Int, Int)]) {
  def low(i: Int): Int = r(i)._1
  def hi(i: Int): Int = r(i)._2
  def length(i: Int): Int = r(i)._2 - r(i)._1 + 1

  val ZERO = BigInt(0)
  val ONE = BigInt(0)
  def gcd(a: BigInt, b: BigInt): BigInt = if (b == ZERO) a else gcd(b, a % b)

  def simplify(a: BigInt, b: BigInt): (BigInt, BigInt) = {
    val g = gcd(a, b)
    if (g == ONE) (a, b) else (a / g, b / g)
  }

  def expectationOfSecond(): Double = {
    val secondFrom = (0 until n).map(low).sortWith(_ > _)(1)
    val secondTo = (0 until n).map(hi).sortWith(_ > _)(1)
    val summands =
      for {
        second <- secondFrom to secondTo
        si <- 0 until n if low(si) <= second && second <= hi(si)
        fi <- 0 until n if fi != si && (if (fi < si) second + 1 else second) <= hi(fi)
        if (0 until n).filter(i => i != si && i != fi).forall(i => low(i) <= (if (i < si) second + 1 else second))
      } yield {
        val a0: BigInt = second * (hi(fi) - math.max(if (fi < si) second + 1 else second, low(fi)) + 1)
        val b0: BigInt = length(si) * length(fi)
        val is = (0 until n).filter(i => i != si && i != fi && hi(i) > (if (i < si) second else second - 1))
        val a = is.map(i => (if (i < si) second else second - 1) - low(i) + 1).foldLeft(a0)(_ * _)
        val b = is.map(i => length(i)).foldLeft(b0)(_ * _)
        simplify(a, b)
      }
    //val optimized = summands
    val grouped = summands.groupBy(_._2).mapValues(_.map(_._1).sum).map(p => simplify(p._2, p._1))
    grouped.map(p => BigDecimal(p._1) / BigDecimal(p._2)).sum.toDouble
  }
}

import Fraction._
import java.io.FileInputStream
import java.util.Scanner

object Solution {
  def main(args: Array[String]) {
    val sc = new Scanner(if (args.length > 0) new FileInputStream(args(0)) else System.in)
    val n = sc.nextInt
    val arr = Array.tabulate(n)(_ => (sc.nextInt(), sc.nextInt()))
    val expectation = new Auction(n, arr).expectationOfSecond().toDouble
    println(expectation)
  }
}

class Fraction(val a:Long, val b:Long) {
  def toDouble: Double = if (a == 0) 0.0 else a.toDouble / b

  def *(that: Fraction): Fraction = mul(this, that)

  override def toString: String =
    if (a == 0) "0"
    else if (b == 1) a.toString
    else a + "/" + b
}

object Fraction {
  val ZERO = new Fraction(0L, 1L)
  val ONE = new Fraction(1L, 1L)
  def gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)
  def fract(a: Long, b: Long): Fraction =
    if (a == 0L) ZERO
    else if (a == b) ONE
    else {
      val d = gcd(a, b)
      new Fraction(a / d, b / d)
    }

  def mul(x: Fraction, y: Fraction): Fraction =
    if (x == ZERO || y == ZERO) ZERO
    else if (x == ONE) y
    else if (y == ONE) x
    else fract(x.a * y.a, x.b * y.b)

  def mul(x: Long, y: Fraction): Fraction =
    if (x == 0 || y == ZERO) ZERO
    else if (x == 1) y
    else if (y == ONE) new Fraction(x, 1L)
    else fract(x * y.a, y.b)

  def sum(x: Fraction, y: Fraction): Fraction =
    if (x == ZERO) y
    else if (y == ZERO) x
    else if (x.b == y.b) fract(x.a + y.a, x.b)
    else fract(x.a * y.b + y.a * x.b, x.b * y.b)
}

class Auction(n: Int, r: Array[(Int, Int)]) {
  @inline def low(i: Int): Int = r(i)._1
  @inline def hi(i: Int): Int = r(i)._2
  @inline def length(i: Int): Int = r(i)._2 - r(i)._1 + 1

  def pFirst(firstFrom: Int, excluded: Int): Fraction = {
    @inline def from(i: Int) = if (i < excluded) firstFrom + 1 else firstFrom
    @inline def till(i: Int) = if (i < excluded) firstFrom else firstFrom - 1
    val fs = (0 until n).filter(i => i != excluded && from(i) <= hi(i))
    if (fs.isEmpty) ZERO
    else
      fs.map(f =>
        (0 until n).filter(i => i != excluded && i != f).
          map(i => if (hi(i) <= till(i)) ONE
                   else if (till(i) < low(i)) ZERO
                   else fract(till(i) - low(i) + 1, length(i))).
          foldLeft(fract(hi(f) - math.max(from(f), low(f)) + 1, length(f)))(mul)
      ).reduce(sum)
  }

  def expectationOfSecond(): Fraction = {
    val secondFrom = (0 until n).map(low).sortWith(_ > _)(1)
    val secondTo = (0 until n).map(hi).sortWith(_ > _)(1)
    (for {
      second <- secondFrom to secondTo
      i <- 0 until n if low(i) <= second && second <= hi(i)
    } yield fract(second, length(i)) * pFirst(second, i)) reduce sum
  }

}

import Fraction._
import java.io.FileInputStream
import java.util.Scanner

object Solution {
  def main(args: Array[String]) {
    // assert(new Auction(3, Array((4, 7), (8, 10), (5, 5))).expectationOfSecond().toDouble == 5.75)
    // assert(new Auction(3, Array((2,5), (3,4), (1,6))).expectationOfSecond().toDouble == 3.5)
    val sc = new Scanner(if (args.length > 0) new FileInputStream(args(0)) else System.in)
    val n = sc.nextInt
    val arr = Array.tabulate(n)(_ => (sc.nextInt(), sc.nextInt()))
    val start = System.nanoTime()
    val expectation = new Auction(n, arr).expectationOfSecond().toDouble
    val end = System.nanoTime()
    println(expectation)
    println("Time = " + (end - start) / 1000000L)
  }
}

class Fraction(val a:Long, val b:Long) {
  def toDouble: Double = if (a == 0) 0.0 else a.toDouble / b

  def *(that: Fraction): Fraction = mul(this, that)

  override def toString: String =
    if (a == 0) "0"
    else if (b == 1) a.toString
    else a + "/" + b
}

object Fraction {
  val ZERO = new Fraction(0L, 1L)
  val ONE = new Fraction(1L, 1L)
  def gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)
  def fract(a: Long, b: Long): Fraction =
    if (a == 0L) ZERO
    else if (a == b) ONE
    else {
      val d = gcd(a, b)
      new Fraction(a / d, b / d)
    }

//  def mul(x: Fraction, y: Fraction): Fraction =
//    if (x == ZERO || y == ZERO) ZERO
//    else if (x == ONE) y
//    else if (y == ONE) x
//    else {
//      val gcd1 = gcd(x.a, y.b)
//      val gcd2 = gcd(x.b, y.a)
//      fract((x.a / gcd1) * (y.a / gcd2), (x.b / gcd2) * (y.b / gcd1))
//      if (x.a * y.a < x.a || x.a * y.a < y.a) println(x.a, y.a, x.a * y.a)
//      fract( x.a * y.a, x.b * y.b)
//    }

  def mul(x: Fraction, y: Fraction): Fraction = mulUnsafe(reduce(x), reduce(y))
  def mulUnsafe(x: Fraction, y: Fraction): Fraction =
    if (x == ZERO || y == ZERO) ZERO
    else if (x == ONE) y
    else if (y == ONE) x
    else {
      val gcd1 = gcd(x.a, y.b)
      val gcd2 = gcd(x.b, y.a)
      fract((x.a / gcd1) * (y.a / gcd2), (x.b / gcd2) * (y.b / gcd1))
      if (x.a * y.a < x.a || x.a * y.a < y.a) println(x.a, y.a, x.a * y.a)
      fract( x.a * y.a, x.b * y.b)
    }

  def mul(x: Long, y: Fraction): Fraction =
    if (x == 0 || y == ZERO) ZERO
    else if (x == 1) y
    else if (y == ONE) new Fraction(x, 1L)
    else fract(x * y.a, y.b)

//  def sum(x: Fraction, y: Fraction): Fraction =
//    if (x == ZERO) y
//    else if (y == ZERO) x
//    else if (x.b == y.b) fract(x.a + y.a, x.b)
//    else {
//      val g = gcd(x.b, y.b)
//      if (g == 1) fract(x.a * y.b + y.a * x.b, x.b * y.b)
//      else fract(x.a * (y.b / g) + y.a * (x.b / g), x.b / g * y.b)
//    }

  def sumUnsafe(x: Fraction, y: Fraction): Fraction =
    if (x == ZERO) y
    else if (y == ZERO) x
    else if (x.b == y.b) fract(x.a + y.a, x.b)
    else {
      val g = gcd(x.b, y.b)
      if (g == 1) fract(x.a * y.b + y.a * x.b, x.b * y.b)
      else fract(x.a * (y.b / g) + y.a * (x.b / g), x.b / g * y.b)
    }

  def sum(x: Fraction, y: Fraction): Fraction = sumUnsafe(reduce(x),reduce(y))

  val MAX: Long = Integer.MAX_VALUE
  def reduce(x: Fraction): Fraction =
    if (x.a < MAX && x.b < MAX) x
    else {
      var a = x.a
      var b = x.b
      while (a > MAX || b > MAX) {
        a >>= 1
        b >>= 1
      }
      fract(a, b)
    }
}

//class BigFraction(val a:BigInt, val b:BigInt) {
//
//}
//
//object BigFraction {
//  def sum(x: BigFraction, y: Fraction): BigFraction = {
//
//  }
//}

class Auction(n: Int, r: Array[(Int, Int)]) {
  @inline def low(i: Int): Int = r(i)._1
  @inline def hi(i: Int): Int = r(i)._2
  @inline def length(i: Int): Int = r(i)._2 - r(i)._1 + 1

  def pFirst(firstFrom: Int, excluded: Int): Fraction = {
    @inline def from(i: Int) = if (i < excluded) firstFrom + 1 else firstFrom
    @inline def till(i: Int) = if (i < excluded) firstFrom else firstFrom - 1
    val fs = (0 until n).filter(i => i != excluded && from(i) <= hi(i))
    if (fs.isEmpty) ZERO
    else
      fs.map(f =>
        (0 until n).filter(i => i != excluded && i != f).
          map(i => if (hi(i) <= till(i)) ONE
                   else if (till(i) < low(i)) ZERO
                   else fract(till(i) - low(i) + 1, length(i))).
          foldLeft(fract(hi(f) - math.max(from(f), low(f)) + 1, length(f)))(mul)
      ).reduce(sum)
  }

  def expectationOfSecond(): Fraction = {
    val secondFrom = (0 until n).map(low).sortWith(_ > _)(1)
    val secondTo = (0 until n).map(hi).sortWith(_ > _)(1)
    val summands =
      for {
        second <- secondFrom to secondTo
        i <- 0 until n if low(i) <= second && second <= hi(i)
      } yield fract(second, length(i)) * pFirst(second, i)
    val optimized = summands.groupBy(_.b).mapValues(_.map(_.a).sum).map(p => fract(p._2, p._1))
    optimized.reduce(sum)
  }

}

import Fraction._
import java.io.FileInputStream
import java.util.Scanner

object Solution {
  def main(args: Array[String]) {
    // assert(new Auction(3, Array((4, 7), (8, 10), (5, 5))).expectationOfSecond().toDouble == 5.75)
    // assert(new Auction(3, Array((2,5), (3,4), (1,6))).expectationOfSecond().toDouble == 3.5)
    val sc = new Scanner(if (args.length > 0) new FileInputStream(args(0)) else System.in)
    val n = sc.nextInt
    val arr = Array.tabulate(n)(_ => (sc.nextInt(), sc.nextInt()))
//    val start = System.nanoTime()
    val expectation = new Auction(n, arr).expectationOfSecond().toDouble
//    val end = System.nanoTime()
    println(expectation)
//    println("Time = " + (end - start) / 1000000L)
  }
}

class Fraction(val a:Long, val b:Long) {
  def toDouble: Double = if (a == 0) 0.0 else a.toDouble / b

  def *(that: Fraction): Fraction = mul(this, that)

  override def toString: String =
    if (a == 0) "0"
    else if (b == 1) a.toString
    else a + "/" + b
}

object Fraction {
  val ZERO = new Fraction(0L, 1L)
  val ONE = new Fraction(1L, 1L)
  def gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)
  def fract(a: Long, b: Long): Fraction =
    if (a == 0L) ZERO
    else if (a == b) ONE
    else {
      val d = gcd(a, b)
      new Fraction(a / d, b / d)
    }

//  def mul(x: Fraction, y: Fraction): Fraction =
//    if (x == ZERO || y == ZERO) ZERO
//    else if (x == ONE) y
//    else if (y == ONE) x
//    else {
//      val gcd1 = gcd(x.a, y.b)
//      val gcd2 = gcd(x.b, y.a)
//      fract((x.a / gcd1) * (y.a / gcd2), (x.b / gcd2) * (y.b / gcd1))
//      if (x.a * y.a < x.a || x.a * y.a < y.a) println(x.a, y.a, x.a * y.a)
//      fract( x.a * y.a, x.b * y.b)
//    }

  def mul(x: Fraction, y: Fraction): Fraction = mulUnsafe(reduce(x), reduce(y))
  def mulUnsafe(x: Fraction, y: Fraction): Fraction =
    if (x == ZERO || y == ZERO) ZERO
    else if (x == ONE) y
    else if (y == ONE) x
    else {
      //val gcd1 = gcd(x.a, y.b)
      //val gcd2 = gcd(x.b, y.a)
      // fract((x.a / gcd1) * (y.a / gcd2), (x.b / gcd2) * (y.b / gcd1))
      // if (x.a * y.a < x.a || x.a * y.a < y.a) println(x.a, y.a, x.a * y.a)
      fract( x.a * y.a, x.b * y.b)
    }

  def mul(x: Long, y: Fraction): Fraction =
    if (x == 0 || y == ZERO) ZERO
    else if (x == 1) y
    else if (y == ONE) new Fraction(x, 1L)
    else fract(x * y.a, y.b)

//  def sum(x: Fraction, y: Fraction): Fraction =
//    if (x == ZERO) y
//    else if (y == ZERO) x
//    else if (x.b == y.b) fract(x.a + y.a, x.b)
//    else {
//      val g = gcd(x.b, y.b)
//      if (g == 1) fract(x.a * y.b + y.a * x.b, x.b * y.b)
//      else fract(x.a * (y.b / g) + y.a * (x.b / g), x.b / g * y.b)
//    }

  def sumUnsafe(x: Fraction, y: Fraction): Fraction =
    if (x == ZERO) y
    else if (y == ZERO) x
    else if (x.b == y.b) fract(x.a + y.a, x.b)
    else {
      val g = gcd(x.b, y.b)
      if (g == 1) fract(x.a * y.b + y.a * x.b, x.b * y.b)
      else fract(x.a * (y.b / g) + y.a * (x.b / g), x.b / g * y.b)
    }

  def sum(x: Fraction, y: Fraction): Fraction = sumUnsafe(reduce(x),reduce(y))

  val MAX: Long = Integer.MAX_VALUE
  def reduce(x: Fraction): Fraction =
    if (x.a < MAX && x.b < MAX) x
    else {
      var a = x.a
      var b = x.b
      while (a > MAX || b > MAX) {
        a >>= 1
        b >>= 1
      }
      fract(a, b)
    }
}

//class BigFraction(val a:BigInt, val b:BigInt) {
//
//}
//
//object BigFraction {
//  def sum(x: BigFraction, y: Fraction): BigFraction = {
//
//  }
//}

class Auction(n: Int, r: Array[(Int, Int)]) {
  @inline def low(i: Int): Int = r(i)._1
  @inline def hi(i: Int): Int = r(i)._2
  @inline def length(i: Int): Int = r(i)._2 - r(i)._1 + 1

  def pFirst(firstFrom: Int, excluded: Int): Fraction = {
    @inline def from(i: Int) = if (i < excluded) firstFrom + 1 else firstFrom
    @inline def till(i: Int) = if (i < excluded) firstFrom else firstFrom - 1
    val fs = (0 until n).filter(i => i != excluded && from(i) <= hi(i))
    if (fs.isEmpty) ZERO
    else
      fs.map(f =>
        (0 until n).filter(i => i != excluded && i != f).
          map(i => if (hi(i) <= till(i)) ONE
                   else if (till(i) < low(i)) ZERO
                   else fract(till(i) - low(i) + 1, length(i))).
          foldLeft(fract(hi(f) - math.max(from(f), low(f)) + 1, length(f)))(mul)
      ).reduce(sum)
  }

  def expectationOfSecond(): Fraction = {
    val secondFrom = (0 until n).map(low).sortWith(_ > _)(1)
    val secondTo = (0 until n).map(hi).sortWith(_ > _)(1)
    val summands =
      for {
        second <- secondFrom to secondTo
        i <- 0 until n if low(i) <= second && second <= hi(i)
      } yield fract(second, length(i)) * pFirst(second, i)
    val optimized = summands.groupBy(_.b).mapValues(_.map(_.a).sum).map(p => fract(p._2, p._1))
    optimized.reduce(sum)
  }

}


object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val d = (1 to 8).map(_ => in.next())
  if (d.forall(t => t == "WBWBWBWB" || t == "BWBWBWBW"))
    println("YES")
  else
    println("NO")
}

object Main{

    def different(a: String, b: String, pos: Int = 0): Boolean = {
        if (pos >= a.length) true else{
            if (a(pos) == b(pos)) false else different(a, b, pos+1)
        }
    }                                         //> different: (a: String, b: String, pos: Int)Boolean

    def validPair(a: String, b: String, remainTry: Int = 0): Boolean = {
        if (remainTry == a.length) false else{
            if (different(a, b)) true else{
                val nextA = a.substring(1) + a(0)
                validPair(nextA, b, remainTry+1)
            }
        }
    }                                         //> validPair: (a: String, b: String, remainTry: Int)Boolean

    def alterChar(s: String, pos: Int = 1): Boolean = {
        if (pos == s.length) true else{
            if (s(pos) == s(pos-1)) false else alterChar(s, pos+1)
        }
    }                                         //> alterChar: (s: String, pos: Int)Boolean

    def validRow(s: String, remainTry: Int = 0): Boolean = {
        if (remainTry == s.length) false else{
            if (alterChar(s)) true else{
                val nextS = s.substring(1) + s(0)
                validRow(nextS, remainTry + 1)
            }
        }
    }                                         //> validRow: (s: String, remainTry: Int)Boolean

    def validBoard(board: Array[String])={
        var ret = true
        if (!validRow(board(0))) ret = false
        for (i <- 1 until board.length){
            if (!validPair(board(i-1), board(i))) ret = false
        }
        ret
    }                                         //> validBoard: (board: Array[String])Boolean

    def main(args: Array[String]) = {
        val board = new Array[String](8)
        for (i <- 0 until 8){
            board(i) = readLine()
        }
        if (validBoard(board)) println("YES") else println("NO")

    }                                         //> main: (args: Array[String])Unit
}

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

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

  val B = List.fill(8)(sc.nextLine)

  def solve(): String = if (B forall (s => s == "WBWBWBWB" || s == "BWBWBWBW")) "YES"
                        else "NO"

  out.println(solve)
  out.close
}

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

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

  val bw = "(BW)*"
  val wb = "(WB)*"
  val ans = (for(_ <- 1 to 8) yield reader.readLine()).forall(s => s.matches(bw) || s.matches(wb))
  val yesNoAns = Map(true -> "YES", false -> "NO")

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

object Main {
  def correct(row: String): Boolean = {
    val sum = row.zipWithIndex.map{ t =>
      if (t._1 == 'W') 1 << t._2
      else 0
    }.sum
    if (sum == 0x55 || sum == 0xAA) true
    else false
  }

  def main(args: Array[String]) {
    val cor = (1 to 8).map(_ => readLine()).map(correct(_)).foldLeft(true)(_ & _)
    if (cor) println("YES")
    else println("NO")
  }
}

object B{
  def main(args: Array[String]){

    val s1="WBWBWBWB"
    val s2="BWBWBWBW"
    (1 to 8).foreach{i=>
      val str=readLine
      if(str!=s1 && str!=s2){
        println("NO")
        return
      }
    }
    println("YES")
  }
}

object Ches {
     def main(args:Array[String]):Unit={
       var list=List[String]()
       for(i<-0 until 8){
          list=list:+readLine()
       }
       if(solve(list)) println("YES")
       else println("NO")
     }
  def solve(list:List[String]):Boolean={
    def isNormal(str:String):Boolean={
      def strIter(str:String, c:Char):Boolean={
        if(str.length==0) true
        else if(c==str.head) false
        else strIter(str.tail, str.head)
      }
      strIter(str, str.last)
    }
    if(list.length==0) true
    else if(!isNormal(list.head)) false
    else solve(list.tail)
  }
}

object Main{

    def different(a: String, b: String, pos: Int = 0): Boolean = {
        if (pos >= a.length) true else{
            if (a(pos) == b(pos)) false else different(a, b, pos+1)
        }
    }                                         //> different: (a: String, b: String, pos: Int)Boolean

    def validPair(a: String, b: String, remainTry: Int = 0): Boolean = {
        if (remainTry == a.length) false else{
            if (different(a, b)) true else{
                val nextA = a.substring(1) + a(0)
                validPair(nextA, b, remainTry+1)
            }
        }
    }                                         //> validPair: (a: String, b: String, remainTry: Int)Boolean

    def validBoard(board: Array[String])={
        var ret = true
        for (i <- 1 until board.length){
            if (!validPair(board(i-1), board(i))) ret = false
        }
        ret
    }                                         //> validBoard: (board: Array[String])Boolean

    def main(args: Array[String]) = {
        val board = new Array[String](8)
        for (i <- 0 until 8){
            board(i) = readLine()
        }
        if (validBoard(board)) println("YES") else println("NO")

    }                                         //> main: (args: Array[String])Unit
}


object Main {

  import java.io.{PrintWriter, _}
  import java.util._

  def main(args: Array[String]): Unit = {
    val inputStream = System.in
    val outputStream = System.out
    val in = new InputReader(inputStream)
    val out = new PrintWriter(outputStream)
    val solver = new Task
    solver.solve(1, in, out)
    out.close()
  }

  def ?(item: Boolean, first: Any, second: Any): Any = if (item) first else second

  class Task {
    def solve(testNumber: Int, in: InputReader, out: PrintWriter): Unit = {
      var arr = new Array[Int](3)
      arr(0) = in.nextInt
      arr(1) = in.nextInt
      arr(2) = in.nextInt
      arr = arr.sorted
      val d = in.nextInt
      val a = math.max(arr(1) + d - arr(2), 0)
      val b = math.min(arr(1) - d - arr(0), 0)
      out.println(a - b)
    }

  }

  class InputReader(val stream: InputStream) extends AutoCloseable {
    //reader = new BufferedReader(new FileReader(stream), 32768);
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer = new StringTokenizer("")

    def next: String = {
      while ( {
        tokenizer == null || !tokenizer.hasMoreTokens
      }) try
        tokenizer = new StringTokenizer(reader.readLine)
      catch {
        case e: IOException =>
          throw new RuntimeException(e)
      }
      tokenizer.nextToken
    }

    def nextLine: String = {
      try
        return reader.readLine
      catch {
        case e: IOException =>
          e.printStackTrace()
      }
      ""
    }

    def nextInt: Int = next.toInt

    def nextLong: Long = next.toLong

    override def close(): Unit = {
    }
  }

}

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

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

  private val oj = System.getenv("ATCODER_DEBUG") == null
  def DEBUG(f: => Unit): Unit = {
    if (!oj){ f }
  }
  def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) "1" else "0").mkString) }
  def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(" ")) }
  def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(" ")) }
  def debugDim(m: Array[Array[Int]]): Unit = if (!oj){
    REP(m.length) { i =>
      debug(m(i))
    }
  }
  def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){
    REP(m(0).length) { j =>
      REP(m.length) { i =>
        System.err.print(m(i)(j))
        System.err.print(" ")
      }
      System.err.println()
    }
  }
  def debug(s: => String): Unit = DEBUG {
    System.err.println(s)
  }
  def debugL(num: => Long): Unit = DEBUG {
    System.err.println(num)
  }

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

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

    def nextInt(): Int = Integer.parseInt(next())
    def nextLong(): Long = java.lang.Long.parseLong(next())
    def nextChar(): Char = next().charAt(0)

    def ni(): Int = nextInt()
    def nl(): Long = nextLong()
    def nc(): Char = nextChar()
    def ns(): String = next()
    def ns(n: Int): Array[Char] = ns().toCharArray
    def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
    def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
      val A1, A2 = Array.ofDim[Int](n)
      REP(n) { i =>
        A1(i) = ni() + offset
        A2(i) = ni() + offset
      }
      (A1, A2)
    }
    def nm(n: Int, m: Int): Array[Array[Int]] = {
      val A = Array.ofDim[Int](n, m)
      REP(n) { i =>
        REP(m) { j =>
          A(i)(j) = ni()
        }
      }
      A
    }
    def nal(n: Int): Array[Long] = map(n)(_ => nl())
    def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  }

  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }
  def TO(from: Int, to: Int)(f: Int => Unit): Unit = {
    REP(to - from + 1, from) { i =>
      f(i)
    }
  }
  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }

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

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

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

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

  def solve(): Unit = {
    val A, B, C, D = ni()
    val V = Array(A, B, C)
    sort(V)
    val ans = max(0, D - (V(1) - V(0))) + max(0, D - (V(2) - V(1)))
    out.println(ans)
  }
}

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

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

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

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

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

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

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

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

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

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

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

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

object Main {

  import java.io.{PrintWriter, _}
  import java.util._

  def main(args: Array[String]): Unit = {
    val inputStream = System.in
    val outputStream = System.out
    val in = new InputReader(inputStream)
    val out = new PrintWriter(outputStream)
    val solver = new Task
    solver.solve(1, in, out)
    out.close()
  }

  def ?(item: Boolean, first: Any, second: Any): Any = if (item) first else second

  class Task {
    def solve(testNumber: Int, in: InputReader, out: PrintWriter): Unit = {
      var arr = new Array[Int](3)
      arr(0) = in.nextInt
      arr(1) = in.nextInt
      arr(2) = in.nextInt
      arr = arr.sorted
      val d = in.nextInt
      val a = math.max(arr(1) + d - arr(2), 0)
      val b = math.max(math.abs(arr(1) - d - arr(0)), 0)
      out.println(a + b)
    }

  }

  class InputReader(val stream: InputStream) extends AutoCloseable {
    //reader = new BufferedReader(new FileReader(stream), 32768);
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer = new StringTokenizer("")

    def next: String = {
      while ( {
        tokenizer == null || !tokenizer.hasMoreTokens
      }) try
        tokenizer = new StringTokenizer(reader.readLine)
      catch {
        case e: IOException =>
          throw new RuntimeException(e)
      }
      tokenizer.nextToken
    }

    def nextLine: String = {
      try
        return reader.readLine
      catch {
        case e: IOException =>
          e.printStackTrace()
      }
      ""
    }

    def nextInt: Int = next.toInt

    def nextLong: Long = next.toLong

    override def close(): Unit = {
    }
  }

}


import scala.io.Source

object Cf177a1 extends App {
  val a = Source.stdin.getLines.drop(1).map(_.split(" ").map(_.toInt)).toArray
  var rez = 0
  val n = a.length
  for (i <- 0 until n) {
    for (j <- 0 until n) {
      if (i == j || i == n - j - 1 || i == n / 2 || j == n / 2) rez = rez + a(i)(j)
    }
  }
  println(rez)
}


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

  override def apply(io: IO): io.type = {
    val votes = io.read[Vector[Int]]
    val majority = 0 +: votes.indicesWhere(v => 2*v <= votes.head)
    val ans = if (2*majority.map(votes).sum > votes.sum) {
      majority
    } else {
      Nil
    }
    io.writeLine(ans.length).writeAll(ans.map(_ +  1))
  }

  implicit class IterableExtensions[A, C[A] <: Seq[A]](s: C[A]) {
    def indicesWhere(f: A => Boolean): Seq[Int] = s.zipWithIndex.collect {case (a, i) if f(a) => i}
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)
  def apply(io: IO): io.type
  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()
}
/***********************************[Scala I/O]*********************************************/
import java.io._, java.util.StringTokenizer
import scala.collection.generic.CanBuild

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

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

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

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

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

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

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

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

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

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

object A extends App {

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

  val Array(n) = readInts(1)
  val as = readInts(n).zipWithIndex
  val a0 = as(0)._1

  val cs = as.filter(_._1 * 2 <= a0)

  val sum = a0 + cs.map(_._1).sum

  if (sum * 2 > as.map(_._1).sum) {
    println(cs.size + 1)
    println((1 +: cs.map(_._2 + 1)).mkString(" "))
  } else {
    println(0)
  }

  Console.flush
}

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

  override def apply(io: IO): io.type = {
    val votes = io.read[Vector[Int]]
    val majority = 0 +: votes.indicesWhere(v => 2*v <= votes.head)
    val ans = if (2*majority.map(votes).sum >= votes.sum) {
      majority
    } else {
      Nil
    }
    io.writeLine(ans.length).writeAll(ans.map(_ +  1))
  }

  implicit class IterableExtensions[A, C[A] <: Seq[A]](s: C[A]) {
    def indicesWhere(f: A => Boolean): Seq[Int] = s.zipWithIndex.collect {case (a, i) if f(a) => i}
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)
  def apply(io: IO): io.type
  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()
}
/***********************************[Scala I/O]*********************************************/
import java.io._, java.util.StringTokenizer
import scala.collection.generic.CanBuild

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

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

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

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

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

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

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

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

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

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


object Main {
  def main(args: Array[String]) {
    val n = readInt()
    println(3 * n / 2)
  }
}

import java.util.Scanner
object GAGA {
    def main(args: Array[String]) {
      val scanner = new Scanner(System.in)
      val n = scanner.nextInt()
      println(n/2*3);
    }
}

import java.util.StringTokenizer

object _84A extends App {
  var token = new StringTokenizer("")
  def next = {
    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)
    token.nextToken()
  }
  val n = next.toInt
  println(n / 2 * 3)
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  println(3 * in.next().toInt / 2)
}

import scala.math
object Main
{
	def main(args:Array[String])
	{
		println(readInt / 2 * 3)
	}
}

object A84 {

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

  def main(args: Array[String]): Unit = {
    val Array(n) = readInts(1)
    println(3*(n/2))
  }

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

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

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

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

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

}

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

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

  val N = sc.nextInt

  val answer = 2 * N - (N / 2)

  out.println(answer)
  out.close
}

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

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

  def ans = readInt / 2 * 3

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