fun main(args: Array<String>)
{ var c: Int=0
	var x= readLine()!!.toInt()
	for(i in 1..x)
		{
			for(j in 1..(i*x))
				{
					if((j*i)>x && (j%i)==0)
						{
							println("$j   $i")
							c++
							break
						}
				}
			if(c==1)break

		}
	if(c==0)println("-1")

}

fun main(args : Array<String>) {

    val n1 = readLine()!!
    var n = n1.toInt()
    var a = 0
    var b = 0
    var c = 0

    if(n==1){
        c = 0
    }
    else{
         for(i in 1..n){
             for(j in 1..n){
                 if(i%j==0 && i/j<n && i*j>n){
                     a = i
                     b = j
                     c++
                     break
                 }
             }
         }

    }

    if(c==0){
       println(-1)
    }
    else{
        print(a)
        print(" ")
        print(b)
    }
}

fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    val n = r.readLine()!!.toInt()
    println(if (n==1) -1 else "$n $n")
}

import java.io.*
val br = BufferedReader(InputStreamReader(System.`in`))
val bw = BufferedWriter(OutputStreamWriter(System.out))
fun println(s: String) { bw.write(s + "\n") }
fun readLine() = br.readLine()!!

fun main(args: Array<String>) {
    solve()
    bw.close()
}

fun solve() {
    val r = readLine().toInt()
    for (a in 1..r) {
        for (b in 1..r) {
            if (a % b == 0 && a * b > r && a.toDouble() / b.toDouble() < r ) {
                println("$a $b")
                return
            }
        }
    }
    println("-1")

}

fun constructIntegers(n:Int):String{
        val a=n
        val b=n
        if(n > 1) {
            return a.toString()+" "+b.toString()
        }
        return "-1"
    }
    fun main(args : Array<String>){
    println(constructIntegers(readLine()!!.toInt()))
}

fun main() {
    val x = readLine()!!.toInt()
    if (x == 1) {
        println(-1)
    } else {
        println("${x - (x and 1)} 2")
    }
}

private fun read(delimit: Char = ' ') = readLine()!!.split(delimit)

fun main(args: Array<String>) {
    val (num) = read().map(String::toInt)

    var found = false

    for (x in 2..num) {
        val a = x
        val b = x/2

        if ((a%b == 0) && ((a/b) < num) && ((a*b) > num)) {
            print("$a $b")
            found = true
            break
        }
    }

    if (!found) {
        for (x in 2..num) {
            val a = x
            val b = x

            if ((a%b == 0) && ((a/b) < num) && ((a*b) > num)) {
                print("$a $b")
                found = true
                break
            }
        }
    }

    if (!found) {
        println(-1)
    }
}

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var a = n
    var b = n
    if (n == 1) {
        println(-1)
    } else {
        println("$a $b")
    }
}

import java.io.*
import kotlin.system.measureTimeMillis

fun solve(input: BufferedReader) {
    val x = input.readLine().toInt()
    for (a in 1..x)
        for (b in 1..x)
            if (a % b == 0 && a / b < x && a * b > x) {
                print("%d %d\n".format(a, b))
                return
            }
    println(-1)
}

fun main(args: Array<String>) {
    System.err.println("time = %dms".format(measureTimeMillis {
        solve(System.`in`.bufferedReader())
//        solve(File("a.out").bufferedReader())
    }))
}

import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    var x = sc.nextInt()
    if(x == 1) println(-1)
    else print("${x} ${x}")
}

fun main() {
    val x = readLine()!!.toInt()
    for (b in 1..x)
        for (a in b..x step b)
            if (a * b > x && a / b < x) return print("$a $b")
    print(-1)
}

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val result = solve(n)
    if (result == null) {
        println(-1)
    } else {
        println("${result.first} ${result.second}")
    }
}

fun solve(x: Int): Pair<Int, Int>? {
    for (b in 1..x) {
        for (a in x downTo 1) {
            if (a % b == 0) {
                if (a * b > x) {
                    if (a.toFloat()/b.toFloat() < x) {
                        return a to b
                    }
                }
            }
        }
    }

    return null
}

import java.util.*

fun main(args: Array<String>) {
    Scanner(System.`in`).forEach {
        val x = it.toInt()
        for (a in 1..100) {
            for (b in 1..100) {
                if (a % b == 0 && b <= x && a * b > x && a / b < x) {
                    println("$a $b")
                    return
                }
            }
        }
        println("-1")
        return
    }

}

fun main()
{ var c: Int=0
	var x= readLine()!!.toInt()
	for(i in 1..x)
		{
			for(j in 1..(i*x))
				{
					if((j*i)>x && (j%i)==0)
						{
							println("$j   $i")
							c++
							break
						}
				}
			if(c==1)break

		}
	if(c==0)println("-1")

}

import java.io.*
import java.util.*

class A {
    fun solve(x : Int) : Pair<Int, Int> {
        if (x == 1) {
            return Pair(-1, -1)
        }
        if (x % 2 == 0) {
            return Pair(x, 2)
        } else {
            return Pair(x - 1, 2)
        }
    }

    fun solve(input : InputStream, output : OutputStream) {
        val reader = InputReader(BufferedInputStream(input))
        val writer = PrintWriter(BufferedOutputStream(output))

        val x = reader.nextInt()
        val (a, b) = solve(x)
        if (a == -1) {
            writer.println("-1")
        } else {
            writer.println("$a $b")
        }

        writer.close()
    }

    private class InputReader(stream: InputStream) {
        var reader: BufferedReader = BufferedReader(InputStreamReader(stream), 32768)
        var tokenizer: StringTokenizer? = null

        operator fun next(): String {
            while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
                try {
                    tokenizer = StringTokenizer(reader.readLine())
                } catch (e: IOException) {
                    throw RuntimeException(e)
                }

            }
            return tokenizer!!.nextToken()
        }

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

        fun nextLong(): Long {
            return java.lang.Long.parseLong(next())
        }
    }
}

fun main(args : Array<String>) {
    A().solve(System.`in`, System.out)
}

fun constructIntegers(n:Int):String{
    var a = 0
    var b = 0
        if(n > 3) {
            for(i in n downTo 2){
                a = i
                for(j in a-1 downTo 2) {
                    b = j
                    if (a%b == 0 && a*b > n && a/b < n){
                        return a.toString()+" "+b.toString()
                    }
                }
            }
        }
        return "-1"
    }

    fun main(args: Array<String>){
    println(constructIntegers(readLine()!!.toInt()))
}

fun main() {
    val x = readLine()!!.toInt()
    if (x == 1) {
        println(-1)
    } else {
        println("${x + (x and 1)} 2")
    }
}

private fun read(delimit: Char = ' ') = readLine()!!.split(delimit)

fun main(args: Array<String>) {
    val (num) = read().map(String::toInt)

    var found = false

    for (x in 1..num) {
        if (x * 2 <= num) {
            print("$x ${x * 2}")
            found = true
            break
        }
    }

    if (!found) {
        println(-1)
    }
}

private fun read(delimit: Char = ' ') = readLine()!!.split(delimit)

fun main(args: Array<String>) {
    val (num) = read().map(String::toInt)

    var found = false

    for (x in 2..num) {

        if ((x%2 == 0) && (x/2 < num) && (x*2 > num)) {
            print("$x ${x / 2}")
            found = true
            break
        }
    }

    if (!found) {
        println(-1)
    }
}

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var a = n/2
    var b = n/2
    while (!c(a,b,n)) {
        if (a <1 || a > n || b < 1 || b > n) {
            println(-1)
            return
        }
        a++
        b--
    }
    print("$a $b")
}

fun c(a: Int, b: Int, n: Int) = a*b > n && a/b < n && a%b == 0

fun main()
{ var c: Int=0
	var x= readLine()!!.toInt()
	for(i in 1..x-1)
		{
			for(j in 1..(i*x)-1)
				{
					if((j*i)>x && (j%i)==0)
						{
							println("$j   $i")
							c++
							break
						}
				}
			if(c==1)break

		}
	if(c==0)println("-1")

}


fun main() {
    fun readInts() = readLine()!!.split(" ").map(String::toInt)

    val (_, desksPerLane, santaPlace) = readInts()
    val lane = santaPlace / (2 * desksPerLane) + if (santaPlace % (2 * desksPerLane) == 0) 0 else 1
    val deskInLane = santaPlace - (lane - 1) * 2 * desksPerLane
    val numRow = (deskInLane + 1) / 2
    print("$lane $numRow ${if (santaPlace % 2 == 0) 'R' else 'L'}")
}

fun main(args: Array<String>) {
    val (n, m, k) = readLine()!!.split(" ").map(String::toInt)
    val lane = ((k-1) / (2 * m)) + 1
    val desk = (((k-1)/2) % m) + 1
    val side = if(k%2 == 1) "L" else "R"
    println("$lane $desk $side")
}

fun findRow(k: Int, m: Int) = if ((k / 2) % m == 0) (k / 2) / m else (k / 2) / m + 1

fun findDesk(k: Int, m: Int) = if ((k / 2) % m == 0) m else (k / 2) % m

fun main(args: Array<String>) {
    val (n, m, k) = readLine()!!.split(" ").map(String::toInt)
    var side = 'R'
    var row: Int
    var desk: Int
    if (k % 2 == 0) {
        row = findRow(k, m)
        desk = findDesk(k, m)
    } else {
        row = findRow(k+1, m)
        desk = findDesk(k+1, m)
        side = 'L'
    }
    println("$row $desk $side")
}


import kotlin.math.*

private const val MOD = 998244353

fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val c = Array(n + 1) { IntArray(n + 1) }
    val d = Array(n + 1) { IntArray(n + 1) }
    c[0][0] = 1
    d[0][0] = 1
    for (x in 1..n) {
        for (m in 1..x) {
            c[x][m] = d[x - m][min(m, x - m)]
            for (l in 1 until m) {
                c[x][m] = add(c[x][m], c[x - l][m])
            }
            d[x][m] = add(c[x][m], d[x][m - 1])
        }
    }
    var sum = 0
    wl@ for (w in 1..n) {
        for (h in 1..n) {
            if (w * h >= k) continue@wl
            sum = add(sum, mul(c[n][w], c[n][h]))
        }
    }
    sum = mul(sum, 2)
    println(sum)
}

private fun add(a: Int, b: Int): Int = ((a.toLong() + b) % MOD).toInt()
private fun mul(a: Int, b: Int): Int = ((a.toLong() * b) % MOD).toInt()

import java.util.*

val MOD = 998244353L

fun main() {
    val jin = Scanner(System.`in`)
    val n = jin.nextInt()
    val k = jin.nextInt()
    val amts = LongArray(n + 1) {
        if (it == 0) {
            0L
        } else {
            val dp = LongArray(n + 1)
            dp[0] = 1L
            var sum = 1L
            for (j in 1..n) {
                dp[j] = sum
                sum += dp[j]
                if (j >= it) {
                    sum -= dp[j - it]
                }
                sum %= MOD
            }
            dp[n]
        }
    }
    for (j in n downTo 1) {
        amts[j] -= amts[j - 1]
    }
    var answer = 0L
    for (a in 1..n) {
        for (b in 1..n) {
            if (a * b < k) {
                answer += amts[a] * amts[b]
                answer %= MOD
            }
        }
    }
    answer *= 2
    println(((answer % MOD) + MOD) % MOD)
}


fun main(args: Array<String>) = println(arrayOf(readLine()!!, readLine()!!, readLine()!!).map(String::toInt).let { (a, b, c) -> arrayOf(a + b + c, a * b * c, a + b * c, a * b + c, (a + b) * c, a * (b + c)).max() })

fun main() {
    val a = readLine()!!.toInt()
    val b = readLine()!!.toInt()
    val c = readLine()!!.toInt()

    println(arrayOf(
        a + b + c,
        a + b * c,
        a * b * c,
        a * b + c,
        a * (b + c),
        (a + b) * c
    ).max())
}

import java.util.*

fun main (args:Array<String>)
{
    var a:Int= readLine()!!.toInt()
    var b: Int= readLine()!!.toInt()
    var c:Int= readLine()!!.toInt()
    var Max:Int=0
    if(a+b*c>Max)
        Max=a+b*c
     if(a*(b+c)>Max)
        Max=a*(b+c)
     if((a*b*c)>Max)
        Max=(a*b*c)
     if((a+b)*c>Max)
        Max=(a+b)*c
    if(a+b+c>Max)
    Max=a+b+c
System.out.println(Max)
}

import java.io.BufferedReader
import java.io.InputStreamReader

val alg1 = { i1: Int, i2: Int, i3: Int -> i1 + i2 * i3 }
val alg2 = { i1: Int, i2: Int, i3: Int -> i1 * (i2 + i3) }
val alg3 = { i1: Int, i2: Int, i3: Int -> i1 * i2 * i3 }
val alg4 = { i1: Int, i2: Int, i3: Int -> (i1 + i2) * i3 }
val alg5 = { i1: Int, i2: Int, i3: Int -> i1 + i2 + i3 }
val alg6 = { i1: Int, i2: Int, i3: Int -> i1 * i2 + i3 }

fun main(args: Array<String>) {
    val reader = BufferedReader(InputStreamReader(System.`in`))
    val arg1 = reader.readLine().toInt()
    val arg2 = reader.readLine().toInt()
    val arg3 = reader.readLine().toInt()
    val answers = listOf(alg1(arg1, arg2, arg3),
            alg2(arg1, arg2, arg3),
            alg3(arg1, arg2, arg3),
            alg4(arg1, arg2, arg3),
            alg5(arg1, arg2, arg3),
            alg6(arg1, arg2, arg3))
    println(answers.max())
}

fun main(args: Array<String>) {
    val (a,b,c) = Array(3, { readLine()!!.toInt()})
    println(arrayOf(a*b*c,(a+b)*c,a*(b+c),a+b+c).max())
}

fun main(args: Array<String>) {
    val a = readLine()!!.toInt()
    val b = readLine()!!.toInt()
    val c = readLine()!!.toInt()

    fun addOrMultiply(x: Int, y: Int): Int {
        if (x == 1 || y == 1) {
            return x + y
        }
        else {
            return x * y
        }
    }

    val larger = maxOf(a, c)
    val smaller = minOf(a, c)
    println(addOrMultiply(addOrMultiply(smaller, b), larger))
}

import kotlin.math.max

fun main(args : Array<String>){

    var X = readLine()!!.toInt()
    var Y = readLine()!!.toInt()
    var Z = readLine()!!.toInt()

    println(MAX(X+Y+Z,X*Y*Z,(X+Y)*Z,X*(Y+Z)))

                              }

fun MAX(V:Int,X:Int,Y:Int,Z:Int) : Int {
        if (V > X && V > Y && V > Z)
            return V

        else if (X > V && X > Y && X > Z)
            return X

        else if (Y > V && Y > X && Y > Z)
            return Y

        else
            return Z
                                       }

fun main(args: Array<String>) {
	val a = readLine()!!.toInt()
	val b = readLine()!!.toInt()
	val c = readLine()!!.toInt()
	findMaxVal(a, b, c)
}

fun findMaxVal(a: Int, b: Int, c: Int){
	val maxOfSumAllAndProductAll = Integer.max(a*b*c, a + b + c)
	val maxOfPartialSumAll = Integer.max(partialSum(a, b, c), partialSum(c, b, a))
	val maxOfPartialSumBracesAll = Integer.max(partialSumBraces(a, b, c), partialSumBraces(c, b, a))
	println(Integer.max(Integer.max(maxOfSumAllAndProductAll, maxOfPartialSumAll),maxOfPartialSumBracesAll))
}
fun partialSum(a: Int, b: Int, c: Int): Int {
	return a+b*c
}
fun partialSumBraces(a: Int, b: Int, c: Int) = (a+b)*c

import kotlin.math.max
import kotlin.math.min

/**
 * Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last
 * class the teacher wrote three positive integers a, b, c on the blackboard. The task was to insert signs of
 * operations '+' and '*', and probably brackets between the numbers so that the value of the resulting expression is
 * as large as possible. Let's consider an example: assume that the teacher wrote numbers 1, 2 and 3 on the blackboard.
 * Here are some ways of placing signs and brackets:
 * 1+2*3=7
 * 1*(2+3)=5
 * 1*2*3=6
 * (1+2)*3=9
 * Note that you can insert operation signs only between a and b, and between b and c, that is, you cannot swap integers.
 * For instance, in the given sample you cannot get expression (1+3)*2.
 * It's easy to see that the maximum value that you can obtain is 9.
 * Your task is: given a, b and c print the maximum value that you can get.
 *
 * Input
 * The input contains three integers a, b and c, each on a single line (1 ≤ a, b, c ≤ 10).
 *
 * Output
 * Print the maximum value of the expression that you can obtain.
 */
fun readInt(): Int = readLine()!!.toInt()

fun readInputs():MutableList<Int> {
    val inputList:MutableList<Int> = mutableListOf()
    for (i in 0..2){
        inputList += listOf(readInt())
    }
    return inputList
}

fun maxExp(list: MutableList<Int>): Int {
    val expr1 = list[0] + list[1] + list[2]
    val expr2 = list[0] * list[1] * list[2]
    val expr3 = list[0] + list[1] * list[2]
    val expr4 = list[0] * list[1] + list[2]
    val expr5 = list[0] * (list[1] + list[2])
    val expr6 = (list[0] + list[1]) * list[2]
    return max(max(max(max(max(expr1, expr2), expr3), expr4), expr5), expr6)
}
/*
fun sum0and1(list: MutableList<Int>):List<Int>{
    if (list.contains(0)) {
        list.remove(0)
    }
    var counter = 0
    for (i in 0..2){
        if (list[i] == 1) counter++
    }
    return if(counter != 3) {
        if (list.contains(1)) {
            val index = list.indexOf(1)
            list.remove(1)
            if(index!=0 && index!=2) {
                val minValue = min(list[index], list[index - 1])
                if (minValue == list[index]) list[index]++ else list[index - 1]++
            }
            else if(index == 0){
                list[index]++
            }
            else{
                list[index-1]++
            }
        }
        list.toList()
    }
    else {
        listOf(list.reduce { acc: Int, i: Int -> acc + i }.toInt())
    }
}

fun maxResult(list: List<Int>): Int = list.reduce { acc, i -> acc * i }
*/

fun main(){
    val inputValues = readInputs().toMutableList()
    /*
    val filteredList = sum0and1(inputValues)
    val result = maxResult(filteredList)
    */
    println(maxExp(inputValues))
}

import java.io.*
import java.util.*

class ProblemIO(val rd: BufferedReader, val wr: PrintWriter) {
    var tok = StringTokenizer("")

    companion object {
        fun console() = ProblemIO(BufferedReader(InputStreamReader(System.`in`)), PrintWriter(System.out))
        fun files(inputFilename: String, outputFilename: String) = ProblemIO(BufferedReader(FileReader(File(inputFilename))), PrintWriter(File(outputFilename)))
    }

    fun readToken(): String {
        while (!tok.hasMoreTokens()) {
            tok = StringTokenizer(rd.readLine())
        }
        return tok.nextToken()
    }

    fun readInt(): Int = readToken().toInt()
    fun <T> print(v: T) = wr.print(v)
    fun <T> println(v: T) = wr.println(v)
    fun close() {
        rd.close()
        wr.close()
    }
}

fun solve() {
    val io = ProblemIO.console()
    val a = io.readInt()
    val b = io.readInt()
    val c = io.readInt()
    val v = intArrayOf(a * b * c, (a + b) * c, a * (b + c), a + b * c, a * b + c, a + b + c)
    io.println(v.max())
    io.close()
}

fun main(args: Array<String>) {
    Thread({ solve() }).start()
}

fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    val a = r.readLine()!!.toInt()
    val b = r.readLine()!!.toInt()
    val c = r.readLine()!!.toInt()
    val max1 = maxOf(a+b*c, (a+b)*c, a*b+c)
    val max2 = maxOf(a*(b+c), a*b*c, a+b+c)
    println(maxOf(max1, max2))
}

import java.util.*
import java.math.*
import kotlin.math.*

fun readLn()=readLine()!!
fun readInt()=readLn().toInt()
fun readInts()=readLn().split(" ").map{it.toInt()}
fun readLong()=readLn().toLong()
fun readLongs()=readLn().split(" ").map{it.toLong()}

val out=mutableListOf<String>()
fun printLine(s:String){out.add(s)}
fun output(){println(out.joinToString("\n"))}

fun main(){
    var a=readInt()
    var b=readInt()
    var c=readInt()
    var ans=a+b+c
    ans=max(ans,a+b*c)
    ans=max(ans,a*b+c)
    ans=max(ans,a*b*c)
    ans=max(ans,(a+b)*c)
    ans=max(ans,a*(b+c))
    printLine("$ans")
    output()
}

import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val list = arrayListOf<Int>()
    // Manually declare all possible expression results
    list.add(a+b+c)
    list.add(a*b*c)
    list.add(a+b*c)
    list.add(a*b+c)
    list.add((a+b)*c)
    list.add(a*(b+c))
    // Print maximum
    println(list.max())
}

import java.util.*

fun main(args: Array<String>) {

    val scanner = Scanner(System.`in`)

    val a = scanner.nextLong()
    val b = scanner.nextLong()
    val c = scanner.nextLong()

    var res : Long = a + b + c

    res = Math.max(res, (a+b)*c)
    res = Math.max(res, a*(b+c))
    res = Math.max(res, a*b*c)
    res = Math.max(res, a+b*c)
    res = Math.max(res, a*b+c)

    System.out.print(res)

}

import java.io.*
import java.util.*

fun main(args: Array<String>) {
    val inputStream = System.`in`
    val outputStream = System.out
    val input = InputReader(inputStream)
    val output = PrintWriter(outputStream)
    val solver = Task()
    solver.solve(input, output)
    output.close()
}

private class Task {
    fun solve(input: InputReader, output: PrintWriter) {
        val a = input.nextInt()
        val b = input.nextInt()
        val c = input.nextInt()

        output.print(listOf(
                a * b * c,
                a + b * c,
                a * b + c,
                a + b + c,
                (a + b) * c,
                a * (b + c)).max()
        )

    }
}

private class InputReader(stream: InputStream) {
    private var reader: BufferedReader = BufferedReader(InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer? = null

    operator fun next(): String {
        while (tokenizer == null || tokenizer?.hasMoreTokens()?.not() == true) {
            try {
                tokenizer = StringTokenizer(reader.readLine())
            } catch (e: IOException) {
                throw RuntimeException(e)
            }

        }
        return tokenizer!!.nextToken()
    }

    fun nextInt(): Int {
        return next().toInt()
    }

}

import java.io.*
import java.util.*

fun main(args: Array<String>) {
    val inputStream = System.`in`
    val outputStream = System.out
    val input = InputReader(inputStream)
    val output = PrintWriter(outputStream)
    val solver = Task()
    solver.solve(input, output)
    output.close()
}

private class Task {
    fun solve(input: InputReader, output: PrintWriter) {
        val a = input.nextInt()
        val b = input.nextInt()
        val c = input.nextInt()

        output.print(listOf(a * b * c, a + b + c, a + b * c, a * b + c, (a + b) * c, a * (b + c)).max())
    }
}

private class InputReader(stream: InputStream) {
    private var reader: BufferedReader = BufferedReader(InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer? = null

    operator fun next(): String {
        while (tokenizer == null || tokenizer?.hasMoreTokens()?.not() == true) {
            try {
                tokenizer = StringTokenizer(reader.readLine())
            } catch (e: IOException) {
                throw RuntimeException(e)
            }

        }
        return tokenizer!!.nextToken()
    }

    fun nextInt(): Int {
        return next().toInt()
    }

}

import java.io.PrintWriter
import kotlin.math.*

fun main() {
    io.apply {

        val a = int
        val b = int
        val c = int
        cout .. arrayOf(a + b + c, a * b + c, a * (b + c), (a + b) * c, a + b * c, a * b * c).max()!! .. nl

    }.cout.flush()
}

// @formatter:off
private val io = object {
    private val `in` = System.`in`
    private fun ll(): Long {
        var x: Int; var q = false; var n = 0L; do x = `in`.read() while (x < 33); if (x == 45) { q = true; x = `in`.read() }
        do { n = n * 10 - x + 48; x = `in`.read() } while (x > 32); return if (q) n else -n
    }
    val int get() = ll().toInt(); val long get() = ll()
    fun ints(n: Int = int): IntArray { return IntArray(n) { int } }
    fun ints1(n: Int = int): IntArray { return IntArray(n) { int - 1 } }
    val cout = PrintWriter(System.out); val nl = "\n"
    operator fun PrintWriter.rangeTo(a: Int): PrintWriter { print(a); print(" "); return this }
    operator fun PrintWriter.rangeTo(a: Long): PrintWriter { print(a); print(" "); return this }
    operator fun PrintWriter.rangeTo(a: IntArray): PrintWriter { a.forEach { print(it); print(" ") }; return this }
    operator fun PrintWriter.rangeTo(a: String): PrintWriter { write(a); return this }
} // @formatter:on

/* ----------- */

fun main() {
    var func :(Int , Int , Int) -> Unit = {n1,n2,n3 ->
        var arr = arrayOf(0,0,0,0)
        arr[0] = n1 + n2 + n3
        arr[1] = (n1 + n2) * n3
        arr[2] = n1 * (n2 + n3)
        arr[3] = n1 * n2 * n3
        println(arr.max())
    }
    func(readLine()!!.toInt() , readLine()!!.toInt() , readLine()!!.toInt())

}

import java.lang.Integer.max

fun main(args: Array<String>) {
    var first = readLine()!!.toInt()
    var second = readLine()!!.toInt()
    var third = readLine()!!.toInt()

    println(
            arrayOf(
                    first * second * third,
                    (first + second) * third,
                    first * (second + third),
                    first + second + third,
                    first + second * third,
                    first * second + third
            ).max()
    )
}

fun main() {
    val a = readLine()!!.toInt()
    val b = readLine()!!.toInt()
    val c = readLine()!!.toInt()

    println(listOf(a*b*c, a*b+c, a*(b+c), a+b*c, (a+b)*c, a+b+c).max())
}

import java.util.*

/**
 * Created by v.shipugin on 30/08/2018
 */

fun main(args: Array<String>) {
    Cont274().first()
}

class Cont274 {

    fun first() {
        val scanner = Scanner(System.`in`)

        val a = scanner.nextInt()
        val b = scanner.nextInt()
        val c = scanner.nextInt()

        val fist = a + b + c
        val second = (a + b) * c
        val third = a * (b + c)
        val foufh = a * b * c

        println(
                Math.max(
                        Math.max(fist, second),
                        Math.max(third, foufh)
                )
        )
    }
}

fun main(args : Array<String>) {
    var arr = IntArray(3)
    for (i in 0..2)
        arr[i] = readLine()!!.toInt()
    var ans1 = 0
    var ans2 = 0
    var max = arr[0] * arr[1]

    if (arr[0] + arr[1] > max)
        max = arr[0] + arr[1]

    if (max * arr[2] > max + arr[2])
        ans1 = max * arr[2]
    else
        ans1 = max * arr[2]

    max = arr[1] * arr[2]
    if (arr[1] + arr[2] > max)
        max = arr[1] + arr[2]
    if (max * arr[0] > max + arr[0])
        ans2 = max * arr[0]
    else
        ans2 = max + arr[0]

    if (ans1 > ans2)
        println(ans1)
    else
        println(ans2)
}

import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val a = scanner.nextInt()
    val b = scanner.nextInt()
    val c = scanner.nextInt()

    val case1 = (a + b) * c
    val case6 = a * b + c

    val case2 = a + b + c
    val case3 = a * b * c

    val case4 = a * b + c
    val case5 = a * (b + c)

    val result = arrayOf(case1, case2, case3, case4, case5, case6)

    println(result.max())
}

import java.io.BufferedReader
import java.io.InputStreamReader

fun main() {
    val br = BufferedReader(InputStreamReader(System.`in`))
    val nums = Array(3){0}
    for (i in 0 until 3){
        nums[i] = br.readLine().toInt()
    }
    val a = nums[0]
    val b = nums[1]
    val c = nums[2]
    val options = listOf(
        a + b + c,
        a * b * c,
        (a + b)*c,
        a*(b + c),
        a*b + c,
        a + b*c
    )
    println(options.max())
}

//package problem479A

fun main() {
    val numbers = listOf(readLine()!!, readLine()!!, readLine()!!).map { it.toInt() }

    val possibilities = mutableListOf(numbers.reduce { acc, i -> acc * i }, numbers.sum())
    possibilities.add(numbers[0] + numbers[1] * numbers[2])
    possibilities.add((numbers[0] + numbers[1]) * numbers[2])
    possibilities.add(numbers[0] * numbers[1] + numbers[2])
    possibilities.add(numbers[0] * (numbers[1] + numbers[2]))

    println(possibilities.max())
}

fun main(){
    val list=ArrayList<Int>()
    for(i in 0..2){
        list.add(readLine()!!.toInt())
    }
    val list2=ArrayList<Int>()
    list2.add((list[0]+list[1])*list[2])
    list2.add(list[0]+(list[1]*list[2]))
    list2.add(list[0]*list[1]*list[2])
    list2.add((list[0]*list[1])+list[2])
    list2.add(list[0]*(list[1]+list[2]))
    list2.add(list[0]+list[1]+list[2])
    print(list2.max())
}

import com.sun.xml.internal.fastinfoset.util.StringArray
import java.awt.List
import java.util.*
import kotlin.collections.ArrayList
import kotlin.math.min

fun main() {
    var sc = Scanner(System.`in`)
    var a = sc.nextInt()
    var b = sc.nextInt()
    var c = sc.nextInt()

    var max = 0
    if (a * b * c > max) max = a * b * c
    if ((a + b) * c > max) max = (a + b) * c
    if (a * (b + c) > max) max = a * (b + c)
    if (a * b + c > max) max = a * b + c
    if (a + b + c > max) max = a + b + c

    println(max)
}

fun main(args: Array<String>) {
    val (a, b, c) = (1..3).map { readLine()!!.toInt() }

    val m = arrayOf(a * b + c, a * (b + c), a + b * c, (a + b) * c, a + b + c, a * b * c).max()!!

    println(m)
}

import java.lang.Math.*

fun main(){

    val a = readLine()?.toInt() ?: 1
    val b = readLine()?.toInt() ?: 1
    val c = readLine()?.toInt() ?: 1

    var answer = a + b + c
    answer = max(answer, a.plus(b).times(c))
    answer = max(answer, a.times(b.plus(c)))
    answer = max(answer, a.times(b).times(c))

    println(answer)
}

fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    val a = r.readLine()!!.toInt()
    val b = r.readLine()!!.toInt()
    val c = r.readLine()!!.toInt()
    val max1 = maxOf(a+b*c, (a+b)*c)
    val max2 = maxOf(a*(b+c), a*b*c)
    println(maxOf(max1, max2))
}

fun main(args : Array<String>) {
    var arr = IntArray(3)
    for (i in 0..2)
        arr[i] = readLine()!!.toInt()
    arr.sort()
    var max = arr[0] * arr[1]
    if (arr[0] + arr[1] > max)
        max = arr[0] + arr[1]
    if (max * arr[2] > max + arr[2])
        println(max * arr[2])
    else
        println(max + arr[2] )
}

fun main(args : Array<String>) {
    var arr = IntArray(3)
    for (i in 0..2)
        arr[i] = readLine()!!.toInt()
    var max = arr[0] * arr[1]
    if (arr[0] + arr[1] > max)
        max = arr[0] + arr[1]
    if (max * arr[2] > max + arr[2])
        println(max * arr[2])
    else
        println(max + arr[2] )
}

import java.io.BufferedReader
import java.io.InputStreamReader

fun main() {
    val br = BufferedReader(InputStreamReader(System.`in`))
    val abc = Array(3){0}
    for (i in 0 until 3){
        abc[i] = br.readLine().toInt()
    }
    val nums = abc.sorted()
    println(
        if (nums[0] == 1){
            (nums[0] + nums[1]) * nums[2]
        } else if (nums.fold(true){acc, x -> x == 1 && acc}){
            nums[0] + nums[1] + nums[2]
        } else{
            nums[0] * nums[1] * nums[2]
        }
    )
}

import java.io.BufferedReader
import java.io.InputStreamReader

fun main() {
    val br = BufferedReader(InputStreamReader(System.`in`))
    val abc = Array(3){0}
    for (i in 0 until 3){
        abc[i] = br.readLine().toInt()
    }
    val nums = abc.sorted()
    println(
        if (nums.fold(true){acc, x -> x == 1 && acc}){
            (nums[0] + nums[1]) * nums[2]
        } else if (nums[0] == 1){
            nums[0] + nums[1] + nums[2]
        } else{
            nums[0] * nums[1] * nums[2]
        }
    )
}

import java.io.BufferedReader
import java.io.InputStreamReader

fun main() {
    val br = BufferedReader(InputStreamReader(System.`in`))
    val nums = Array(3){0}
    for (i in 0 until 3){
        nums[i] = br.readLine().toInt()
    }
    println(
        if (nums.fold(true){acc, x -> x == 1 && acc}){
            nums[0] + nums[1] + nums[2]
        } else if (nums[0] == 1){
            (nums[0] + nums[1]) * nums[2]
        } else{
            nums[0] * nums[1] * nums[2]
        }
    )
}

import java.io.BufferedReader
import java.io.InputStreamReader

fun main() {
    val br = BufferedReader(InputStreamReader(System.`in`))
    val abc = Array(3){0}
    for (i in 0 until 3){
        abc[i] = br.readLine().toInt()
    }
    val nums = abc.sorted()
    println(
        if (nums.fold(true){acc, x -> x == 1 && acc}){
            nums[0] + nums[1] + nums[2]
        } else if (nums[0] == 1){
            (nums[0] + nums[1]) * nums[2]
        } else{
            nums[0] * nums[1] * nums[2]
        }
    )
}

import java.io.BufferedReader
import java.io.InputStreamReader

fun main() {
    val br = BufferedReader(InputStreamReader(System.`in`))
    val abc = Array(3){0}
    for (i in 0 until 3){
        abc[i] = br.readLine().toInt()
    }
    val nums = abc.sorted()
    println(
        if (nums[0] == 1){
            (nums[0] + nums[1]) * nums[2]
        } else{
            nums[0] * nums[1] * nums[2]
        }
    )
}

import java.lang.Math.*

fun main(){

    val a = readLine()?.toInt() ?: 1
    val b = readLine()?.toInt() ?: 1
    val c = readLine()?.toInt() ?: 1

    if (a != 1 && b != 1 && c != 1)
        println(a.times(b).times(c))
    else if(a == 1 && b == 1 && c == 1)
        println(a.plus(b).plus(c))
    else{
        val x = min(a, min(b,c))
        val y = if (a == x) min(b,c) else if (b == x) min(a,c) else min(a, b)
        println(x.plus(y).times(max(a, max(b,c))))

    }
}

import java.util.*

fun main (args:Array<String>)
{
    var a:Int= readLine()!!.toInt()
    var b: Int= readLine()!!.toInt()
    var c:Int= readLine()!!.toInt()
    var Max:Int=0
    if(a+b*c>Max)
        Max=a+b*c
     if(a*(b+c)>Max)
        Max=a*(b+c)
     if((a*b*c)>Max)
        Max=(a*b*c)
     if((a+b)*c>Max)
        Max=(a+b)*c
System.out.println(Max)
}

import java.io.BufferedReader
import java.io.InputStreamReader

val alg1 = { i1: Int, i2: Int, i3: Int -> i1 + i2 * i3 }
val alg2 = { i1: Int, i2: Int, i3: Int -> i1 * (i2 + i3) }
val alg3 = { i1: Int, i2: Int, i3: Int -> i1 * i2 * i3 }
val alg4 = { i1: Int, i2: Int, i3: Int -> (i1 + i2) * i3 }

fun main(args: Array<String>) {
    val reader = BufferedReader(InputStreamReader(System.`in`))
    val arg1 = reader.readLine().toInt()
    val arg2 = reader.readLine().toInt()
    val arg3 = reader.readLine().toInt()
    val answers = listOf(alg1(arg1, arg2, arg3),
            alg2(arg1, arg2, arg3),
            alg3(arg1, arg2, arg3),
            alg4(arg1, arg2, arg3))
    println(answers.max())
}

fun main(args: Array<String>) {
    val (a,b,c) = Array(3, { readLine()!!.toInt()})
    println(arrayOf(a*b*c,(a+b)*c,a*(b+c)).max())
}

fun main(args: Array<String>) {
    val a = readLine()!!.toInt()
    val b = readLine()!!.toInt()
    val c = readLine()!!.toInt()

    fun addOrMultiply(x: Int, y: Int): Int {
        if (x == 1 || y == 1) {
            return x + y
        }
        else {
            return x * y
        }
    }

    println(addOrMultiply(addOrMultiply(a, b), c))
}

/**
 * Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last
 * class the teacher wrote three positive integers a, b, c on the blackboard. The task was to insert signs of
 * operations '+' and '*', and probably brackets between the numbers so that the value of the resulting expression is
 * as large as possible. Let's consider an example: assume that the teacher wrote numbers 1, 2 and 3 on the blackboard.
 * Here are some ways of placing signs and brackets:
 * 1+2*3=7
 * 1*(2+3)=5
 * 1*2*3=6
 * (1+2)*3=9
 * Note that you can insert operation signs only between a and b, and between b and c, that is, you cannot swap integers.
 * For instance, in the given sample you cannot get expression (1+3)*2.
 * It's easy to see that the maximum value that you can obtain is 9.
 * Your task is: given a, b and c print the maximum value that you can get.
 *
 * Input
 * The input contains three integers a, b and c, each on a single line (1 ≤ a, b, c ≤ 10).
 *
 * Output
 * Print the maximum value of the expression that you can obtain.
 */

fun readInt(): Int = readLine()!!.toInt()

fun readInputs():MutableList<Int> {
    val inputList:MutableList<Int> = mutableListOf()
    for (i in 0..2){
        inputList += listOf(readInt())
    }
    return inputList
}

fun sum0and1(list: MutableList<Int>):List<Int>{
    if (list.contains(0)) {
        list.remove(0)
    }
    val checkList = list intersect listOf(1, 1)
    return if(checkList != listOf(1, 1) && checkList != listOf(1, 1, 1)) {
        if (list.contains(1)) {
            val index = list.indexOf(1)
            list.remove(1)
            list[index]++
        }
        list.toList()
    }
    else {
        listOf(list.reduce { acc: Int, i: Int -> acc + i }.toInt())
    }
}

fun maxResult(list: List<Int>): Int = list.reduce { acc, i -> acc * i }

fun main(){
    val inputValues = readInputs().toMutableList()
    val filteredList = sum0and1(inputValues)
    val result = maxResult(filteredList)
    println(result)
}

/**
 * Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last
 * class the teacher wrote three positive integers a, b, c on the blackboard. The task was to insert signs of
 * operations '+' and '*', and probably brackets between the numbers so that the value of the resulting expression is
 * as large as possible. Let's consider an example: assume that the teacher wrote numbers 1, 2 and 3 on the blackboard.
 * Here are some ways of placing signs and brackets:
 * 1+2*3=7
 * 1*(2+3)=5
 * 1*2*3=6
 * (1+2)*3=9
 * Note that you can insert operation signs only between a and b, and between b and c, that is, you cannot swap integers.
 * For instance, in the given sample you cannot get expression (1+3)*2.
 * It's easy to see that the maximum value that you can obtain is 9.
 * Your task is: given a, b and c print the maximum value that you can get.
 *
 * Input
 * The input contains three integers a, b and c, each on a single line (1 ≤ a, b, c ≤ 10).
 *
 * Output
 * Print the maximum value of the expression that you can obtain.
 */

fun readInt(): Int = readLine()!!.toInt()

fun readInputs():MutableList<Int> {
    val inputList:MutableList<Int> = mutableListOf()
    for (i in 0..2){
        inputList += listOf(readInt())
    }
    return inputList
}

fun sum0and1(list: MutableList<Int>):List<Int>{
    if (list.contains(0)) {
        list.remove(0)
    }
    val checkList = list intersect listOf(1, 1, 1)
    return if(checkList.size < 2) {
        if (list.contains(1)) {
            val index = list.indexOf(1)
            list.remove(1)
            list[index]++
        }
        list.toList()
    }
    else {
        listOf(list.reduce { acc: Int, i: Int -> acc + i }.toInt())
    }
}

fun maxResult(list: List<Int>): Int = list.reduce { acc, i -> acc * i }

fun main(){
    val inputValues = readInputs().toMutableList()
    val filteredList = sum0and1(inputValues)
    val result = maxResult(filteredList)
    println(result)
}

import kotlin.math.min

/**
 * Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last
 * class the teacher wrote three positive integers a, b, c on the blackboard. The task was to insert signs of
 * operations '+' and '*', and probably brackets between the numbers so that the value of the resulting expression is
 * as large as possible. Let's consider an example: assume that the teacher wrote numbers 1, 2 and 3 on the blackboard.
 * Here are some ways of placing signs and brackets:
 * 1+2*3=7
 * 1*(2+3)=5
 * 1*2*3=6
 * (1+2)*3=9
 * Note that you can insert operation signs only between a and b, and between b and c, that is, you cannot swap integers.
 * For instance, in the given sample you cannot get expression (1+3)*2.
 * It's easy to see that the maximum value that you can obtain is 9.
 * Your task is: given a, b and c print the maximum value that you can get.
 *
 * Input
 * The input contains three integers a, b and c, each on a single line (1 ≤ a, b, c ≤ 10).
 *
 * Output
 * Print the maximum value of the expression that you can obtain.
 */
fun readInt(): Int = readLine()!!.toInt()

fun readInputs():MutableList<Int> {
    val inputList:MutableList<Int> = mutableListOf()
    for (i in 0..2){
        inputList += listOf(readInt())
    }
    return inputList
}

fun sum0and1(list: MutableList<Int>):List<Int>{
    if (list.contains(0)) {
        list.remove(0)
    }
    var counter = 0
    for (i in 0..2){
        if (list[i] == 1) counter++
    }
    return if(counter != 3) {
        if (list.contains(1)) {
            val index = list.indexOf(1)
            list.remove(1)
            if(index!=0 && index!=2) {
                val minValue = min(list[index], list[index - 1])
                if (minValue == list[index]) list[index]++ else list[index - 1]++
            }
            else if(index == 0){
                list[index]++
            }
            else{
                list[index-1]++
            }
        }
        list.toList()
    }
    else {
        listOf(list.reduce { acc: Int, i: Int -> acc + i }.toInt())
    }
}

fun maxResult(list: List<Int>): Int = list.reduce { acc, i -> acc * i }

fun main(){
    val inputValues = readInputs().toMutableList()
    val filteredList = sum0and1(inputValues)
    val result = maxResult(filteredList)
    println(result)
}

/**
 * Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last
 * class the teacher wrote three positive integers a, b, c on the blackboard. The task was to insert signs of
 * operations '+' and '*', and probably brackets between the numbers so that the value of the resulting expression is
 * as large as possible. Let's consider an example: assume that the teacher wrote numbers 1, 2 and 3 on the blackboard.
 * Here are some ways of placing signs and brackets:
 * 1+2*3=7
 * 1*(2+3)=5
 * 1*2*3=6
 * (1+2)*3=9
 * Note that you can insert operation signs only between a and b, and between b and c, that is, you cannot swap integers.
 * For instance, in the given sample you cannot get expression (1+3)*2.
 * It's easy to see that the maximum value that you can obtain is 9.
 * Your task is: given a, b and c print the maximum value that you can get.
 *
 * Input
 * The input contains three integers a, b and c, each on a single line (1 ≤ a, b, c ≤ 10).
 *
 * Output
 * Print the maximum value of the expression that you can obtain.
 */

fun readInt(): Int = readLine()!!.toInt()

fun readInputs():MutableList<Int> {
    val inputList:MutableList<Int> = mutableListOf()
    for (i in 0..2){
        inputList += listOf(readInt())
    }
    return inputList
}

fun sum0and1(list: MutableList<Int>):List<Int>{
    if (list.contains(0)) {
        list.remove(0)
    }
    return if(list != listOf(1, 1, 1)) {
        if (list.contains(1)) {
            list.remove(1)
            list[list.lastIndex]++
        }
        list.toList()
    }
    else {
        listOf(list.reduce { acc: Int, i: Int -> acc + i }.toInt())
    }
}

fun maxResult(list: List<Int>): Int = list.reduce { acc, i -> acc * i }

fun main(){
    val inputValues = readInputs().toMutableList()
    val filteredList = sum0and1(inputValues)
    val result = maxResult(filteredList)
    println(result)
}

/**
 * Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last
 * class the teacher wrote three positive integers a, b, c on the blackboard. The task was to insert signs of
 * operations '+' and '*', and probably brackets between the numbers so that the value of the resulting expression is
 * as large as possible. Let's consider an example: assume that the teacher wrote numbers 1, 2 and 3 on the blackboard.
 * Here are some ways of placing signs and brackets:
 * 1+2*3=7
 * 1*(2+3)=5
 * 1*2*3=6
 * (1+2)*3=9
 * Note that you can insert operation signs only between a and b, and between b and c, that is, you cannot swap integers.
 * For instance, in the given sample you cannot get expression (1+3)*2.
 * It's easy to see that the maximum value that you can obtain is 9.
 * Your task is: given a, b and c print the maximum value that you can get.
 *
 * Input
 * The input contains three integers a, b and c, each on a single line (1 ≤ a, b, c ≤ 10).
 *
 * Output
 * Print the maximum value of the expression that you can obtain.
 */
fun readInt(): Int = readLine()!!.toInt()

fun readInputs():MutableList<Int> {
    val inputList:MutableList<Int> = mutableListOf()
    for (i in 0..2){
        inputList += listOf(readInt())
    }
    return inputList
}

fun sum0and1(list: MutableList<Int>):List<Int>{
    if (list.contains(0)) {
        list.remove(0)
    }
    var counter = 0
    for (i in 0..2){
        if (list[i] == 1) counter++
    }
    return if(counter < 2) {
        if (list.contains(1)) {
            val index = list.indexOf(1)
            list.remove(1)
            list[index]++
        }
        list.toList()
    }
    else {
        listOf(list.reduce { acc: Int, i: Int -> acc + i }.toInt())
    }
}

fun maxResult(list: List<Int>): Int = list.reduce { acc, i -> acc * i }

fun main(){
    val inputValues = readInputs().toMutableList()
    val filteredList = sum0and1(inputValues)
    val result = maxResult(filteredList)
    println(result)
}

/**
 * Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last
 * class the teacher wrote three positive integers a, b, c on the blackboard. The task was to insert signs of
 * operations '+' and '*', and probably brackets between the numbers so that the value of the resulting expression is
 * as large as possible. Let's consider an example: assume that the teacher wrote numbers 1, 2 and 3 on the blackboard.
 * Here are some ways of placing signs and brackets:
 * 1+2*3=7
 * 1*(2+3)=5
 * 1*2*3=6
 * (1+2)*3=9
 * Note that you can insert operation signs only between a and b, and between b and c, that is, you cannot swap integers.
 * For instance, in the given sample you cannot get expression (1+3)*2.
 * It's easy to see that the maximum value that you can obtain is 9.
 * Your task is: given a, b and c print the maximum value that you can get.
 *
 * Input
 * The input contains three integers a, b and c, each on a single line (1 ≤ a, b, c ≤ 10).
 *
 * Output
 * Print the maximum value of the expression that you can obtain.
 */

fun readInt(): Int = readLine()!!.toInt()

fun readInputs():MutableList<Int> {
    val inputList:MutableList<Int> = mutableListOf()
    for (i in 0..2){
        inputList += listOf(readInt())
    }
    return inputList
}

fun sum0and1(list: MutableList<Int>):List<Int>{
    if (list.contains(0)) {
        list.remove(0)
    }
    val checkList = list intersect listOf(1, 1, 1)
    return if(checkList != setOf(1, 1) && checkList != setOf(1, 1, 1)) {
        if (list.contains(1)) {
            val index = list.indexOf(1)
            list.remove(1)
            list[index]++
        }
        list.toList()
    }
    else {
        listOf(list.reduce { acc: Int, i: Int -> acc + i }.toInt())
    }
}

fun maxResult(list: List<Int>): Int = list.reduce { acc, i -> acc * i }

fun main(){
    val inputValues = readInputs().toMutableList()
    val filteredList = sum0and1(inputValues)
    val result = maxResult(filteredList)
    println(result)
}

/**
 * Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last
 * class the teacher wrote three positive integers a, b, c on the blackboard. The task was to insert signs of
 * operations '+' and '*', and probably brackets between the numbers so that the value of the resulting expression is
 * as large as possible. Let's consider an example: assume that the teacher wrote numbers 1, 2 and 3 on the blackboard.
 * Here are some ways of placing signs and brackets:
 * 1+2*3=7
 * 1*(2+3)=5
 * 1*2*3=6
 * (1+2)*3=9
 * Note that you can insert operation signs only between a and b, and between b and c, that is, you cannot swap integers.
 * For instance, in the given sample you cannot get expression (1+3)*2.
 * It's easy to see that the maximum value that you can obtain is 9.
 * Your task is: given a, b and c print the maximum value that you can get.
 *
 * Input
 * The input contains three integers a, b and c, each on a single line (1 ≤ a, b, c ≤ 10).
 *
 * Output
 * Print the maximum value of the expression that you can obtain.
 */

fun readInt(): Int = readLine()!!.toInt()

fun readInputs():MutableList<Int> {
    val inputList:MutableList<Int> = mutableListOf()
    for (i in 0..2){
        inputList += listOf(readInt())
    }
    return inputList
}

fun sum0and1(list: MutableList<Int>):List<Int>{
    if (list.contains(0)) {
        list.remove(0)
    }
    return if(list != listOf(1, 1, 1)) {
        if (list.contains(1)) {
            val index = list.indexOf(1)
            list.remove(1)
            list[index]++
        }
        list.toList()
    }
    else {
        listOf(list.reduce { acc: Int, i: Int -> acc + i }.toInt())
    }
}

fun maxResult(list: List<Int>): Int = list.reduce { acc, i -> acc * i }

fun main(){
    val inputValues = readInputs().toMutableList()
    val filteredList = sum0and1(inputValues)
    val result = maxResult(filteredList)
    println(result)
}

/**
 * Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last
 * class the teacher wrote three positive integers a, b, c on the blackboard. The task was to insert signs of
 * operations '+' and '*', and probably brackets between the numbers so that the value of the resulting expression is
 * as large as possible. Let's consider an example: assume that the teacher wrote numbers 1, 2 and 3 on the blackboard.
 * Here are some ways of placing signs and brackets:
 * 1+2*3=7
 * 1*(2+3)=5
 * 1*2*3=6
 * (1+2)*3=9
 * Note that you can insert operation signs only between a and b, and between b and c, that is, you cannot swap integers.
 * For instance, in the given sample you cannot get expression (1+3)*2.
 * It's easy to see that the maximum value that you can obtain is 9.
 * Your task is: given a, b and c print the maximum value that you can get.
 *
 * Input
 * The input contains three integers a, b and c, each on a single line (1 ≤ a, b, c ≤ 10).
 *
 * Output
 * Print the maximum value of the expression that you can obtain.
 */

fun readInt(): Int = readLine()!!.toInt()

fun readInputs():MutableList<Int> {
    val inputList:MutableList<Int> = mutableListOf()
    for (i in 0..2){
        inputList += listOf(readInt())
    }
    return inputList.sortedDescending().toMutableList()
}

fun sum0and1(list: MutableList<Int>):List<Int>{
    if (list.contains(0)) {
        list.remove(0)
    }
    if(list.contains(1)){
        list.remove(1)
        list[list.lastIndex] ++
    }
    return list.toList()
}

fun maxResult(list: List<Int>): Int = list.reduce { acc, i -> acc * i }

fun main(){
    val inputValues = readInputs().toMutableList()
    val filteredList = sum0and1(inputValues)
    val result = maxResult(filteredList)
    println(result)
}

/**
 * Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last
 * class the teacher wrote three positive integers a, b, c on the blackboard. The task was to insert signs of
 * operations '+' and '*', and probably brackets between the numbers so that the value of the resulting expression is
 * as large as possible. Let's consider an example: assume that the teacher wrote numbers 1, 2 and 3 on the blackboard.
 * Here are some ways of placing signs and brackets:
 * 1+2*3=7
 * 1*(2+3)=5
 * 1*2*3=6
 * (1+2)*3=9
 * Note that you can insert operation signs only between a and b, and between b and c, that is, you cannot swap integers.
 * For instance, in the given sample you cannot get expression (1+3)*2.
 * It's easy to see that the maximum value that you can obtain is 9.
 * Your task is: given a, b and c print the maximum value that you can get.
 *
 * Input
 * The input contains three integers a, b and c, each on a single line (1 ≤ a, b, c ≤ 10).
 *
 * Output
 * Print the maximum value of the expression that you can obtain.
 */

fun readInt(): Int = readLine()!!.toInt()

fun readInputs():MutableList<Int> {
    val inputList:MutableList<Int> = mutableListOf()
    for (i in 0..2){
        inputList += listOf(readInt())
    }
    return inputList.sortedDescending().toMutableList()
}

fun sum0and1(list: MutableList<Int>):List<Int>{
    if (list.contains(0)) {
        list.remove(0)
    }
    return if(list != listOf(1, 1, 1)) {
        if (list.contains(1)) {
            list.remove(1)
            list[list.lastIndex]++
        }
        list.toList()
    }
    else {
        listOf(list.reduce { acc: Int, i: Int -> acc + i }.toInt())
    }
}

fun maxResult(list: List<Int>): Int = list.reduce { acc, i -> acc * i }

fun main(){
    val inputValues = readInputs().toMutableList()
    val filteredList = sum0and1(inputValues)
    val result = maxResult(filteredList)
    println(result)
}

import kotlin.math.min

/**
 * Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last
 * class the teacher wrote three positive integers a, b, c on the blackboard. The task was to insert signs of
 * operations '+' and '*', and probably brackets between the numbers so that the value of the resulting expression is
 * as large as possible. Let's consider an example: assume that the teacher wrote numbers 1, 2 and 3 on the blackboard.
 * Here are some ways of placing signs and brackets:
 * 1+2*3=7
 * 1*(2+3)=5
 * 1*2*3=6
 * (1+2)*3=9
 * Note that you can insert operation signs only between a and b, and between b and c, that is, you cannot swap integers.
 * For instance, in the given sample you cannot get expression (1+3)*2.
 * It's easy to see that the maximum value that you can obtain is 9.
 * Your task is: given a, b and c print the maximum value that you can get.
 *
 * Input
 * The input contains three integers a, b and c, each on a single line (1 ≤ a, b, c ≤ 10).
 *
 * Output
 * Print the maximum value of the expression that you can obtain.
 */
fun readInt(): Int = readLine()!!.toInt()

fun readInputs():MutableList<Int> {
    val inputList:MutableList<Int> = mutableListOf()
    for (i in 0..2){
        inputList += listOf(readInt())
    }
    return inputList
}

fun sum0and1(list: MutableList<Int>):List<Int>{
    if (list.contains(0)) {
        list.remove(0)
    }
    var counter = 0
    for (i in 0..2){
        if (list[i] == 1) counter++
    }
    return if(counter < 2) {
        if (list.contains(1)) {
            val index = list.indexOf(1)
            list.remove(1)
            if(index!=0 && index!=2) {
                val minValue = min(list[index], list[index - 1])
                if (minValue == list[index]) list[index]++ else list[index - 1]++
            }
            else if(index == 0){
                list[index]++
            }
            else{
                list[index-1]++
            }
        }
        list.toList()
    }
    else {
        listOf(list.reduce { acc: Int, i: Int -> acc + i }.toInt())
    }
}

fun maxResult(list: List<Int>): Int = list.reduce { acc, i -> acc * i }

fun main(){
    val inputValues = readInputs().toMutableList()
    val filteredList = sum0and1(inputValues)
    val result = maxResult(filteredList)
    println(result)
}


fun main(args: Array<String>) {
    val a = Array(3) {readLine()}
    var bad = false
    for (i in 0 until 3)
        for (j in 0 until 3)
            bad = bad or (a[i]!![j] != a[2 - i]!![2 - j])
    println(if (bad) "NO" else "YES")
}

fun main(args: Array<String>) {

    val matrix = Array(3){""}
    for (x in 0 until 3) matrix[x] = readLine()!!
    when {
        matrix[0][0] != matrix[2][2] -> print("NO")
        matrix[0][1] != matrix[2][1] -> print("NO")
        matrix[0][2] != matrix[2][0] -> print("NO")
        matrix[1][0] != matrix[1][2] -> print("NO")
        else -> print("YES")
    }
}

import java.util.Scanner

fun main(args : Array<String>) {

    var line1: MutableList<Char> = mutableListOf()
    var line2: MutableList<Char> = mutableListOf()
    var line3: MutableList<Char> = mutableListOf()
    val a = readLine()!!
    val b = readLine()!!
    val c = readLine()!!

    for (char in a) { line1.add(char) }
    for (char in b) { line2.add(char) }
    for (char in c) { line3.add(char) }

    if(line1[0]==line1[2] && line2[0]==line2[2] && line3[0]==line3[2] && line1[1]==line3[1]){
        println("YES")
    }
    else if(line1[0]==line3[0] && line1[1]==line3[1] && line1[2]==line3[2] && line2[0]==line2[2]){
        println("YES")
    }
    else if(line1[0]==line3[2] && line1[1]==line3[1] && line1[2]==line3[0] && line2[0]==line2[2]){
        println("YES")
    }
    else {
        println("NO")

    }

}

fun main() {
    val board = Array(3) { "" }
    board[0] = readLine()!!
    board[1] = readLine()!!
    board[2] = readLine()!!
    for (row in 0 until 2)
        for (column in 0 until 3)
            if (board[row][column] != board[2 - row][2 - column]) return print("NO")
    print("YES")
}


import java.util.Scanner
import java.lang.Math.*

class Cell(s : String) {
    val col = s[0] - 'a'
    val row = s[1].toInt()
}

fun move(source: Cell, target: Cell) {
    var deltaCol = target.col - source.col
    var deltaRow = target.row - source.row
    val absoluteCol = abs(deltaCol)
    val absoluteRow = abs(deltaRow)
    val steps = max(absoluteCol, absoluteRow)
    println(steps)
    for (i in 0 until steps) {
        if (deltaCol > 0) {
            print('R')
            deltaCol--
        } else if (deltaCol < 0) {
            print('L')
            deltaCol++
        }

        if (deltaRow > 0) {
            print('U')
            deltaRow--
        } else if (deltaRow < 0) {
            print('D')
            deltaRow++
        }

        println()
    }
}

fun main() {
    val scanner = Scanner(System.`in`)
    val source = Cell(scanner.nextLine())
    val target = Cell(scanner.nextLine())
    move(source, target)
}

fun readString1(): String
{
    val line: String? = readLine()
    if (line == null) return ""
    return line.trim()
}

fun main (args: Array<String>)
{
    val first: String = readString1()
    val second: String = readString1()

    var x1: Int = 0
    var y1: Int = 0
    var x2: Int = 0
    var y2: Int = 0

    x1 = first.get(0).toInt() - 'a'.toInt()
    y1 = first.get(1).toString().toInt()-1

    x2 = second.get(0).toInt() - 'a'.toInt()
    y2 = second.get(1).toString().toInt()-1

    var c: Int = 0
    var r: MutableList<String> = mutableListOf()

    while (!(x1==x2&&y1==y2))
    {

        var m: String = ""

        if(x1 > x2)
        {
            x1--
            m+="L"
        }
        else if(x1 < x2)
        {
            x1++
            m+="R"
        }

        if(y1 > y2)
        {
            y1--
            m+="D"
        }
        else if(y1 < y2)
        {
            y1++
            m+="U"
        }
        r.add(m)
        c++
    }
    print(r.joinToString(separator = "\n",prefix = ("$c\n")))

}

import java.util.Scanner

fun main(args : Array<String>) {

    var coor1: MutableList<Char> = mutableListOf()
    var coor2: MutableList<Char> = mutableListOf()
    val n = readLine()!!
    val m = readLine()!!

    for(char in n){ coor1.add(char) }
    for(char in m){ coor2.add(char) }

    if(coor1[0]==coor2[0] && coor1[1]==coor2[1]){ println(0) }
    else if(coor1[0]==coor2[0] && coor1[1]>coor2[1]){
        println(coor1[1]-coor2[1])
        for(i in 1..(coor1[1]-coor2[1])){ println("D") }
    }
    else if(coor1[0]==coor2[0] && coor1[1]<coor2[1]){
        println(coor2[1]-coor1[1])
        for(i in 1..(coor2[1]-coor1[1])){ println("U") }
    }
    else if(coor1[1]==coor2[1] && coor1[0]<coor2[0]){
        println(coor2[0]-coor1[0])
        for(i in 1..(coor2[0]-coor1[0])){ println("R") }
    }
    else if(coor1[1]==coor2[1] && coor1[0]>coor2[0]){
        println(coor1[0]-coor2[0])
        for(i in 1..(coor1[0]-coor2[0])){ println("L") }
    }
    else if(coor1[1]<coor2[1] && coor1[0]<coor2[0]){
        if((coor2[1]-coor1[1])<(coor2[0]-coor1[0])){
            println((coor2[0]-coor1[0]))
            for(i in 1..(coor2[1]-coor1[1])){ println("RU") }
            for(i in 1..(coor2[0]-coor1[0])-(coor2[1]-coor1[1])){ println("R") }
        }
        else if((coor2[1]-coor1[1])>(coor2[0]-coor1[0])){
            println((coor2[1]-coor1[1]))
            for(i in 1..(coor2[0]-coor1[0])){ println("RU") }
            for(i in 1..(coor2[1]-coor1[1])-(coor2[0]-coor1[0])){ println("U") }
        }
        else {
            println((coor2[1] - coor1[1]))
            for (i in 1..(coor2[0] - coor1[0])) { println("RU") }
        }
    }
    else if(coor1[1]>coor2[1] && coor1[0]<coor2[0]){
        if((coor1[1]-coor2[1])<(coor2[0]-coor1[0])){
            println((coor2[0]-coor1[0]))
            for(i in 1..(coor1[1]-coor2[1])){ println("RD") }
            for(i in 1..(coor2[0]-coor1[0])-(coor1[1]-coor2[1])){ println("R") }
        }
        else if((coor1[1]-coor2[1])>(coor2[0]-coor1[0])){
            println((coor1[1]-coor2[1]))
            for(i in 1..(coor2[0]-coor1[0])){ println("RD") }
            for(i in 1..(coor1[1]-coor2[1])-(coor2[0]-coor1[0])){ println("D") }
        }
        else {
            println((coor1[1] - coor2[1]))
            for (i in 1..(coor1[1] - coor2[1])) { println("RD") }
        }
    }
    else if(coor1[1]<coor2[1] && coor1[0]>coor2[0]){
        if((coor2[1]-coor1[1])<(coor1[0]-coor2[0])){
            println((coor1[0]-coor2[0]))
            for(i in 1..(coor2[1]-coor1[1])){ println("LU") }
            for(i in 1..(coor1[0]-coor2[0])-(coor2[1]-coor1[1])){ println("L") }
        }
        else if((coor2[1]-coor1[1])>(coor1[0]-coor2[0])){
            println((coor2[1]-coor1[1]))
            for(i in 1..(coor1[0]-coor2[0])){ println("LU") }
            for(i in 1..(coor2[1]-coor1[1])-(coor1[0]-coor2[0])){ println("U") }
        }
        else {
            println((coor2[1] - coor1[1]))
            for (i in 1..(coor2[1] - coor1[1])) { println("LU") }
        }
    }
    else if(coor1[1]>coor2[1] && coor1[0]>coor2[0]){
        if((coor1[1]-coor2[1])<(coor1[0]-coor2[0])){
            println((coor1[0]-coor2[0]))
            for(i in 1..(coor1[1]-coor2[1])){ println("LD") }
            for(i in 1..(coor1[0]-coor2[0])-(coor1[1]-coor2[1])){ println("L") }
        }
        else if((coor1[1]-coor2[1])>(coor1[0]-coor2[0])){
            println((coor1[1]-coor2[1]))
            for(i in 1..(coor1[0]-coor2[0])){ println("LD") }
            for(i in 1..(coor1[1]-coor2[1])-(coor1[0]-coor2[0])){ println("D") }
        }
        else {
            println((coor1[1] - coor2[1]))
            for (i in 1..(coor1[1] - coor2[1])) { println("LD") }
        }
    }
}

import kotlin.math.abs

fun main() {
    val r = System.`in`.bufferedReader()
    val s1 = StringBuilder()
    //val (s, n) = r.readLine()!!.split(" ").map { it.toInt() }
    //val n = r.readLine()!!.toInt()
    val st = r.readLine()!!
    val en = r.readLine()!!
    var right = en[0].toInt() - st[0].toInt()
    var up = en[1].toInt() - st[1].toInt()
    println(maxOf(abs(right), abs(up)))
    var ans = 0
    while (up != 0 || right != 0) {
        when {
            up != 0 && right != 0 -> {
                when {
                    up > 0 && right > 0 -> {
                        println("RU")
                        up--
                        right--
                    }
                    up > 0 && right < 0 -> {
                        println("LU")
                        up--
                        right++
                    }
                    up < 0 && right > 0 -> {
                        println("RD")
                        up++
                        right--
                    }
                    up < 0 && right < 0 -> {
                        println("LD")
                        up++
                        right++
                    }
                }
            }
            up == 0 -> if (right>0){
                println("R")
                right--
            } else{
                println("L")
                right++
            }
            right==0->if (up>0){
                println("U")
                up--
            }else{
                println("D")
                up++
            }
        }
    }
}

import java.util.*
import java.math.*
import kotlin.math.*

fun readLn()=readLine()!!
fun readInt()=readLn().toInt()
fun readInts()=readLn().split(" ").map{it.toInt()}
fun readLong()=readLn().toLong()
fun readLongs()=readLn().split(" ").map{it.toLong()}

val out=mutableListOf<String>()
fun printLine(s:String){out.add(s)}
fun output(){println(out.joinToString("\n"))}

fun main(){
    var a=readLn()
    var b=readLn()
    var x=abs(a[0]-b[0])
    var y=abs(a[1]-b[1])
    var ch1=if(a[0]>b[0])'L' else 'R'
    var ch2=if(a[1]>b[1])'D' else 'U'
    printLine("${max(x,y)}")
    repeat(min(x,y)){printLine("$ch1$ch2")}
    for(i in 1..x-y){printLine("$ch1")}
    for(i in 1..y-x){printLine("$ch2")}
    output()
}

fun a3() {
    var result = arrayOf<String>()
    var first = ""
    var second = ""
    var intSize : Int
    var charSize : Int
    val loopSize : Int

    val start = readLine()!!
    val end = readLine()!!

    if (start[1].toInt() > end[1].toInt()) {
        intSize = start[1].toInt() - end[1].toInt()
        second = "D"
    } else {
        intSize = end[1].toInt() - start[1].toInt()
        second = "U"
    }

    if (start[0] > end[0]) {
        charSize = start[0] - end[0]
        first = "L"
    } else {
        charSize = end[0] - start[0]
        first = "R"
    }

    loopSize = if(intSize > charSize) intSize else charSize

    for (i in 0 until loopSize) {
        if(intSize <= 0) second = ""
        if(charSize <= 0) first = ""

        intSize--
        charSize--

        result += "$first$second"
    }

    println(loopSize)
    result.forEach {
        println(it)
    }
}

fun main() {
    a3()
}

import java.util.*

fun main(args: Array<String>) {
    main { readLine() }
}

fun main(readLine: () -> String?) {
    val problem = readProblem(readLine)
    val solution = solve(problem)
    printSolution(solution)
}

// READ

fun readProblem(readLine: () -> String?): Problem {
    val start = Position.parse(readLine()!!.trim())
    val target = Position.parse(readLine()!!.trim())
    return Problem(start, target)
}

class Position (val x: Int, val y: Int) {
    companion object {
        fun parse(str: String): Position {
            return Position(
                    str[0].toInt() - 'a'.toInt(),
                    str[1].toInt() - '0'.toInt()
            )
        }
    }

    override fun toString(): String {
        return "($x - $y)"
    }
}

class Problem (val from: Position, val to: Position)

// SOLVE PROBLEM

fun solve(problem: Problem): Answer {
    val answer = Answer()
    var xd = problem.to.x - problem.from.x
    var yd = problem.to.y - problem.from.y
    when {
        (xd < 0 && yd < 0) -> {
            val len = if (-xd < -yd) { -xd } else { -yd }
            xd += len
            yd += len
            answer.go(Direction.LD, len)
        }
        (xd < 0 && yd > 0) -> {
            val len = if (-xd < yd) { -xd } else { yd }
            xd += len
            yd -= len
            answer.go(Direction.LU, len)
        }
        (xd > 0 && yd > 0) -> {
            val len = if (xd < yd) { xd } else { yd }
            xd -= len
            yd -= len
            answer.go(Direction.RU, len)
        }
        (xd > 0 && yd < 0) -> {
            val len = if (xd < -yd) { xd } else { -yd }
            xd -= len
            yd += len
            answer.go(Direction.RD, len)
        }
    }
    when {
        (xd < 0) -> {
            answer.go(Direction.L, -xd)
        }
        (xd > 0) -> {
            answer.go(Direction.R, xd)
        }
        (yd < 0) -> {
            answer.go(Direction.D, -yd)
        }
        (yd > 0) -> {
            answer.go(Direction.U, yd)
        }
    }
    return answer
}

// PRINT SOLUTION

class Answer () {
    private val segments: MutableList<Segment> = ArrayList()

    fun go(dir: Direction, length: Int) {
        if (length > 0) {
            segments.add(Segment(dir, length))
        }
    }

    fun print(consumer: (String) -> Unit) {
        val length = segments.map { it.length } .sum()
        consumer(length.toString())
        for (seg in segments) {
            for (i in 1..seg.length) {
                consumer(seg.dir.name)
            }
        }
    }
}

class Segment(val dir: Direction, val length: Int) {
    override fun toString(): String {
        val sb = StringBuilder()
        for (i in 1..length) {
            sb.append(dir)
        }
        return sb.toString()
    }
}

enum class Direction() {
    L, LD, D, RD, R, RU, U, LU
}

fun printSolution(solution: Answer) {
    solution.print { println(it) }
}

import kotlin.math.abs
import kotlin.math.max

fun main() {
    val from = readLine()!!
    val to = readLine()!!
    var horizontal = from[0] - to[0]
    var vertical = from[1] - to[1]
    println(max(abs(horizontal), abs(vertical)))
    while (horizontal != 0 || vertical != 0) {
        when {
            horizontal < 0 -> {
                print('R'); horizontal++
            }
            horizontal > 0 -> {
                print('L'); horizontal--
            }
        }
        when {
            vertical < 0 -> {
                print('U'); vertical++
            }
            vertical > 0 -> {
                print('D'); vertical--
            }
        }
        println()
    }
}

import kotlin.math.abs

private fun readLn() = readLine()!!

fun main() {
    val s = readLn().toCharArray()
    val d = readLn().toCharArray()

    var dr: Int = abs(s[0] - d[0])
    var dw: Int = abs(s[1] - d[1])

    val n = maxOf(dr, dw)
    println(n)
    repeat(n) {
        if(dr>0) {
            if (s[0] > d[0]) {
                s[0]--
                print("L")
            } else {
                s[0]++
                print("R")
            }
            dr--
        }
        if(dw>0) {
            if (s[1] > d[1]) {
                s[1]--
                print("D")
            } else {
                s[1]++
                print("U")
            }
            dw--
        }
        println()
    }
}

fun main() {
    val s = readLine()!!.toCharArray()
    val d = readLine()!!.toCharArray()
    var hori = s[0] - d[0]
    var vert = s[1] - d[1]
    if (hori >= 0 && vert >= 0) { // a8 - h1 = 7 fin
        if (hori > vert) {
            println(hori)
        } else {
            println(vert)
        }
    } else if (hori <= 0 && vert >= 0) {
        if (-hori > vert) {
            println(-hori)
        } else {
            println(vert)
        }
    } else if (hori >= 0 && vert <= 0) {
        if (hori > -vert) {
            println(hori)
        } else {
            println(-vert)
        }
    } else { // hori and vert are negative , (-x,0)
        if (-hori < -vert) {
            println(-vert)
        } else {
            println(-hori)
        }
    }
    while (hori != 0 || vert != 0) { // add or sub until equals to 0
        //println("$hori $vert")
        if (hori < 0) {
            print('R')
            hori++
        } else if (hori > 0) {
            print('L')
            hori--
        }
        if (vert < 0) {
            print('U')
            vert++
        } else if (vert > 0) {
            print('D')
            vert--
        }
        println()
    }
}

import java.util.*
import kotlin.math.abs
import kotlin.math.max

fun main() {
    var reader = Scanner(System.`in`)

    var start = reader.nextLine().trim()
    var end = reader.nextLine().trim()

    var x = start[0] - end[0]
    var y = start[1] - end[1]

    val res = max(abs(x), abs(y))
    println(res)
    repeat(res) {
        if (x > 0) {
            print('L')
            x--
        }
        if (x < 0) {
            print('R')
            x++
        }
        if (y > 0) {
            print('D')
            y--
        }
        if (y < 0) {
            print('U')
            y++
        }
        println()
    }
}

fun main() {
    val r = System.`in`.bufferedReader()
    val s1 = StringBuilder()
    //val (s, n) = r.readLine()!!.split(" ").map { it.toInt() }
    //val n = r.readLine()!!.toInt()
    val st = r.readLine()!!
    val en = r.readLine()!!
    var right = en[0].toInt() - st[0].toInt()
    var up = en[1].toInt() - st[1].toInt()
    println(maxOf(right, up))
    var ans = 0
    while (up != 0 || right != 0) {
        when {
            up != 0 && right != 0 -> {
                when {
                    up > 0 && right > 0 -> {
                        println("RU")
                        up--
                        right--
                    }
                    up > 0 && right < 0 -> {
                        println("LU")
                        up--
                        right++
                    }
                    up < 0 && right > 0 -> {
                        println("RD")
                        up++
                        right--
                    }
                    up < 0 && right < 0 -> {
                        println("LD")
                        up++
                        right++
                    }
                }
            }
            up == 0 -> if (right>0){
                println("R")
                right--
            } else{
                println("L")
                right++
            }
            right==0->if (up>0){
                println("U")
                up--
            }else{
                println("D")
                up++
            }
        }
    }
}

fun main() {
    val s = readLine()!!.toCharArray()
    val d = readLine()!!.toCharArray()
    var hori = s[0]-d[0]
    var vert = s[1]-d[1]
    if(hori>0&&vert>0){ // a8 - h1 = 7 fin
        if(hori>vert){
            println(hori)
        }else{
            println(vert)
        }
    }else if(hori<0&&vert>0){
        if(-hori > vert){
            println(-hori)
        }else{
            println(vert)
        }
    }else if(hori>0&&vert<0){
        if(hori>-vert){
            println(hori)
        }else{
            println(-vert)
        }
    }else{ // hori and vert are negative
        if(hori>vert){
            println(-vert)
        }else{
            println(-hori)
        }
    }
    while (hori!=0||vert!=0){ // add or sub until equals to 0
        //println("$hori $vert")
        if(hori<0){
            print('R')
            hori++
        }else if(hori > 0){
            print('L')
            hori--
        }
        if(vert<0){
            print('U')
            vert++
        }else if(vert > 0){
            print('D')
            vert--
        }
        println()
    }
}

fun main() {
    val s = readLine()!!.toCharArray()
    val d = readLine()!!.toCharArray()
    var hori = s[0]-d[0]
    var vert = s[1]-d[1]
    if(hori>0&&vert>0){ // a8 - h1 = 7 fin
        if(hori>vert){
            println(hori)
        }else{
            println(vert)
        }
    }else if(hori<0&&vert>0){
        if(-hori > vert){
            println(-hori)
        }else{
            println(vert)
        }
    }else if(hori>0&&vert<0){
        if(hori>-vert){
            println(hori)
        }else{
            println(-vert)
        }
    }else{ // hori and vert are negative
        if(hori>vert){
            println(-vert)
        }else{
            println(-hori)
        }
    }
    while (hori!=0&&vert!=0){
        if(hori<0){
            print('R')
            hori++
        }else{
            print('L')
            hori--
        }
        if(vert<0){
            print('D')
            vert++
        }else{
            print('U')
            vert--
        }
        println()
    }
}

import java.util.*
import kotlin.math.abs
import kotlin.math.max

fun main() {
    var reader = Scanner(System.`in`)

    var start = reader.nextLine().trim()
    var end = reader.nextLine().trim()

    var x = start[0] - end[0]
    var y = start[1] - end[1]

    val res = max(abs(x), abs(y))
    println(res)
    repeat(res) {
        if (x > 0) {
            print('L')
            x--
        }
        if (x < 0) {
            print('R')
            x++
        }
        if (y > 0) {
            println('D')
            y--
        }
        if (y < 0) {
            println('U')
            y++
        }
    }
}


fun main() {
    readInteger()
    val s = readLine()!!
    var pre = s[0]
    var sCount = 0
    var fCount = 0
    for (i in 1 until s.length) {
        if (pre != s[i]){
            if (pre == 'S') {
                sCount++
            } else {
                fCount++
            }
        }

        pre = s[i]
    }

    val ans = if (sCount > fCount) {
        "Yes"
    } else {
        "No"
    }

    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readStrings() = readLine()!!.split(" ")
fun readIntegers() = readStrings().map(String::toInt)

fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    val n = r.readLine()!!.toInt()
    //val v = r.readLine()!!.split(" ").map { it.toLong() }
    val str = r.readLine()!!
    var sf = 0
    var fs = 0
    (0..n-2).forEach {
        when{
            str[it]=='S'&&str[it+1]=='F' -> sf++
            str[it]=='F'&&str[it+1]=='S' -> fs++
        }
    }
    println(if (sf>fs) "YES" else "NO")
}

fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val s = readLine()!!
    if (s[0]=='S' && s[n-1]=='F') println("YES") else println("NO")
}

fun main(args:Array<String>)
{
var n=readLine()!!
    var t=readLine()!!
    var switch=0
    var counter=0
    var counter1=0
    var flag=false
    var f=false
for(i in t) {
    if(i=='S')
    {
        f=true
    }
    if(i=='F'&&f)
    {
        f=false
        counter++;
    }
}
    f=false
    for(i in t) {
        if(i=='F')
        {
            f=true
        }
        if(i=='S'&&f)
        {
            f=false
            counter1++;
        }
    }

    println(if(counter>counter1) "YES" else "NO")
}

fun main(args: Array<String>) {
    readLine()
    val input = readLine()!!
    val chars = input.toCharArray()

    var previousChar = chars.first()
    var i = 0
    var sf = 0
    var fs = 0

    for (char in chars) {
        if (i > 0 && char != previousChar) {
            if (char == 'S') {
                fs += 1
            } else {
                sf += 1
            }
        }
        previousChar = char
        i += 1
    }

    if (sf > fs) println("YES") else println("NO")
}

/* https://codeforces.com/problemset/problem/867/A */

fun main() {
    readLine()!!.toInt() // read number of days
    val cityInitials = readLine()!!
    var tripsFromStoF = 0
    var tripsFromFtoS = 0
    var lastChar = '_'
    cityInitials.forEach {
        if (it == 'F' && lastChar == 'S') {
            tripsFromStoF++
        } else if (it == 'S' && lastChar == 'F') {
            tripsFromFtoS++
        }
        lastChar = it
    }
    println(if (tripsFromStoF > tripsFromFtoS) "YES" else "NO")
}

fun main() {
    val nightCount = Integer.parseInt(readLine()!!)
    val cities = readLine()!!
    var sf = 0
    var fs = 0
    for(i in 0 until nightCount - 1) {
        val flight = cities.substring(i, i + 2)
        when (flight) {
            "SF" -> sf++
            "FS" -> fs++
        }
    }

    if (sf > fs) {
        println("YES")
    } else {
        println("NO")
    }
}

fun main() {
    var n = readLine()!!.toInt()
    val line = readLine()!!.toCharArray()
    var SF = 0
    var FS = 0
    for (i in 0 until line.size-1)
    {
        if (line[i] == 'S' && line[i+1] == 'F')
            SF++
        else if (line[i] == 'F' && line[i+1] == 'S')
            FS++
    }

    if (SF > FS)
        print("YES")
    else
        print("NO")

}

fun main() {
    readLine()
    val s = readLine()

    var franCount = 0
    var sietlCount = 0
    var last = s!![0]
    for (c in s!!) {
        if(last != c) {
            if(c == 'F') {
                franCount++
            } else {
                sietlCount++
            }
            last = c
        }
    }

    if(franCount > sietlCount) print("Yes") else print("No")
}

private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }

fun main() {
    readInt()
    val flights = readLn()
    var f = 0
    var s = 0
    for (i in 1 until flights.length) {
        if (flights[i] != flights[i - 1]) {
            if (flights[i] == 'S') s++
            else f++
        }
    }
    if (f > s) println("yes") else println("no")
}

/**
 * Problem Link: https://codeforces.com/problemset/problem/867/A
 * Difficulty: 600
 */
fun main(args: Array<String>) {
    readLine()!!
    val s = readLine()!!
    var lastChar = ' '
    var SF = 0
    var FS = 0
    s.forEach { c ->
        if (lastChar == 'F' && c == 'S') {
            FS++
        }
        if (lastChar == 'S' && c == 'F') {
            SF++
        }
        lastChar = c
    }
    println("${if (SF > FS) "YES" else "NO"}")
}

import java.lang.StringBuilder
import java.util.*
import kotlin.collections.ArrayList
import kotlin.math.max

fun main() {
    var sc = Scanner(System.`in`)
    var n = sc.nextInt()
    var str = sc.next()
    var s = 0

    for (i in 1..str.length - 1) {
        if (str[i] == 'F' && str[i - 1] == 'S') {
            s++
        } else if (str[i] == 'S' && str[i - 1] == 'F') {
            s--
        }
    }
    if (s > 0) {
        println("YES")
    } else {
        println("NO")
    }

}

fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    var String = readLine().toString()
    var dem1 = 0
    var dem2 = 0
    for (i in 0..(String.length-2)){
        if (String[i] == 'F' && String[i+1] == 'S')
            dem1 ++
        if (String[i+1] == 'F' && String[i] == 'S')
            dem2 ++
    }
    print( if (dem1>=dem2) "NO" else "YES")
}

fun main() {
    val numDays = readLine()!!.toInt()
    val cities = readLine()!!
    var counter = 0
    for (pos in 1 until numDays) {
        when {
            (cities[pos] == 'S' && cities[pos - 1] == 'F') -> counter--
            (cities[pos] == 'F' && cities[pos - 1] == 'S') -> counter++
        }
    }
    if (counter > 0) print("YES") else print("NO")
}

    fun main(args: Array<String>){
        var temp = 0
        val n = readLine()!!.toInt()
        val s = readLine()!!

        for(i in 0 until n-1){
            when {
                (s[i] == 'S' && s[i+1] == 'F') ->temp++
                (s[i] == 'F' && s[i+1] == 'S') ->temp--
            }
        }
        if(temp>0) print ("YES") else print("NO")
    }

private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readLong() = readLn().toLong()
private fun readDouble() = readLn().toDouble()
private fun readStrings() = readLn().split(' ')
private fun readInts() = readStrings().map { it.toInt() }
private fun readLongs() = readStrings().map { it.toLong() }
private fun readDoubles() = readStrings().map { it.toDouble() }

fun main() {
    val n = readInt()
    val s = readLn()
    var cntSF = 0
    var cntFS = 0
    for (i in 1 until s.length) {
        when (s.subSequence(i - 1, i + 1)) {
            "SF" -> cntSF++
            "FS" -> cntFS++
        }
    }
    if (cntSF > cntFS) {
        println("YES")
    } else {
        println("NO")
    }
}

import java.util.Scanner
import kotlin.math.max

fun main() {
    val reader = Scanner(System.`in`)

    var n = reader.nextInt()
    var s = reader.next()

    var win = 0
    var lose = 0
    for(i in 1..n-1){
        if (s[i] == 'F' && s[i-1] == 'S') {
            win++
        } else if (s[i] == 'S' && s[i-1] == 'F') {
            lose++
        }
    }
    if(win > lose) println("YES")
    else println("NO")
}

fun main(args:Array<String>)
{

    var t=readLine()!!
    var switch=0
    var counter=0
    var counter1=0
    var flag=false
    var f=false
for(i in t) {
    if(i=='S')
    {
        f=true
    }
    if(i=='F'&&f)
    {
        f=false
        counter++;
    }
}
    f=false
    for(i in t) {
        if(i=='F')
        {
            f=true
        }
        if(i=='S'&&f)
        {
            f=false
            counter1++;
        }
    }

    println(if(counter>counter1) "YES" else "NO")
}

fun main() {
    val nightCount = Integer.parseInt(readLine()!!)
    val cities = readLine()!!
    var sf = 0
    var fs = 0
    for(i in 0 until nightCount - 1) {
        val flight = cities.substring(i, i + 2)
        println(flight)
        when (flight) {
            "SF" -> sf++
            "FS" -> fs++
        }
    }

    if (sf > fs) {
        println("YES")
    } else {
        println("NO")
    }
}


fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    //val n = r.readLine()!!.toInt()
    //val (n, k) = r.readLine()!!.split(" ").map { it.toInt() }
    val s1 = r.readLine()!!
    val s2 = r.readLine()!!
    var i = 0
    s2.forEach {
        if (it==s1[i]) i++
    }
    println(i+1)
}

import java.util.*
val reader = Scanner(System.`in`)
var ans = 1
fun main(args: Array<String>){
    val s = reader.next()
    val t = reader.next()

    for (i in t) {

        if(i == s[ans-1])
            ans++
    }

    print(ans)
}

fun solution (a:String, b:String) : Int {
    var pos = 0;
    for (i in b) {
        if (i == a[pos]) {
            pos++
        }
    }
    return pos+1
}

fun main(args: Array<String>) {
    //    myassert(2, solution("RGB", "RRR"))
    //    myassert(3, solution("RRRBGBRBBB", "BBBRR"))
    //    myassert(15, solution("BRRBGBRGRBGRGRRGGBGBGBRGBRGRGGGRBRRRBRBBBGRRRGGBBB",
    //            "BBRBGGRGRGBBBRBGRBRBBBBRBRRRBGBBGBBRRBBGGRBRRBRGRB"))

    solution(readLine()!!, readLine()!!).let{print(it)}
}

import java.io.BufferedReader
import java.io.InputStreamReader

fun main() {
    val br = BufferedReader(InputStreamReader(System.`in`))
    val s = br.readLine()
    val t = br.readLine()
    var pos = 0
    for (c in t) {
        if (c == s[pos]){
            pos++
        }
    }
    println(pos + 1)
}

import java.util.*

fun main() {
    val reader = Scanner(System.`in`)
    val t = reader.nextLine()
    val c = reader.nextLine()
    var ci=0
    c.forEach {
        if (it==t[ci]){
            ci++
        }
    }
    println(ci+1)
}

fun readLn() = readLine()!! // string line
fun readInt() = readLn().toInt() // single int
fun readStrings() = readLn().split(" ") // list of strings
fun readInts() = readStrings().map { it.toInt() } // list of ints

fun findLissPos(): Int {

    val stones = readLn()
    val instructions = readLn()
    var curPos = 0
    for (i in 0 until instructions.length) {
        if (stones[curPos ] == instructions[i])
            curPos++
    }

    curPos++

    return curPos;
}

fun main() {
    print(findLissPos())
}

fun main() {
   var r : String = readLine()!!
    var q: String = readLine()!!
    var i : Int = 0;
    for(idx in 0..q.lastIndex) {
        if(q[idx] == r[i]) {
            i++;
        }
    }
    println(i + 1);
}

import java.lang.AssertionError
import java.util.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

private fun myAssert(x: Boolean) {
    if (!x) {
        throw AssertionError()
    }
}

fun main(args: Array<String>) {
//  var s = Scanner(System.`in`)
  var s = readLn()
  var t = readLn()
  var ans = 0
  var l = 0
  var r = 0
  while (r < t.length) {
    if (s[l] == t[r]) {
      l++
      r++
    } else {
      r++
    }
  }
  println(l + 1)
}

fun main() {
    val s = readLine()!!
    val t = readLine()!!
    var sPos = 0
    for(c in t)
        if(c == s[sPos]) sPos++
    print(sPos + 1)
}

// Bismillahir Rahmanir Raheem

import java.util.Scanner
fun main() {
    val sc = Scanner (System.`in`)

    var str: String = readLine()!!
    var stt: String = readLine()!!

    var j: Int = 0
    var s: Int = stt.length

    for (i in 0 .. s-1)
        if (str[j] == stt[i]) j++

    println (j+1)
}

import java.util.*

fun main() {
    val sc = Scanner(System.`in`)
    var str = sc.nextLine()
    var cmd = sc.nextLine()
    var cnt = 1
    var i = 0
    for (ch in cmd) {
        if(ch == str[i]) {
            cnt++
            i++
        }
    }
    print(cnt)
}

import java.io.PrintWriter
import java.util.StringTokenizer
import kotlin.math.pow
import kotlin.math.sqrt

//private val INPUT = File("input.txt").inputStream()
//private val OUTPUT = File("output.txt").outputStream()
private val INPUT = System.`in`
private val OUTPUT = System.out

private val bufferedReader = INPUT.bufferedReader()
private val outputWriter = PrintWriter(OUTPUT, false)
private fun readLn() = bufferedReader.readLine()!!

private fun readList() = readLn().split(' ')
private var tokenizer = StringTokenizer("")
private fun read(): String {
    while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(readLn(), " ")
    return tokenizer.nextToken()
}

private fun readInt() = read().toInt()
private fun readLong() = read().toLong()
private fun readDouble() = read().toDouble()

private fun readIntList() = readList().map { it.toInt() }
private fun readLongList() = readList().map { it.toLong() }
private fun readDoubleList() = readList().map { it.toDouble() }

private fun readIntArray(n: Int = 0) =
    if (n == 0) readList().run { IntArray(size) { get(it).toInt() } } else IntArray(n) { readInt() }

private fun readLongArray(n: Int = 0) =
    if (n == 0) readList().run { LongArray(size) { get(it).toLong() } } else LongArray(n) { readLong() }

private fun readDoubleArray(n: Int = 0) =
    if (n == 0) readList().run { DoubleArray(size) { get(it).toDouble() } } else DoubleArray(n) { readDouble() }

private fun Int.modPositive(other: Int): Int = if (this % other < 0) ((this % other) + other) else (this % other)

private class `CF265-D2-A` {
    fun solveTestCase(): Int {
        val s = read()
        val t = read()
        var pos = 0

        t.forEach {
            if (s[pos] == it)  {
                pos++
            }
        }

        return pos + 1
    }
}

fun main(args: Array<String>) {

    outputWriter.println(
        `CF265-D2-A`()
            .solveTestCase()
    )

    outputWriter.flush()
}

fun main() = Pair(readLine()!!, readLine()!!)
    .let { (stones, instructions) ->
        var currentPosition = 0
        for (instructionIndex in 0..instructions.lastIndex) {
            if (instructions[instructionIndex] == stones[currentPosition]) {
                currentPosition++
            }
        }
        currentPosition
    }
    .let(Int::inc)
    .run(::println)

import java.util.Scanner;
import java.util.Arrays;
import java.util.*;
import java.math.*;
import java.io.*;

fun main(args: Array<String>) {
 val s = Scanner(System.`in`)
 val postion = s.next();
 val instrution = s.next();
 colorstone(postion,instrution)
}
fun colorstone (postion : String ,instrution : String ){

val postions = postion.toCharArray();
val instrutions = instrution.toCharArray();
var counter = 1

 for(i in instrutions.indices){
if(postion[counter-1] == instrutions[i]){
    counter++
}
}
print(counter)
}