// 2022.07.31 at 20:35:58 HKT
import java.io.BufferedInputStream
import java.io.File
import java.io.PrintWriter
import kotlin.system.measureTimeMillis
import java.util.TreeMap
import java.util.TreeSet
import kotlin.random.Random
import kotlin.random.nextInt

// 1. Modded
const val p = 1000000007L
const val pI = p.toInt()
fun Int.adjust():Int{ if(this >= pI){ return this  - pI }else if (this < 0){ return this + pI };return this }
fun Int.snap():Int{ if(this >= pI){return this - pI} else return this}
infix fun Int.modM(b:Int):Int{ return ((this.toLong() * b) % pI).toInt() }
infix fun Int.modPlus(b:Int):Int{ val ans = this + b;return if(ans >= pI) ans - pI else ans }
fun intPow(x:Int,e:Int,m:Int):Int{
    var X = x ; var E =e ; var Y = 1
    while(E > 0){
        if(E and 1 == 0){
            X = ((1L * X * X) % m).toInt()
            E = E shr 1
        }else{
            Y = ((1L * X * Y) % m).toInt()
            E -= 1
        }
    }
    return Y
}
// 2. DP initial values
const val plarge = 1_000_000_727
const val nlarge = -plarge
const val phuge = 2_727_000_000_000_000_000L
const val nhuge = -phuge
// 3. conveniecen conversions
val Boolean.chi:Int get() = if(this) 1 else 0 //characteristic function
val BooleanArray.chiarray:IntArray get() = IntArray(this.size){this[it].chi}
val Char.code :Int get() = this.toInt() -  'a'.toInt()
//3. hard to write stuff
fun IntArray.put(i:Int,v:Int){ this[i] = (this[i] + v).adjust() }
val mint:MutableList<Int> get() = mutableListOf<Int>()
val mong:MutableList<Long> get() = mutableListOf<Long>()
//4. more outputs
fun List<Char>.conca():String = this.joinToString("")
val CharArray.conca :String get() = this.joinToString("")
val IntArray.conca :String get() = this.joinToString(" ")
@JvmName("concaInt")
fun List<Int>.conca():String = this.joinToString(" ")
val LongArray.conca:String get() = this.joinToString(" ")
@JvmName("concaLong")
fun List<Long>.conca():String = this.joinToString(" ")
//5. Pair of ints
const val longmask = (1L shl 32) - 1
fun makepair(a:Int, b:Int):Long = (a.toLong() shl 32) xor (longmask and b.toLong()) // remember positev sonly
val Long.first get() = (this ushr 32).toInt()
val Long.second get() = this.toInt()
//6. strings
val String.size get() = this.length
const val randCount = 100
//7. bits
fun Int.has(i:Int):Boolean = (this and (1 shl i) != 0)
fun Long.has(i:Int):Boolean = (this and (1L shl i) != 0L)
//8 TIME
inline fun TIME(f:()->Unit){
    val t = measureTimeMillis(){
        f()
    }
    println("$t ms")
}
//9.ordered pair
fun order(a:Int, b:Int):Pair<Int,Int>{
    return Pair(minOf(a,b), maxOf(a,b))
}
object Reader{
    private const val BS = 1 shl 16
    private const val NC = 0.toChar()
    private val buf = ByteArray(BS)
    private var bId = 0
    private var size = 0
    private var c = NC

    var warningActive = true
    var fakein = StringBuilder()

    private var IN: BufferedInputStream = BufferedInputStream(System.`in`, BS)
    val OUT: PrintWriter = PrintWriter(System.out)

    private val char: Char
        get() {
            while (bId == size) {
                size = IN.read(buf) // no need for checked exceptions
                if (size == -1) return NC
                bId = 0
            }
            return buf[bId++].toChar()
        }

    fun nextInt(): Int {
        var neg = false
        if (c == NC) c = char
        while (c < '0' || c > '9') {
            if (c == '-') neg = true
            c = char
        }
        var res = 0
        while (c in '0'..'9') {
            res = (res shl 3) + (res shl 1) + (c - '0')
            c = char
        }
        return if (neg) -res else res
    }
    fun nextLong(): Long {
        var neg = false
        if (c == NC) c = char
        while (c < '0' || c > '9') {
            if (c == '-') neg = true
            c = char
        }
        var res = 0L
        while (c in '0'..'9') {
            res = (res shl 3) + (res shl 1) + (c - '0')
            c = char
        }
        return if (neg) -res else res
    }
    fun nextString():String{
        val ret = StringBuilder()
        while (true){
            c = char
            if(!isWhitespace(c)){ break}
        }
        ret.append(c)
        while (true){
            c = char
            if(isWhitespace(c)){ break}
            ret.append(c)
        }
        return ret.toString()
    }
    fun isWhitespace(c:Char):Boolean{
        return c == ' ' || c == '\n' || c == '\r' || c == '\t'
    }
    fun rerouteInput(){
        if(warningActive){
            put("Custom test enabled")
            println("Custom test enabled")
            warningActive = false
        }
        val S = fakein.toString()
        println("New Case ")
        println(S.take(80))
        println("...")
        fakein.clear()
        IN = BufferedInputStream(S.byteInputStream(),BS)
    }
    fun takeFile(name:String){
        IN = BufferedInputStream(File(name).inputStream(),BS)
    }
}
fun put(aa:Any){ Reader.OUT.println(aa)}
fun done(){ Reader.OUT.close() }
fun share(aa:Any){
    if(aa is IntArray){Reader.fakein.append(aa.joinToString(" "))}
    else if(aa is LongArray){Reader.fakein.append(aa.joinToString(" "))}
    else if(aa is List<*>){Reader.fakein.append(aa.toString())}
    else{Reader.fakein.append(aa.toString())}
    Reader.fakein.append("\n")
}

val getintfast:Int get() = Reader.nextInt()
val getint:Int get(){ val ans = getlong ; if(ans > Int.MAX_VALUE) IntArray(1000000000); return ans.toInt() }
val getlong:Long get() = Reader.nextLong()
val getstr:String get() = Reader.nextString()
fun getline(n:Int):IntArray{
    return IntArray(n){getint}
}
fun getlineL(n:Int):LongArray{
    return LongArray(n){getlong}
}
var dmark = -1
infix fun Any.dei(a:Any){
    dmark++
    var str = "<${dmark}>   "
    debug()
    if(this is String){ str += this
    }else if(this is Int){ str += this.toString()
    }else if(this is Long){ str += this.toString()
    }else{ str += this.toString()}
    if(a is List<*>){ println("$str : ${a.joinToString(" ")}")
    }else if(a is IntArray){ println("$str : ${a.joinToString(" ")}")
    }else if(a is LongArray){ println("$str : ${a.joinToString(" ")}")
    }else if(a is BooleanArray){ println("$str :${a.map{if(it)'1' else '0'}.joinToString(" ")}")
    }else if(a is Array<*>){
        println("$str : ")
        for(c in a){if(c is IntArray){println(c.joinToString(" "))}
        else if(c is LongArray){println(c.joinToString(" "))}
        else if(c is BooleanArray){println(c.map { if(it) '1' else '0' }.joinToString(""))
        }
        }
        println()
    }else{ println("$str : $a")
    }
}
val just = " "
fun crash(){
    throw Exception("Bad programme")}
fun assert(a:Boolean){
    if(!a){
        throw Exception("Failed Assertion")
    }}
enum class solveMode {
    real, rand, tc
}
object solve{
    var mode:solveMode = solveMode.real
    var tcNum:Int = 0
    var rand:()->Unit = {}
    var TC:MutableMap<Int,()->Unit> = mutableMapOf()
    var tn:Long = 0
    fun cases(onecase:()->Unit){
        val t = if(mode == solveMode.real){if(singleCase) 1 else getint} else if(mode == solveMode.tc){1 } else randCount
        if(pI != 998_244_353 && pI != 1_000_000_007){
            throw Exception("Not usual primes!")
        }
        if(t == 1 && mode != solveMode.real){
            tn = System.currentTimeMillis()
        }
        repeat(t){
            if(mode == solveMode.tc){
                TC[tcNum]?.let { it() }
                Reader.rerouteInput()
            }else if(mode == solveMode.rand){
                rand()
                Reader.rerouteInput()
            }
            onecase()
        }
        if(t == 1 && mode != solveMode.real){
            val dt = System.currentTimeMillis() - tn
            println("Time $dt ms ")
        }
    }
    inline fun singleCase(a:solve.()->Unit){
        val t = if(mode != solveMode.rand){1} else randCount
        repeat(t) { a() }
    }
    fun rand(a:()->Unit){
        this.rand = a
    }
    fun tc(id:Int = 0,a:()->Unit){
        TC[id] = a
    }
    fun usetc(a:Int = 0 ){
        this.tcNum = a
        this.mode = solveMode.tc
    }
    fun userand(){
        this.mode = solveMode.rand
    }
}

fun debug(){}
const val singleCase = true
fun main(){
    solve.cases{
        val n = getint
        val m = getint
        var base = (n-1) * m.toLong() + 1

        val arr = BooleanArray((m+1) * 20)
        var taken = 0
        val ret = IntArray(21)
        for(level in 1..20){
            for(i in level..level * m step level){
                if(arr[i] == false){
                    arr[i] = true
                    taken ++
                }
            }
            ret[level] = taken
        }
        for(p in 2..n){

            var now  =1
            var maxp = 0
            while(now * p.toLong() <= n){
                now *= p
                maxp ++
            }
            val distinct = maxp.toLong() * m
            val actual = ret[maxp]
            base -= distinct
            base += actual
        }
        put(base)

    }
    done()
}

/*
1 1
2 4
3 9
4 16

1000000 1000000
 */


// 2022.07.31 at 20:35:58 HKT
import java.io.BufferedInputStream
import java.io.File
import java.io.PrintWriter
import kotlin.system.measureTimeMillis
import java.util.TreeMap
import java.util.TreeSet
import kotlin.random.Random
import kotlin.random.nextInt

// 1. Modded
const val p = 1000000007L
const val pI = p.toInt()
fun Int.adjust():Int{ if(this >= pI){ return this  - pI }else if (this < 0){ return this + pI };return this }
fun Int.snap():Int{ if(this >= pI){return this - pI} else return this}
infix fun Int.modM(b:Int):Int{ return ((this.toLong() * b) % pI).toInt() }
infix fun Int.modPlus(b:Int):Int{ val ans = this + b;return if(ans >= pI) ans - pI else ans }
fun intPow(x:Int,e:Int,m:Int):Int{
    var X = x ; var E =e ; var Y = 1
    while(E > 0){
        if(E and 1 == 0){
            X = ((1L * X * X) % m).toInt()
            E = E shr 1
        }else{
            Y = ((1L * X * Y) % m).toInt()
            E -= 1
        }
    }
    return Y
}
// 2. DP initial values
const val plarge = 1_000_000_727
const val nlarge = -plarge
const val phuge = 2_727_000_000_000_000_000L
const val nhuge = -phuge
// 3. conveniecen conversions
val Boolean.chi:Int get() = if(this) 1 else 0 //characteristic function
val BooleanArray.chiarray:IntArray get() = IntArray(this.size){this[it].chi}
val Char.code :Int get() = this.toInt() -  'a'.toInt()
//3. hard to write stuff
fun IntArray.put(i:Int,v:Int){ this[i] = (this[i] + v).adjust() }
val mint:MutableList<Int> get() = mutableListOf<Int>()
val mong:MutableList<Long> get() = mutableListOf<Long>()
//4. more outputs
fun List<Char>.conca():String = this.joinToString("")
val CharArray.conca :String get() = this.joinToString("")
val IntArray.conca :String get() = this.joinToString(" ")
@JvmName("concaInt")
fun List<Int>.conca():String = this.joinToString(" ")
val LongArray.conca:String get() = this.joinToString(" ")
@JvmName("concaLong")
fun List<Long>.conca():String = this.joinToString(" ")
//5. Pair of ints
const val longmask = (1L shl 32) - 1
fun makepair(a:Int, b:Int):Long = (a.toLong() shl 32) xor (longmask and b.toLong()) // remember positev sonly
val Long.first get() = (this ushr 32).toInt()
val Long.second get() = this.toInt()
//6. strings
val String.size get() = this.length
const val randCount = 100
//7. bits
fun Int.has(i:Int):Boolean = (this and (1 shl i) != 0)
fun Long.has(i:Int):Boolean = (this and (1L shl i) != 0L)
//8 TIME
inline fun TIME(f:()->Unit){
    val t = measureTimeMillis(){
        f()
    }
    println("$t ms")
}
//9.ordered pair
fun order(a:Int, b:Int):Pair<Int,Int>{
    return Pair(minOf(a,b), maxOf(a,b))
}
object Reader{
    private const val BS = 1 shl 16
    private const val NC = 0.toChar()
    private val buf = ByteArray(BS)
    private var bId = 0
    private var size = 0
    private var c = NC

    var warningActive = true
    var fakein = StringBuilder()

    private var IN: BufferedInputStream = BufferedInputStream(System.`in`, BS)
    val OUT: PrintWriter = PrintWriter(System.out)

    private val char: Char
        get() {
            while (bId == size) {
                size = IN.read(buf) // no need for checked exceptions
                if (size == -1) return NC
                bId = 0
            }
            return buf[bId++].toChar()
        }

    fun nextInt(): Int {
        var neg = false
        if (c == NC) c = char
        while (c < '0' || c > '9') {
            if (c == '-') neg = true
            c = char
        }
        var res = 0
        while (c in '0'..'9') {
            res = (res shl 3) + (res shl 1) + (c - '0')
            c = char
        }
        return if (neg) -res else res
    }
    fun nextLong(): Long {
        var neg = false
        if (c == NC) c = char
        while (c < '0' || c > '9') {
            if (c == '-') neg = true
            c = char
        }
        var res = 0L
        while (c in '0'..'9') {
            res = (res shl 3) + (res shl 1) + (c - '0')
            c = char
        }
        return if (neg) -res else res
    }
    fun nextString():String{
        val ret = StringBuilder()
        while (true){
            c = char
            if(!isWhitespace(c)){ break}
        }
        ret.append(c)
        while (true){
            c = char
            if(isWhitespace(c)){ break}
            ret.append(c)
        }
        return ret.toString()
    }
    fun isWhitespace(c:Char):Boolean{
        return c == ' ' || c == '\n' || c == '\r' || c == '\t'
    }
    fun rerouteInput(){
        if(warningActive){
            put("Custom test enabled")
            println("Custom test enabled")
            warningActive = false
        }
        val S = fakein.toString()
        println("New Case ")
        println(S.take(80))
        println("...")
        fakein.clear()
        IN = BufferedInputStream(S.byteInputStream(),BS)
    }
    fun takeFile(name:String){
        IN = BufferedInputStream(File(name).inputStream(),BS)
    }
}
fun put(aa:Any){ Reader.OUT.println(aa)}
fun done(){ Reader.OUT.close() }
fun share(aa:Any){
    if(aa is IntArray){Reader.fakein.append(aa.joinToString(" "))}
    else if(aa is LongArray){Reader.fakein.append(aa.joinToString(" "))}
    else if(aa is List<*>){Reader.fakein.append(aa.toString())}
    else{Reader.fakein.append(aa.toString())}
    Reader.fakein.append("\n")
}

val getintfast:Int get() = Reader.nextInt()
val getint:Int get(){ val ans = getlong ; if(ans > Int.MAX_VALUE) IntArray(1000000000); return ans.toInt() }
val getlong:Long get() = Reader.nextLong()
val getstr:String get() = Reader.nextString()
fun getline(n:Int):IntArray{
    return IntArray(n){getint}
}
fun getlineL(n:Int):LongArray{
    return LongArray(n){getlong}
}
var dmark = -1
infix fun Any.dei(a:Any){
    dmark++
    var str = "<${dmark}>   "
    debug()
    if(this is String){ str += this
    }else if(this is Int){ str += this.toString()
    }else if(this is Long){ str += this.toString()
    }else{ str += this.toString()}
    if(a is List<*>){ println("$str : ${a.joinToString(" ")}")
    }else if(a is IntArray){ println("$str : ${a.joinToString(" ")}")
    }else if(a is LongArray){ println("$str : ${a.joinToString(" ")}")
    }else if(a is BooleanArray){ println("$str :${a.map{if(it)'1' else '0'}.joinToString(" ")}")
    }else if(a is Array<*>){
        println("$str : ")
        for(c in a){if(c is IntArray){println(c.joinToString(" "))}
        else if(c is LongArray){println(c.joinToString(" "))}
        else if(c is BooleanArray){println(c.map { if(it) '1' else '0' }.joinToString(""))
        }
        }
        println()
    }else{ println("$str : $a")
    }
}
val just = " "
fun crash(){
    throw Exception("Bad programme")}
fun assert(a:Boolean){
    if(!a){
        throw Exception("Failed Assertion")
    }}
enum class solveMode {
    real, rand, tc
}
object solve{
    var mode:solveMode = solveMode.real
    var tcNum:Int = 0
    var rand:()->Unit = {}
    var TC:MutableMap<Int,()->Unit> = mutableMapOf()
    var tn:Long = 0
    fun cases(onecase:()->Unit){
        val t = if(mode == solveMode.real){if(singleCase) 1 else getint} else if(mode == solveMode.tc){1 } else randCount
        if(pI != 998_244_353 && pI != 1_000_000_007){
            throw Exception("Not usual primes!")
        }
        if(t == 1 && mode != solveMode.real){
            tn = System.currentTimeMillis()
        }
        repeat(t){
            if(mode == solveMode.tc){
                TC[tcNum]?.let { it() }
                Reader.rerouteInput()
            }else if(mode == solveMode.rand){
                rand()
                Reader.rerouteInput()
            }
            onecase()
        }
        if(t == 1 && mode != solveMode.real){
            val dt = System.currentTimeMillis() - tn
            println("Time $dt ms ")
        }
    }
    inline fun singleCase(a:solve.()->Unit){
        val t = if(mode != solveMode.rand){1} else randCount
        repeat(t) { a() }
    }
    fun rand(a:()->Unit){
        this.rand = a
    }
    fun tc(id:Int = 0,a:()->Unit){
        TC[id] = a
    }
    fun usetc(a:Int = 0 ){
        this.tcNum = a
        this.mode = solveMode.tc
    }
    fun userand(){
        this.mode = solveMode.rand
    }
}

fun debug(){}
const val singleCase = true
fun main(){
    solve.cases{
        val n = getint
        val m = getint
        var base = (n-1) * m.toLong() + 1

        val arr = BooleanArray((m+1) * 20)
        var taken = 0
        val ret = IntArray(21)
        for(level in 1..20){
            for(i in level..level * m step level){
                if(arr[i] == false){
                    arr[i] = true
                    taken ++
                }
            }
            ret[level] = taken
        }
        val checked = BooleanArray(n+1)
        for(p in 2..n){

            if(checked[p]){
                 continue
            }
            var now  =1
            var maxp = 0
            while(now * p.toLong() <= n){
                now *= p
                checked[p] = true
                maxp ++
            }
            val distinct = maxp.toLong() * m
            val actual = ret[maxp]
            base -= distinct
            base += actual
        }
        put(base)

    }
    done()
}

/*
1 1
2 4
3 9
4 16

1000000 1000000
 */


// 2022.07.31 at 20:35:58 HKT
import java.io.BufferedInputStream
import java.io.File
import java.io.PrintWriter
import kotlin.system.measureTimeMillis
import java.util.TreeMap
import java.util.TreeSet
import kotlin.random.Random
import kotlin.random.nextInt

// 1. Modded
const val p = 1000000007L
const val pI = p.toInt()
fun Int.adjust():Int{ if(this >= pI){ return this  - pI }else if (this < 0){ return this + pI };return this }
fun Int.snap():Int{ if(this >= pI){return this - pI} else return this}
infix fun Int.modM(b:Int):Int{ return ((this.toLong() * b) % pI).toInt() }
infix fun Int.modPlus(b:Int):Int{ val ans = this + b;return if(ans >= pI) ans - pI else ans }
fun intPow(x:Int,e:Int,m:Int):Int{
    var X = x ; var E =e ; var Y = 1
    while(E > 0){
        if(E and 1 == 0){
            X = ((1L * X * X) % m).toInt()
            E = E shr 1
        }else{
            Y = ((1L * X * Y) % m).toInt()
            E -= 1
        }
    }
    return Y
}
// 2. DP initial values
const val plarge = 1_000_000_727
const val nlarge = -plarge
const val phuge = 2_727_000_000_000_000_000L
const val nhuge = -phuge
// 3. conveniecen conversions
val Boolean.chi:Int get() = if(this) 1 else 0 //characteristic function
val BooleanArray.chiarray:IntArray get() = IntArray(this.size){this[it].chi}
val Char.code :Int get() = this.toInt() -  'a'.toInt()
//3. hard to write stuff
fun IntArray.put(i:Int,v:Int){ this[i] = (this[i] + v).adjust() }
val mint:MutableList<Int> get() = mutableListOf<Int>()
val mong:MutableList<Long> get() = mutableListOf<Long>()
//4. more outputs
fun List<Char>.conca():String = this.joinToString("")
val CharArray.conca :String get() = this.joinToString("")
val IntArray.conca :String get() = this.joinToString(" ")
@JvmName("concaInt")
fun List<Int>.conca():String = this.joinToString(" ")
val LongArray.conca:String get() = this.joinToString(" ")
@JvmName("concaLong")
fun List<Long>.conca():String = this.joinToString(" ")
//5. Pair of ints
const val longmask = (1L shl 32) - 1
fun makepair(a:Int, b:Int):Long = (a.toLong() shl 32) xor (longmask and b.toLong()) // remember positev sonly
val Long.first get() = (this ushr 32).toInt()
val Long.second get() = this.toInt()
//6. strings
val String.size get() = this.length
const val randCount = 100
//7. bits
fun Int.has(i:Int):Boolean = (this and (1 shl i) != 0)
fun Long.has(i:Int):Boolean = (this and (1L shl i) != 0L)
//8 TIME
inline fun TIME(f:()->Unit){
    val t = measureTimeMillis(){
        f()
    }
    println("$t ms")
}
//9.ordered pair
fun order(a:Int, b:Int):Pair<Int,Int>{
    return Pair(minOf(a,b), maxOf(a,b))
}
object Reader{
    private const val BS = 1 shl 16
    private const val NC = 0.toChar()
    private val buf = ByteArray(BS)
    private var bId = 0
    private var size = 0
    private var c = NC

    var warningActive = true
    var fakein = StringBuilder()

    private var IN: BufferedInputStream = BufferedInputStream(System.`in`, BS)
    val OUT: PrintWriter = PrintWriter(System.out)

    private val char: Char
        get() {
            while (bId == size) {
                size = IN.read(buf) // no need for checked exceptions
                if (size == -1) return NC
                bId = 0
            }
            return buf[bId++].toChar()
        }

    fun nextInt(): Int {
        var neg = false
        if (c == NC) c = char
        while (c < '0' || c > '9') {
            if (c == '-') neg = true
            c = char
        }
        var res = 0
        while (c in '0'..'9') {
            res = (res shl 3) + (res shl 1) + (c - '0')
            c = char
        }
        return if (neg) -res else res
    }
    fun nextLong(): Long {
        var neg = false
        if (c == NC) c = char
        while (c < '0' || c > '9') {
            if (c == '-') neg = true
            c = char
        }
        var res = 0L
        while (c in '0'..'9') {
            res = (res shl 3) + (res shl 1) + (c - '0')
            c = char
        }
        return if (neg) -res else res
    }
    fun nextString():String{
        val ret = StringBuilder()
        while (true){
            c = char
            if(!isWhitespace(c)){ break}
        }
        ret.append(c)
        while (true){
            c = char
            if(isWhitespace(c)){ break}
            ret.append(c)
        }
        return ret.toString()
    }
    fun isWhitespace(c:Char):Boolean{
        return c == ' ' || c == '\n' || c == '\r' || c == '\t'
    }
    fun rerouteInput(){
        if(warningActive){
            put("Custom test enabled")
            println("Custom test enabled")
            warningActive = false
        }
        val S = fakein.toString()
        println("New Case ")
        println(S.take(80))
        println("...")
        fakein.clear()
        IN = BufferedInputStream(S.byteInputStream(),BS)
    }
    fun takeFile(name:String){
        IN = BufferedInputStream(File(name).inputStream(),BS)
    }
}
fun put(aa:Any){ Reader.OUT.println(aa)}
fun done(){ Reader.OUT.close() }
fun share(aa:Any){
    if(aa is IntArray){Reader.fakein.append(aa.joinToString(" "))}
    else if(aa is LongArray){Reader.fakein.append(aa.joinToString(" "))}
    else if(aa is List<*>){Reader.fakein.append(aa.toString())}
    else{Reader.fakein.append(aa.toString())}
    Reader.fakein.append("\n")
}

val getintfast:Int get() = Reader.nextInt()
val getint:Int get(){ val ans = getlong ; if(ans > Int.MAX_VALUE) IntArray(1000000000); return ans.toInt() }
val getlong:Long get() = Reader.nextLong()
val getstr:String get() = Reader.nextString()
fun getline(n:Int):IntArray{
    return IntArray(n){getint}
}
fun getlineL(n:Int):LongArray{
    return LongArray(n){getlong}
}
var dmark = -1
infix fun Any.dei(a:Any){
    dmark++
    var str = "<${dmark}>   "
    debug()
    if(this is String){ str += this
    }else if(this is Int){ str += this.toString()
    }else if(this is Long){ str += this.toString()
    }else{ str += this.toString()}
    if(a is List<*>){ println("$str : ${a.joinToString(" ")}")
    }else if(a is IntArray){ println("$str : ${a.joinToString(" ")}")
    }else if(a is LongArray){ println("$str : ${a.joinToString(" ")}")
    }else if(a is BooleanArray){ println("$str :${a.map{if(it)'1' else '0'}.joinToString(" ")}")
    }else if(a is Array<*>){
        println("$str : ")
        for(c in a){if(c is IntArray){println(c.joinToString(" "))}
        else if(c is LongArray){println(c.joinToString(" "))}
        else if(c is BooleanArray){println(c.map { if(it) '1' else '0' }.joinToString(""))
        }
        }
        println()
    }else{ println("$str : $a")
    }
}
val just = " "
fun crash(){
    throw Exception("Bad programme")}
fun assert(a:Boolean){
    if(!a){
        throw Exception("Failed Assertion")
    }}
enum class solveMode {
    real, rand, tc
}
object solve{
    var mode:solveMode = solveMode.real
    var tcNum:Int = 0
    var rand:()->Unit = {}
    var TC:MutableMap<Int,()->Unit> = mutableMapOf()
    var tn:Long = 0
    fun cases(onecase:()->Unit){
        val t = if(mode == solveMode.real){if(singleCase) 1 else getint} else if(mode == solveMode.tc){1 } else randCount
        if(pI != 998_244_353 && pI != 1_000_000_007){
            throw Exception("Not usual primes!")
        }
        if(t == 1 && mode != solveMode.real){
            tn = System.currentTimeMillis()
        }
        repeat(t){
            if(mode == solveMode.tc){
                TC[tcNum]?.let { it() }
                Reader.rerouteInput()
            }else if(mode == solveMode.rand){
                rand()
                Reader.rerouteInput()
            }
            onecase()
        }
        if(t == 1 && mode != solveMode.real){
            val dt = System.currentTimeMillis() - tn
            println("Time $dt ms ")
        }
    }
    inline fun singleCase(a:solve.()->Unit){
        val t = if(mode != solveMode.rand){1} else randCount
        repeat(t) { a() }
    }
    fun rand(a:()->Unit){
        this.rand = a
    }
    fun tc(id:Int = 0,a:()->Unit){
        TC[id] = a
    }
    fun usetc(a:Int = 0 ){
        this.tcNum = a
        this.mode = solveMode.tc
    }
    fun userand(){
        this.mode = solveMode.rand
    }
}

fun debug(){}
const val singleCase = true
fun main(){
    solve.cases{
        val n = getint
        val m = getint
        var base = (n-1) * m.toLong() + 1

        val arr = BooleanArray((m+1) * 20)
        var taken = 0
        val ret = IntArray(21)
        for(level in 1..20){
            for(i in level..level * m step level){
                if(arr[i] == false){
                    arr[i] = true
                    taken ++
                }
            }
            ret[level] = taken
        }
        val checked = BooleanArray(n+1)
        for(p in 2..n){

            if(checked[p]){
                 continue
            }
            var now  =1
            var maxp = 0
            while(now * p.toLong() <= n){
                now *= p
                checked[now] = true
                maxp ++
            }
            val distinct = maxp.toLong() * m
            val actual = ret[maxp]
            base -= distinct
            base += actual
        }
        put(base)

    }
    done()
}

/*
1 1
2 4
3 9
4 16

1000000 1000000
 */


import java.io.BufferedReader
import java.io.BufferedWriter

class ProblemE {
    private fun BufferedReader.readInt(): Int = this.readLine().toInt()
    private fun BufferedReader.readIntArray(delimiter: String = " ") =
        this.readLine().split(delimiter).map { it.toInt() }.toIntArray()

    private fun BufferedWriter.writeLine(s: String) {
        this.write(s)
        this.newLine()
    }

    private fun solveTest(input: BufferedReader, output: BufferedWriter) {
        val (n, m) = input.readIntArray()

        /***
         * x^(i*j) where 1 <=i <= log_x(k), 1 <= j <= m
         *               1 <= i <= 20, 1 <= j <= 1e6
         *
         */
        val numDistinctPowers = IntArray(22)
        var numUnique = 0
        val visited = BooleanArray(22*(m +1))
        for(i in 1 until numDistinctPowers.size) {
            for(j in 1..m) {
                if(!visited[i*j]) {
                    visited[i*j] = true
                    numUnique+=1
                }
            }
            numDistinctPowers[i] = numUnique
        }
        val isAPower = BooleanArray(n +1)
        var numDistinct = 1L
        for(x in 2..n) {
            if(!isAPower[x]) {
                var powerCount = 0
                var j = x.toLong()
                while(j <= n) {
                    isAPower[j.toInt()] = true
                    powerCount += 1
                    j *= x
                }
                numDistinct+= numDistinctPowers[powerCount]
            }
        }
        output.writeLine(numDistinct.toString())
    }

    fun solve(input: BufferedReader, output: BufferedWriter) {
        solveTest(input, output)
        input.close()
        output.close()
    }

}

fun main() {
    val solution = ProblemE()
    solution.solve(System.`in`.bufferedReader(), System.out.bufferedWriter())
}


// 2022.07.31 at 20:35:58 HKT
import java.io.BufferedInputStream
import java.io.File
import java.io.PrintWriter
import kotlin.system.measureTimeMillis
import java.util.TreeMap
import java.util.TreeSet
import kotlin.random.Random
import kotlin.random.nextInt

// 1. Modded
const val p = 1000000007L
const val pI = p.toInt()
fun Int.adjust():Int{ if(this >= pI){ return this  - pI }else if (this < 0){ return this + pI };return this }
fun Int.snap():Int{ if(this >= pI){return this - pI} else return this}
infix fun Int.modM(b:Int):Int{ return ((this.toLong() * b) % pI).toInt() }
infix fun Int.modPlus(b:Int):Int{ val ans = this + b;return if(ans >= pI) ans - pI else ans }
fun intPow(x:Int,e:Int,m:Int):Int{
    var X = x ; var E =e ; var Y = 1
    while(E > 0){
        if(E and 1 == 0){
            X = ((1L * X * X) % m).toInt()
            E = E shr 1
        }else{
            Y = ((1L * X * Y) % m).toInt()
            E -= 1
        }
    }
    return Y
}
// 2. DP initial values
const val plarge = 1_000_000_727
const val nlarge = -plarge
const val phuge = 2_727_000_000_000_000_000L
const val nhuge = -phuge
// 3. conveniecen conversions
val Boolean.chi:Int get() = if(this) 1 else 0 //characteristic function
val BooleanArray.chiarray:IntArray get() = IntArray(this.size){this[it].chi}
val Char.code :Int get() = this.toInt() -  'a'.toInt()
//3. hard to write stuff
fun IntArray.put(i:Int,v:Int){ this[i] = (this[i] + v).adjust() }
val mint:MutableList<Int> get() = mutableListOf<Int>()
val mong:MutableList<Long> get() = mutableListOf<Long>()
//4. more outputs
fun List<Char>.conca():String = this.joinToString("")
val CharArray.conca :String get() = this.joinToString("")
val IntArray.conca :String get() = this.joinToString(" ")
@JvmName("concaInt")
fun List<Int>.conca():String = this.joinToString(" ")
val LongArray.conca:String get() = this.joinToString(" ")
@JvmName("concaLong")
fun List<Long>.conca():String = this.joinToString(" ")
//5. Pair of ints
const val longmask = (1L shl 32) - 1
fun makepair(a:Int, b:Int):Long = (a.toLong() shl 32) xor (longmask and b.toLong()) // remember positev sonly
val Long.first get() = (this ushr 32).toInt()
val Long.second get() = this.toInt()
//6. strings
val String.size get() = this.length
const val randCount = 100
//7. bits
fun Int.has(i:Int):Boolean = (this and (1 shl i) != 0)
fun Long.has(i:Int):Boolean = (this and (1L shl i) != 0L)
//8 TIME
inline fun TIME(f:()->Unit){
    val t = measureTimeMillis(){
        f()
    }
    println("$t ms")
}
//9.ordered pair
fun order(a:Int, b:Int):Pair<Int,Int>{
    return Pair(minOf(a,b), maxOf(a,b))
}
object Reader{
    private const val BS = 1 shl 16
    private const val NC = 0.toChar()
    private val buf = ByteArray(BS)
    private var bId = 0
    private var size = 0
    private var c = NC

    var warningActive = true
    var fakein = StringBuilder()

    private var IN: BufferedInputStream = BufferedInputStream(System.`in`, BS)
    val OUT: PrintWriter = PrintWriter(System.out)

    private val char: Char
        get() {
            while (bId == size) {
                size = IN.read(buf) // no need for checked exceptions
                if (size == -1) return NC
                bId = 0
            }
            return buf[bId++].toChar()
        }

    fun nextInt(): Int {
        var neg = false
        if (c == NC) c = char
        while (c < '0' || c > '9') {
            if (c == '-') neg = true
            c = char
        }
        var res = 0
        while (c in '0'..'9') {
            res = (res shl 3) + (res shl 1) + (c - '0')
            c = char
        }
        return if (neg) -res else res
    }
    fun nextLong(): Long {
        var neg = false
        if (c == NC) c = char
        while (c < '0' || c > '9') {
            if (c == '-') neg = true
            c = char
        }
        var res = 0L
        while (c in '0'..'9') {
            res = (res shl 3) + (res shl 1) + (c - '0')
            c = char
        }
        return if (neg) -res else res
    }
    fun nextString():String{
        val ret = StringBuilder()
        while (true){
            c = char
            if(!isWhitespace(c)){ break}
        }
        ret.append(c)
        while (true){
            c = char
            if(isWhitespace(c)){ break}
            ret.append(c)
        }
        return ret.toString()
    }
    fun isWhitespace(c:Char):Boolean{
        return c == ' ' || c == '\n' || c == '\r' || c == '\t'
    }
    fun rerouteInput(){
        if(warningActive){
            put("Custom test enabled")
            println("Custom test enabled")
            warningActive = false
        }
        val S = fakein.toString()
        println("New Case ")
        println(S.take(80))
        println("...")
        fakein.clear()
        IN = BufferedInputStream(S.byteInputStream(),BS)
    }
    fun takeFile(name:String){
        IN = BufferedInputStream(File(name).inputStream(),BS)
    }
}
fun put(aa:Any){ Reader.OUT.println(aa)}
fun done(){ Reader.OUT.close() }
fun share(aa:Any){
    if(aa is IntArray){Reader.fakein.append(aa.joinToString(" "))}
    else if(aa is LongArray){Reader.fakein.append(aa.joinToString(" "))}
    else if(aa is List<*>){Reader.fakein.append(aa.toString())}
    else{Reader.fakein.append(aa.toString())}
    Reader.fakein.append("\n")
}

val getintfast:Int get() = Reader.nextInt()
val getint:Int get(){ val ans = getlong ; if(ans > Int.MAX_VALUE) IntArray(1000000000); return ans.toInt() }
val getlong:Long get() = Reader.nextLong()
val getstr:String get() = Reader.nextString()
fun getline(n:Int):IntArray{
    return IntArray(n){getint}
}
fun getlineL(n:Int):LongArray{
    return LongArray(n){getlong}
}
var dmark = -1
infix fun Any.dei(a:Any){
    dmark++
    var str = "<${dmark}>   "
    debug()
    if(this is String){ str += this
    }else if(this is Int){ str += this.toString()
    }else if(this is Long){ str += this.toString()
    }else{ str += this.toString()}
    if(a is List<*>){ println("$str : ${a.joinToString(" ")}")
    }else if(a is IntArray){ println("$str : ${a.joinToString(" ")}")
    }else if(a is LongArray){ println("$str : ${a.joinToString(" ")}")
    }else if(a is BooleanArray){ println("$str :${a.map{if(it)'1' else '0'}.joinToString(" ")}")
    }else if(a is Array<*>){
        println("$str : ")
        for(c in a){if(c is IntArray){println(c.joinToString(" "))}
        else if(c is LongArray){println(c.joinToString(" "))}
        else if(c is BooleanArray){println(c.map { if(it) '1' else '0' }.joinToString(""))
        }
        }
        println()
    }else{ println("$str : $a")
    }
}
val just = " "
fun crash(){
    throw Exception("Bad programme")}
fun assert(a:Boolean){
    if(!a){
        throw Exception("Failed Assertion")
    }}
enum class solveMode {
    real, rand, tc
}
object solve{
    var mode:solveMode = solveMode.real
    var tcNum:Int = 0
    var rand:()->Unit = {}
    var TC:MutableMap<Int,()->Unit> = mutableMapOf()
    var tn:Long = 0
    fun cases(onecase:()->Unit){
        val t = if(mode == solveMode.real){if(singleCase) 1 else getint} else if(mode == solveMode.tc){1 } else randCount
        if(pI != 998_244_353 && pI != 1_000_000_007){
            throw Exception("Not usual primes!")
        }
        if(t == 1 && mode != solveMode.real){
            tn = System.currentTimeMillis()
        }
        repeat(t){
            if(mode == solveMode.tc){
                TC[tcNum]?.let { it() }
                Reader.rerouteInput()
            }else if(mode == solveMode.rand){
                rand()
                Reader.rerouteInput()
            }
            onecase()
        }
        if(t == 1 && mode != solveMode.real){
            val dt = System.currentTimeMillis() - tn
            println("Time $dt ms ")
        }
    }
    inline fun singleCase(a:solve.()->Unit){
        val t = if(mode != solveMode.rand){1} else randCount
        repeat(t) { a() }
    }
    fun rand(a:()->Unit){
        this.rand = a
    }
    fun tc(id:Int = 0,a:()->Unit){
        TC[id] = a
    }
    fun usetc(a:Int = 0 ){
        this.tcNum = a
        this.mode = solveMode.tc
    }
    fun userand(){
        this.mode = solveMode.rand
    }
}

fun debug(){}
const val singleCase = true
fun main(){
    solve.cases{
        val n = getint
        val m = getint
        var base = (n-1) * m.toLong() + 1

        val arr = BooleanArray((m+1) * 20)
        var taken = 0
        val ret = IntArray(21)
        for(level in 1..20){
            for(i in level..level * m step level){
                if(arr[i] == false){
                    arr[i] = true
                    taken ++
                }
            }
            ret[level] = taken
        }
        for(p in 2..n){

            var now  =1
            var maxp = 0
            while(now * p <= n){
                now *= p
                maxp ++
            }
            val distinct = maxp.toLong() * m
            val actual = ret[maxp]
            base -= distinct
            base += actual
        }
        put(base)

    }
    done()
}

/*
1 1
2 4
3 9
4 16
 */


import jdk.nashorn.internal.runtime.JSType.toLong
import sun.security.jgss.GSSToken.readInt
import java.util.*
import kotlin.math.sqrt

fun main(args : Array<String>){
    val o=Scanner(System.`in`)
 var n=0
  var a= o.nextInt()
    var k=true
  if(a%2==1){

      if(  fun1(a)==true){
          print("1")
      }else{

          if(fun1(a-2)==true){
              print("2")
          }else{
              print("3")
          }
      }
  }else{
      if(n==2){
          print("1")
      }else{
          print("2")
      }
  }

}

fun fun1(a:Int): Boolean {
    var k= sqrt(a.toDouble())
    for(i in 2..k.toInt()){
        if(a%i==0){
           // print("$i")
            return false;
        }
    }
    return true;
}


import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*
import java.util.Collections.min
import kotlin.math.min

fun main() {
    val r = FastReader()
    val n = r.nextInt()
    print(solve(n))

}

fun isp(m:Int): Int {
    var i : Int= 2
    while(i * i <= m){
        if(m % i == 0){
            return (m / i)
        }
        i ++
    }
    return 1
}

fun solve(n:Int):Int{
    var k = isp(n)
    if(k < 3) return k
    var m = n-1
    while(isp(m) != 1){
        m --
    }
    //println(m)
    return 1 +solve( n - m)

}
@Suppress("MemberVisibilityCanBePrivate")
internal class FastReader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    private var tokenizer: StringTokenizer? = null

    operator fun next(): String {
        var t = tokenizer
        while (t == null || !t.hasMoreElements())
            t = StringTokenizer(br.readLine())
        tokenizer = t
        return t.nextToken()
    }

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

    fun nextLong(): Long = next().toLong()

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

    fun nextLine(): String = br.readLine()

    fun nextIntArr(n: Int): IntArray = IntArray(n) { nextInt() }

    fun nextDoubleArr(n: Int): DoubleArray = DoubleArray(n) { nextDouble() }

    fun nextLongArr(n: Int): LongArray = LongArray(n) { nextLong() }

    fun nextIntArr2(n: Int, m: Int): Array<IntArray> = Array(n) { IntArray(m) { nextInt() } }

    fun nextLongArr2(n: Int, m: Int): Array<LongArray> = Array(n) { LongArray(m) { nextLong() } }
}


import jdk.nashorn.internal.runtime.JSType.toLong
import sun.security.jgss.GSSToken.readInt
import java.util.*
import kotlin.math.sqrt

fun main(args : Array<String>){
    val o=Scanner(System.`in`)
 var n=0
  var a= o.nextInt()
    var k=true
  if(a%2==1){

      if(  fun1(a)==true){
          print("1")
      }else{

          if(fun1(a-2)==true){
              print("2")
          }else{
              print("3")
          }
      }
  }else{
      if(a==2){
          print("1")
      }else{
          print("2")
      }
  }

}

fun fun1(a:Int): Boolean {
    var k= sqrt(a.toDouble())
    for(i in 2..k.toInt()){
        if(a%i==0){
           // print("$i")
            return false;
        }
    }
    return true;
}


import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*
import java.util.Collections.min
import kotlin.math.min

fun main() {
    val r = FastReader()
    val n = r.nextInt()
    print(solve(n))

}

fun isp(m:Int): Int {
    var i : Int= 2
    while(i * i <= m){
        if(m % i == 0){
            return 0
        }
        i ++
    }
    return 1
}

fun solve(n:Int):Int{
    var k = isp(n)
    if(k == 1) return k
    if(n%2 == 0) return 2
    if(isp(n-2) == 1) return 2
    return 3
}
@Suppress("MemberVisibilityCanBePrivate")
internal class FastReader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    private var tokenizer: StringTokenizer? = null

    operator fun next(): String {
        var t = tokenizer
        while (t == null || !t.hasMoreElements())
            t = StringTokenizer(br.readLine())
        tokenizer = t
        return t.nextToken()
    }

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

    fun nextLong(): Long = next().toLong()

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

    fun nextLine(): String = br.readLine()

    fun nextIntArr(n: Int): IntArray = IntArray(n) { nextInt() }

    fun nextDoubleArr(n: Int): DoubleArray = DoubleArray(n) { nextDouble() }

    fun nextLongArr(n: Int): LongArray = LongArray(n) { nextLong() }

    fun nextIntArr2(n: Int, m: Int): Array<IntArray> = Array(n) { IntArray(m) { nextInt() } }

    fun nextLongArr2(n: Int, m: Int): Array<LongArray> = Array(n) { LongArray(m) { nextLong() } }
}


import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.InputStream
import java.util.*

private class FScanner internal constructor(inputStream: InputStream = System.`in`) {
    internal val br = BufferedReader(InputStreamReader(inputStream))
    internal var st = StringTokenizer("")

    internal fun hasNext(): Boolean {
        while (!st.hasMoreTokens())
            st = StringTokenizer(br.readLine() ?: return false)
        return true
    }

    internal operator fun next() =
            if (hasNext()) st.nextToken()!!
            else throw RuntimeException("No tokens")

    internal fun nextInt() = next().toInt()

    internal fun nextLong() = next().toLong()

    internal fun nextLine() =
            if (hasNext()) st.nextToken("\n")
            else throw RuntimeException("No tokens")

    internal fun nextIntArray(n: Int) = IntArray(n, { nextInt() })

    internal fun nextLongArray(n: Int) = LongArray(n, { nextLong() })
}

fun main(args: Array<String>) {
    val sc = FScanner()
    val n = sc.nextInt()
    val s = sc.nextLine()
    val b = sc.nextIntArray(n)

    val rev = PriorityQueue<Triple<Char, Int, Char>>(compareBy { it.second })
    var sum = b.sum()

    val remChar = IntArray(26)
    (0 until n / 2).forEach {
        val inv = n - it - 1
        if (s[it] == s[inv]) {
//            println("${s[it]} - ${b[it]} - ${b[n - it - 1]}")
            if (b[it] < b[inv]) {
                remChar[s[it].toByte() - 'a'.toByte()]++
//                rev += Triple(s[inv], b[inv], s[it])
                sum -= b[it]
            } else {
                remChar[s[inv].toByte() - 'a'.toByte()]++
//                rev += Triple(s[it], b[it], s[inv])
                sum -= b[inv]
            }
        } else {
            rev += Triple(s[it], b[it], s[inv])
            rev += Triple(s[inv], b[inv], s[it])
        }
    }

    val remStat = PriorityQueue<Pair<Char, Int>>(compareBy<Pair<Char, Int>> { -it.second })
    remChar
            .forEachIndexed { index, i ->
                if (i > 0) {
                    remStat += Pair((index + 'a'.toByte()).toChar(), i)
                }
            }

//    println(remStat.joinToString(" "))
//    println(sum)

    if (remStat.isNotEmpty()) {
        var x = remStat.poll()
        var oldx = x.first
        var xleft = x.second
        while (remStat.isNotEmpty()) {
            val y = remStat.poll()
            if (y.second <= xleft) {
                xleft -= y.second
            } else {
                xleft = y.second - xleft
                x = y
            }
        }
//        println("Need remove ${x.first} $xleft")
//        println(rev.joinToString(" "))

        //find different x
        while (xleft > 0 && x.first == oldx) {
            val re = rev.poll()
            if (re.first != x.first && re.third != x.first) {
//                println("Remove $re")
                xleft--
                sum -= re.second
            }
        }
    }

    println(sum)
}


import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.InputStream
import java.util.*

private class FScanner internal constructor(inputStream: InputStream = System.`in`) {
    internal val br = BufferedReader(InputStreamReader(inputStream))
    internal var st = StringTokenizer("")

    internal fun hasNext(): Boolean {
        while (!st.hasMoreTokens())
            st = StringTokenizer(br.readLine() ?: return false)
        return true
    }

    internal operator fun next() =
            if (hasNext()) st.nextToken()!!
            else throw RuntimeException("No tokens")

    internal fun nextInt() = next().toInt()

    internal fun nextLong() = next().toLong()

    internal fun nextLine() =
            if (hasNext()) st.nextToken("\n")
            else throw RuntimeException("No tokens")

    internal fun nextIntArray(n: Int) = IntArray(n, { nextInt() })

    internal fun nextLongArray(n: Int) = LongArray(n, { nextLong() })
}

fun main(args: Array<String>) {
    val sc = FScanner()
    val n = sc.nextInt()
    val s = sc.nextLine()
    val b = sc.nextIntArray(n)

    val rev = PriorityQueue<Triple<Char, Int, Char>>(compareBy { it.second })
    var sum = b.sum()

    val remChar = IntArray(26)
    (0 until n / 2).forEach {
        val inv = n - it - 1
        if (s[it] == s[inv]) {
//            println("${s[it]} - ${b[it]} - ${b[n - it - 1]}")
            if (b[it] < b[inv]) {
                remChar[s[it].toByte() - 'a'.toByte()]++
                rev += Triple(s[inv], b[inv], s[it])
                sum -= b[it]
            } else {
                remChar[s[inv].toByte() - 'a'.toByte()]++
                rev += Triple(s[it], b[it], s[inv])
                sum -= b[inv]
            }
        } else {
            rev += Triple(s[it], b[it], s[inv])
            rev += Triple(s[inv], b[inv], s[it])
        }
    }

    val remStat = PriorityQueue<Pair<Char, Int>>(compareBy<Pair<Char, Int>> { -it.second })
    remChar
            .forEachIndexed { index, i ->
                if (i > 0) {
                    remStat += Pair((index + 'a'.toByte()).toChar(), i)
                }
            }

//    println(remStat.joinToString(" "))
//    println(sum)

    if (remStat.isNotEmpty()) {
        var x = remStat.poll()
        var oldx = x.first
        var xleft = x.second
        while (remStat.isNotEmpty()) {
            val y = remStat.poll()
            if (y.second <= xleft) {
                xleft -= y.second
            } else {
                xleft = y.second - xleft
                x = y
            }
        }
//        println("Need remove ${x.first} $xleft")
//        println(rev.joinToString(" "))

        //find different x
        while (xleft > 0 && x.first == oldx) {
            val re = rev.poll()
            if (re.first != x.first && re.third != x.first) {
//                println("Remove $re")
                xleft--
                sum -= re.second
            }
        }
    }

    println(sum)
}


import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.InputStream
import java.util.*

private class FScanner internal constructor(inputStream: InputStream = System.`in`) {
    internal val br = BufferedReader(InputStreamReader(inputStream))
    internal var st = StringTokenizer("")

    internal fun hasNext(): Boolean {
        while (!st.hasMoreTokens())
            st = StringTokenizer(br.readLine() ?: return false)
        return true
    }

    internal operator fun next() =
            if (hasNext()) st.nextToken()!!
            else throw RuntimeException("No tokens")

    internal fun nextInt() = next().toInt()

    internal fun nextLong() = next().toLong()

    internal fun nextLine() =
            if (hasNext()) st.nextToken("\n")
            else throw RuntimeException("No tokens")

    internal fun nextIntArray(n: Int) = IntArray(n, { nextInt() })

    internal fun nextLongArray(n: Int) = LongArray(n, { nextLong() })
}

fun main(args: Array<String>) {
    val sc = FScanner()
    val n = sc.nextInt()
    val s = sc.nextLine()
    val b = sc.nextIntArray(n)

    val rev = PriorityQueue<Triple<Char, Int, Char>>(compareBy { it.second })
    var sum = b.sum()

    val remChar = IntArray(26)
    (0 until n / 2).forEach {
        val inv = n - it - 1
        if (s[it] == s[inv]) {
//            println("${s[it]} - ${b[it]} - ${b[n - it - 1]}")
            if (b[it] < b[inv]) {
                remChar[s[it].toByte() - 'a'.toByte()]++
                rev += Triple(s[inv], b[inv], s[it])
                sum -= b[it]
            } else {
                remChar[s[inv].toByte() - 'a'.toByte()]++
                rev += Triple(s[it], b[it], s[inv])
                sum -= b[inv]
            }
        } else {
            rev += Triple(s[it], b[it], s[inv])
            rev += Triple(s[inv], b[inv], s[it])
        }
    }

    val remStat = PriorityQueue<Pair<Char, Int>>(compareBy<Pair<Char, Int>> { -it.second })
    remChar
            .forEachIndexed { index, i ->
                if (i > 0) {
                    remStat += Pair((index + 'a'.toByte()).toChar(), i)
                }
            }

//    println(remStat.joinToString(" "))
//    println(sum)

    if (remStat.isNotEmpty()) {
        var x = remStat.poll()
        var xleft = x.second
        while (remStat.isNotEmpty()) {
            val y = remStat.poll()
            if (y.second <= xleft) {
                xleft -= y.second
            } else {
                xleft = y.second - xleft
                x = y
            }
        }
//        println("Need remove ${x.first} $xleft")
//        println(rev.joinToString(" "))
        //find different x
        while (xleft > 0) {
            val re = rev.poll()
            if (re.first != x.first && re.third != x.first) {
//                println("Remove $re")
                xleft--
                sum -= re.second
            }
        }
    }

    println(sum)
}


import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.InputStream
import java.util.*

private class FScanner internal constructor(inputStream: InputStream = System.`in`) {
    internal val br = BufferedReader(InputStreamReader(inputStream))
    internal var st = StringTokenizer("")

    internal fun hasNext(): Boolean {
        while (!st.hasMoreTokens())
            st = StringTokenizer(br.readLine() ?: return false)
        return true
    }

    internal operator fun next() =
            if (hasNext()) st.nextToken()!!
            else throw RuntimeException("No tokens")

    internal fun nextInt() = next().toInt()

    internal fun nextLong() = next().toLong()

    internal fun nextLine() =
            if (hasNext()) st.nextToken("\n")
            else throw RuntimeException("No tokens")

    internal fun nextIntArray(n: Int) = IntArray(n, { nextInt() })

    internal fun nextLongArray(n: Int) = LongArray(n, { nextLong() })
}

fun main(args: Array<String>) {
    val sc = FScanner()
    val n = sc.nextInt()
    val s = sc.nextLine()
    val b = sc.nextIntArray(n)

    val remove = mutableSetOf<Int>()
    val rev = PriorityQueue<Pair<Char, Int>>(compareBy { it.second })
    var sum = b.sum()

    val remChar = IntArray(26)
    (0 until n / 2).forEach {
        val inv = n - it - 1
        if (s[it] == s[inv]) {
//            println("${s[it]} - ${b[it]} - ${b[n - it - 1]}")
            if (b[it] < b[inv]) {
                remove.add(it)
                remChar[s[it].toByte() - 'a'.toByte()]++
                rev += Pair(s[inv], b[inv])
                sum -= b[it]
            } else {
                remove.add(inv)
                remChar[s[inv].toByte() - 'a'.toByte()]++
                rev += Pair(s[it], b[it])
                sum -= b[inv]
            }
        } else {
            rev += Pair(s[it], b[it])
            rev += Pair(s[inv], b[inv])
        }
    }

    val remStat = PriorityQueue<Pair<Char, Int>>(compareBy<Pair<Char, Int>> { -it.second })
    remChar
            .forEachIndexed { index, i ->
                if (i > 0) {
                    remStat += Pair((index + 'a'.toByte()).toChar(), i)
                }
            }

//    println(remStat.joinToString(" "))

    if (remStat.isNotEmpty()) {
        var x = remStat.poll()
        var xleft = x.second
        while (remStat.isNotEmpty()) {
            val y = remStat.poll()
            if (y.second <= xleft) {
                xleft -= y.second
            } else {
                xleft = y.second - xleft
                x = y
            }
        }
        //find different x
        while (xleft > 0) {
            val re = rev.poll()
            if (re.first != x.first) {
                xleft--
                sum -= re.second
            }
        }
    }

    println(sum)
}


import java.util.*

class House(var human: Int) {
    val neighbours = mutableListOf<House>()
    var sizeOfSubtree = 0
}

fun main() {
    val n = readLine()!!.toInt()
    val vertices = List(n) { House(it + 1) }
    repeat(n - 1) {
        val (u, v) = readLine()!!.split(" ").map { it.toInt() - 1 }
        vertices[u].neighbours.add(vertices[v])
        vertices[v].neighbours.add(vertices[u])
    }

    fun DFS(vertex: House, old: House): Int {
        return if (vertex.neighbours.size == 1 && vertex != old) {
            vertex.sizeOfSubtree = 1
            1
        } else {
            var vym = 1
            vertex.neighbours.forEach {
                if (it != old) {
                    vym += DFS(it, vertex)
                }
            }
            vertex.sizeOfSubtree = vym
            vym
        }
    }

    DFS(vertices[0], vertices[0])

    fun DFS2(vertex: House, old: House): House? {
        if (vertex.sizeOfSubtree > (n / 2)) {
            vertex.neighbours.forEach {
                if (it != old) {
                    val v = DFS2(it, vertex)
                    if (v != null) {
                        return v
                    }
                }
            }
            return vertex
        }
        return null
    }

    fun DFS3(house: House, split: House): List<House> {
        val houses = mutableListOf<House>()

        fun DFS3IN(vertex: House, old: House) {
            houses.add(vertex)
            vertex.neighbours.forEach {
                if (it != old) {
                    DFS3IN(it, vertex)
                }
            }
        }
        DFS3IN(house, split)
        return houses
    }

    val split = DFS2(vertices[0], vertices[0])!!
    DFS(split, split)
    val sort = split.neighbours.sortedByDescending { it.sizeOfSubtree }.map { DFS3(it, split) }
    val queue = ArrayDeque<Int>() as Queue<Int>
    queue.addAll(sort[0].map { it.human })
    queue.add(split.human)
    split.human = queue.poll()
    for (i in 1 until sort.size) {
        queue.addAll(sort[i].map { it.human })
        sort[i].forEach {
            it.human = queue.poll()
        }
    }
    sort[0].forEach {
        it.human = queue.poll()
    }

    fun DFS4(vertex: House, old: House): Int {
        return if (vertex.neighbours.size == 1 && vertex != old) {
            1
        } else {
            var vym = 0
            vertex.neighbours.forEach {
                if (it != old) {
                    vym += DFS4(it, vertex)
                }
            }
            vym + vertex.sizeOfSubtree
        }
    }
    println((DFS4(split, split) - split.sizeOfSubtree) * 2)
    println(vertices.map { it.human }.joinToString(" "))

}


import java.util.*

class House(var human: Int) {
    val neighbours = mutableListOf<House>()
    var sizeOfSubtree = 0
}

fun main() {
    val n = readLine()!!.toInt()
    val vertices = List(n) { House(it + 1) }
    repeat(n - 1) {
        val (u, v) = readLine()!!.split(" ").map { it.toInt() - 1 }
        vertices[u].neighbours.add(vertices[v])
        vertices[v].neighbours.add(vertices[u])
    }

    fun DFS(vertex: House, old: House): Int {
        return if (vertex.neighbours.size == 1 && vertex != old) {
            vertex.sizeOfSubtree = 1
            1
        } else {
            var vym = 1
            vertex.neighbours.forEach {
                if (it != old) {
                    vym += DFS(it, vertex)
                }
            }
            vertex.sizeOfSubtree = vym
            vym
        }
    }

    DFS(vertices[0], vertices[0])

    fun DFS2(vertex: House, old: House): House? {
        if (vertex.sizeOfSubtree > (n / 2)) {
            vertex.neighbours.forEach {
                if (it != old) {
                    val v = DFS2(it, vertex)
                    if (v != null) {
                        return v
                    }
                }
            }
            return vertex
        }
        return null
    }

    fun DFS3(house: House, split: House): List<House> {
        val houses = mutableListOf<House>()

        fun DFS3IN(vertex: House, old: House) {
            houses.add(vertex)
            vertex.neighbours.forEach {
                if (it != old) {
                    DFS3IN(it, vertex)
                }
            }
        }
        DFS3IN(house, split)
        return houses
    }

    val split = DFS2(vertices[0], vertices[0])!!
    val sort = split.neighbours.sortedByDescending { it.sizeOfSubtree }.map { DFS3(it, split) }
    val queue = ArrayDeque<Int>() as Queue<Int>
    queue.add(split.human)
    queue.addAll(sort[0].map { it.human })
    for (i in 1 until sort.size) {
        queue.addAll(sort[i].map { it.human })
        sort[i].forEach {
            it.human = queue.poll()
        }
    }
    split.human = queue.poll()
    sort[0].forEach {
        it.human = queue.poll()
    }

    fun DFS4(vertex: House, old: House): Int {
        return if (vertex.neighbours.size == 1 && vertex != old) {
            1
        } else {
            var vym = 0
            vertex.neighbours.forEach {
                if (it != old) {
                    vym += DFS4(it, vertex)
                }
            }
            vym + vertex.sizeOfSubtree
        }
    }

    DFS(split, split)
    println((DFS4(split, split) - split.sizeOfSubtree) * 2)
    println(vertices.map { it.human }.joinToString(" "))

}


import java.util.*

class House(var human: Int) {
    val neighbours = mutableListOf<House>()
    var sizeOfSubtree = 0
}

fun main() {
    val n = readLine()!!.toInt()
    val vertices = List(n) { House(it + 1) }
    repeat(n - 1) {
        val (u, v) = readLine()!!.split(" ").map { it.toInt() - 1 }
        vertices[u].neighbours.add(vertices[v])
        vertices[v].neighbours.add(vertices[u])
    }

    fun DFS(vertex: House, old: House): Int {
        return if (vertex.neighbours.size == 1 && vertex != old) {
            vertex.sizeOfSubtree = 1
            1
        } else {
            var vym = 1
            vertex.neighbours.forEach {
                if (it != old) {
                    vym += DFS(it, vertex)
                }
            }
            vertex.sizeOfSubtree = vym
            vym
        }
    }

    DFS(vertices[0], vertices[0])

    fun DFS2(vertex: House, old: House): House? {
        if (vertex.sizeOfSubtree > (n / 2)) {
            vertex.neighbours.forEach {
                if (it != old) {
                    val v = DFS2(it, vertex)
                    if (v != null) {
                        return v
                    }
                }
            }
            return vertex
        }
        return null
    }

    fun DFS3(house: House, split: House): List<House> {
        val houses = mutableListOf<House>()

        fun DFS3IN(vertex: House, old: House) {
            houses.add(vertex)
            vertex.neighbours.forEach {
                if (it != old) {
                    DFS3IN(it, vertex)
                }
            }
        }
        DFS3IN(house, split)
        return houses
    }

    val split = DFS2(vertices[0], vertices[0])!!
    DFS(split, split)
    val sort = split.neighbours.sortedByDescending { it.sizeOfSubtree }.map { DFS3(it, split) }
    val queue = ArrayDeque<Int>() as Queue<Int>
    queue.addAll(sort[0].map { it.human })
    queue.add(split.human)
    split.human = queue.poll()
    for (i in 1 until sort.size) {
        queue.addAll(sort[i].map { it.human })
        sort[i].forEach {
            it.human = queue.poll()
        }
    }
    sort[0].forEach {
        it.human = queue.poll()
    }

    fun DFS4(vertex: House, old: House): Long {
        return if (vertex.neighbours.size == 1 && vertex != old) {
            1L
        } else {
            var vym = 0L
            vertex.neighbours.forEach {
                if (it != old) {
                    vym += DFS4(it, vertex)
                }
            }
            vym + vertex.sizeOfSubtree.toLong()
        }
    }
    println((DFS4(split, split) - split.sizeOfSubtree.toLong()) * 2L)
    println(vertices.map { it.human }.joinToString(" "))

}


fun main() {
    var str = readLine()!!
    if (str[1] == '1' || str[1] == '8') {
        if (str[0] == 'a' || str[0] == 'h') {
            println(3)
            return
        } else {
            println(5)
            return
        }
    } else {
        if (str[0] == 'a' || str[0] == 'h'){
            println(5)
        }else{
            println(8)
        }
    }

}


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

fun main(args : Array<String>) {
  //====== Input preparations ========================================================
//  val fin = BufferedReader(FileReader("a.in"))
  val fin = BufferedReader(InputStreamReader(System.`in`))
  val fout = PrintWriter (System.out)
  var tokenizer = StringTokenizer("")
  fun next() : String {
    while (!tokenizer.hasMoreTokens())
      tokenizer = StringTokenizer(fin.readLine())
    return tokenizer.nextToken()
  }
  fun nextInt() = next().toInt()
  fun nextPairDec() = nextInt()-1 to nextInt()-1
  //====== Solution below ============================================================
  val s = next()
  fun mirror(a: Int) = if (a > 3) 7 - a else a
  val a = mirror(s[0] - 'a')
  val b = mirror(s[1] - '1')
  if (a > 0 && b > 0)
    fout.print(8)
  else if (a == 0 && b == 0)
    fout.print(3)
  else
    fout.print(5)

  fout.close()
  fin.close()
}


fun main() {
    val pos = readLine()!!
    if (pos in setOf("a1", "h1", "a8", "h8")) return print(3)
    if (pos[0] == 'a' || pos[0] == 'h' || pos[1] == '1' || pos[1] == '8') return print(5)
    print(8)
}


fun main() {
    val pos = readLine()!!
    if (pos in setOf("a1", "h1", "a8", "h8")) return print(4)
    if (pos[0] == 'a' || pos[0] == 'h' || pos[1] == '1' || pos[1] == '8') return print(5)
    print(8)
}


import java.io.BufferedReader
import java.io.File
import java.io.PrintWriter

fun main(args: Array<String>) {
    val onlineJudge = System.getProperty("ONLINE_JUDGE") == "true"
    val input = if (onlineJudge) System.`in`.bufferedReader() else File("input.txt").bufferedReader()
    val output = if (onlineJudge) PrintWriter(System.out.writer(), true) else PrintWriter(File("output.txt"))

    solve(input, output)
}

private fun solve(input: BufferedReader, output: PrintWriter) {
    //todo implement the task solution
}


fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    val s1 = r.readLine()!!.split(" ").map { it.toInt() }.sum()
    val s2 = r.readLine()!!.split(" ").map { it.toInt() }.sum()
    val v = r.readLine()!!.toInt()
    val ans = s1/5 + s2/10 +if (s1%5!=0) 1 else 0 +if (s2%10!=0) 1 else 0
    println(if (ans<=v) "YES" else "NO")
}


// https://codeforces.com/problemset/problem/448/A

fun main(args: Array<String>) {
    val medals = readInts()
    val cups = readInts()
    var totalShelves = readInt()

    val totalMedals = medals.sum()
    val totalCups = cups.sum()

    var totalCupsShelves = (totalCups / 10)
    if(totalCupsShelves % 10 != 0){
        totalCupsShelves += 1
    }
    var totalMedalsShelves = (totalMedals / 5) + (totalMedals % 5)
    if(totalMedalsShelves % 5 != 0){
        totalMedalsShelves += 1
    }

    if(totalCupsShelves + totalMedalsShelves > totalShelves){
        print("NO")
    }else{
        print("YES")
    }

}

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


// https://codeforces.com/problemset/problem/448/A

fun main(args: Array<String>) {
    val medals = readInts()
    val cups = readInts()
    var totalShelves = readInt()

    val totalMedals = medals.sum()
    val totalCups = cups.sum()

    var totalCupsShelves = (totalCups / 10)
    if(totalCupsShelves % 10 != 0){
        totalCupsShelves += 1
    }
    var totalMedalsShelves = (totalMedals / 5)
    if(totalMedalsShelves % 5 != 0){
        totalMedalsShelves += 1
    }

    if(totalCupsShelves + totalMedalsShelves > totalShelves){
        print("NO")
    }else{
        print("YES")
    }

}

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


import java.util.*

fun min(a:Double,b:Double) = if (a<b) a else b
fun max(a:Double,b:Double) = if (a>b) a else b
fun min(a:Long,b:Long) = if (a<b) a else b
fun max(a:Long,b:Long) = if (a>b) a else b

fun readLn():String = readLine()!!.toString()
fun readLong() = readLn().toLong()
fun readLongs()  = readLn().split(" ").map{it.toLong()}
var nul=0.toLong();
var one=1.toLong();
var two=2.toLong();
var three=3.toLong();
var four=4.toLong();
var five=5.toLong();
fun powmod(a:Long,b:Long,mod:Long):Long {

    if (b==1.toLong()) return a;
    var k=powmod(a,b/2,mod);
    if (b%2==0.toLong())
    { return (k*k)%mod }
    else { k=k*k; k=k%mod; k=k*a; k=k%mod; return k; }
}
fun prime (p:Long):Long {
    if (p==one) return 0.toLong();
    var i=two;
    while (i*i<=p) {if (p%i==nul) return i; i++; }
    return one;
}
fun inv (a:Long,mod:Long):Long {
return powmod(a,mod-2,mod);
}

fun solve() {
    val cin = Scanner(System.`in`)

    /*
    var map=hashMapOf<String,Int>();
    map[q] <=> map.getOrDefault(q,0)
    Сортировка вектора пар - k=v.sortedWith(compareBy({it.first},{it.second}));
    prLong("${k[i].second}"); - вывод аргумента пары
    var m=ArrayList<Long> (); <=> vector
    getline(cin,a) <=> readLine()!!.last()
   readLong() - одно число
   readLongs() - несколько чисел
   readLine()!!.toCharArray() - возвращает массив чаров из строки

    */
    /* --------- */
        // ВСЕГДА ПИСАТЬ В ЛОНГАХ

    var (a1,a2,a3)=readLongs();
    var (b1,b2,b3)=readLongs();
    a1+=a2+a3;
    b1+=b2+b3;
    var n=readLong();
    var min1=(a1+four)/five+(b1+9.toLong())/10.toLong();
    if (min1>n) print("NO"); else print("YES");
    /* --------- */

}

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

    var T=one;
    //T=readLine()!!.toLong();
    for (i55555 in 1..T) solve()
}


fun main(args:Array<String>) {
    val a = readLine()!!.trim().split(" ").asSequence().sumBy { s -> s.toInt() }
    val b = readLine()!!.trim().split(" ").asSequence().sumBy { s -> s.toInt() }
    val n = readLine()!!.toInt();
    if ((a + 4) / 5 + (b + 9) / 10 <= n) print("YES") else print("NO")
}


fun main(args: Array<String>) {

    val a = readLine()!!.split(' ').map { it.toInt() }.sum()
    val b = readLine()!!.split(' ').map { it.toInt() }.sum()
    val n  = readLine()!!.toInt()

    println(if (d(a,5) + d(b, 10) <= n) "YES" else "NO")
}

fun d(a : Int, n : Int) = if (a%n == 0) a/n else a/n + 1


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

class ProblemIO(val rd: BufferedReader, val wr: PrintWriter) {
    companion object {
        fun console() = ProblemIO(BufferedReader(InputStreamReader(System.`in`)), PrintWriter(System.out))
    }

    var tok = StringTokenizer("")

    fun close() { rd.close(); wr.close() }
    fun <T> print(v: T) = wr.print(v)
    fun <T> println(v: T) = wr.println(v)
    fun readToken(): String {
        while (!tok.hasMoreTokens()) tok = StringTokenizer(rd.readLine())
        return tok.nextToken()
    }
    fun readInt() = readToken().toInt()
    fun readLong() = readToken().toLong()
    fun readLine() : String {
        tok = StringTokenizer("")
        return rd.readLine()
    }
}

fun main(args: Array<String>) {
    Thread({ val io = ProblemIO.console(); solve(io) ; io.close() }).start()
}

fun solve(io: ProblemIO) {
    val a = (1 .. 3).map({ io.readInt() }).sum()
    val b = (1 .. 3).map({ io.readInt() }).sum()
    val n = io.readInt()
    val res = (n >= ((a + 4) / 5) + ((b + 9) / 10))
    io.println(if (res) "YES" else "NO")
}


// https://codeforces.com/problemset/problem/448/A

fun main(args: Array<String>) {
    val medals = readInts()
    val cups = readInts()
    var totalShelves = readInt()

    val totalMedals = medals.sum()
    val totalCups = cups.sum()

    var totalCupsShelves = (totalCups / 10)
    if(totalCups % 10 != 0){
        totalCupsShelves += 1
    }
    var totalMedalsShelves = (totalMedals / 5)
    if(totalMedals % 5 != 0){
        totalMedalsShelves += 1
    }

    if(totalCupsShelves + totalMedalsShelves > totalShelves){
        print("NO")
    }else{
        print("YES")
    }

}

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


// Про награды

fun main(args: Array<String>) {

    val kubok = readLine()!!.trim().split(" ")
    val medal = readLine()!!.trim().split(" ")
    val n = readLine()!!.trim().toInt()

    val countA = kubok.asSequence().sumBy { s -> s.toInt() }
    val countB = medal.asSequence().sumBy { s -> s.toInt() }

 //   println(countA)
 //   println(countB)

    val needRowToA = if (countA % 5 == 0) countA/5 else countA/5+1
    val needRowToB = if (countB % 10 == 0) countB/10 else countB/10+1

  //  println(needRowToA)
  //  println(needRowToB)

    if (n - needRowToB - needRowToA >= 0){
        println("YES")
    }else{
        println("NO")
    }
    /*
        на одной полке не могут находиться кубки и медали одновременно;
        ни на какой полке не должно быть больше пяти кубков;
        ни на какой полке не должно быть больше десяти медалей.
    */

}


fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    val s1 = r.readLine()!!.split(" ").map { it.toInt() }.sum()
    val s2 = r.readLine()!!.split(" ").map { it.toInt() }.sum()
    val v = r.readLine()!!.toInt()
    val ans = s1 / 5 + s2 / 10 + (if (s2 % 10 != 0) 1 else 0) + (if (s1 % 5 != 0) 1 else 0)
    println(if (ans <= v) "YES" else "NO")
}


fun main(args: Array<String>) {
    var a = 0
    var b = 0
    readLine()!!.split(' ').map(String::toInt).forEach {
        a += it
    }
    readLine()!!.split(' ').map(String::toInt).forEach {
        b += it
    }
    val n = readLine()!!.toInt()
    if ((a+4)/5+(b+9)/10 <= n)
        print("YES\n")
    else
        print("NO\n")
}


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

fun main(){
  val a = readInts()
  val s1 = a.sum()
  val b = readInts()
  val s2 = b.sum()
  val n = readInt()
  val p = s1 / 5 + if (s1 % 5 > 0) 1 else 0
  val q = s2 / 10 + if (s2 % 10 > 0) 1 else 0
  println(if (p + q > n) "NO" else "YES")
}


import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    var q1 = 0
    var q2 = 0
    q1 = sc.nextInt() + sc.nextInt() + sc.nextInt()
    q2 = sc.nextInt() + sc.nextInt() + sc.nextInt()
    var s = sc.nextInt()
    var w: Int
    var e: Int
    w = q1 / 5;
    if (q1 % 5 != 0)
        w++;
    e = q2 / 10;
    if (q2 % 10 != 0)
        e++;
    if (s >= (e + w)) print("YES")
    else print("NO")

}


fun main() {
    val line = readLine()!!
    val six = line.indexOf(' ')
    val n = line.substring(0, six).toLong()
    val k = line.substring(six + 1).toLong()
    var len = 0
    while (1L shl len <= n) {
        len++
    }
    fun amt(d: Long): Long {
        var res = 0L
        if (d % 2L == 0L) {
            res += amt(d + 1L)
        }
        var l = 0
        while (1L shl l <= d) {
            l++
        }
        var l2 = l
        while (l2 < len) {
            res += 1L shl (l2 - l)
            l2++
        }
        val q = n / (1L shl (len - l))
        if (q > d) {
            res += 1L shl (len - l)
        } else if (q == d) {
            res += (n % (1L shl (len - l))) + 1L
        }
        //println("amt($d) = $res")
        return res
    }
    var lower = 0L
    var upper = n / 2L
    while (upper > lower) {
        val mid = (lower + upper + 1L) / 2L
        if (amt(2L * mid) >= k) {
            lower = mid
        } else {
            upper = mid - 1L
        }
    }
    var answer = upper * 2L
    if (amt(answer + 1L) >= k) {
        answer++
    }
    println(answer)
}


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

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

val MAX_N = (1e6 + 10).toInt()
val INF = (1e9 + 7).toInt()
val MOD = (1e9 + 7).toInt()
val INF_F = 1e-6

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

    solve(reader, writer)
    writer.close()
}

fun solve(reader: InputReader, writer: PrintWriter) {
    val n = reader.nextInt()
    val k = reader.nextInt()
    val x = reader.nextInt()
    val a = reader.nextArrayInt(n).reversed().toMutableList()
    for (i in 0 until k) {
        a[i] = x
    }
    writer.println(a.sum())
}

fun gcd(a: Int, b: Int): Int {
    return if (b == 0) a else gcd(b, a % b)
}

class InputReader(stream: InputStream) {
    private val reader = BufferedReader(InputStreamReader(stream), 32768)
    private 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 nextArrayInt(count: Int): IntArray {
        return nextArrayInt(0, count)
    }

    fun nextArrayInt(start: Int, count: Int): IntArray {
        val a = IntArray(start + count)
        for (i in start until start + count) {
            a[i] = nextInt()
        }
        return a
    }

    fun nextArrayLong(count: Int): LongArray {
        val a = LongArray(count)
        for (i in 0 until count) {
            a[i] = nextLong()
        }
        return a
    }
}


import kotlin.math.*

val sc = java.util.Scanner(System.`in`)

data class Interval(val L: Int, val R: Int) : Comparable<Interval> {
	override fun compareTo(other: Interval): Int {
		return compareValuesBy(this, other, Interval::L, Interval::R)
	}
}

fun main(args: Array<String>) {
	val n = sc.nextInt()
	val k = sc.nextInt()
	val x = sc.nextInt()
	val a = Array(n) { sc.nextInt() }
	a.reverse()
	for (i in 0 until k) a[i] = x
	println(a.sum())
}


import kotlin.math.min

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

    val (numChores, numReplazazbleChores, timeFastChores) = readInts()
    val chores = readInts().reversed()
    var sol = 0
    val end = min(numChores, numReplazazbleChores)
    for (chore in chores.subList(0, end)) sol += min(chore, timeFastChores)
    print(sol + chores.subList(end, numChores).sum())
}


fun main(args: Array<String>) {
    val spin = "v<^>"

    val line = readLine()!!
    val s = line.split(" ")[0]
    val e = line.split(" ")[1]

    val n = readLine()!!.toInt()

    when {
        n % 2 == 0 -> println("undefined")
        n % 2 == 1 -> {
            if(spin[(spin.indexOf(s) + n) % 4] == e[0]) println("cw")
            else println("ccw")
        }
    }

}


fun main() {
    val positions = "v<^>"
    val fromTo = readLine()!!
    val duration = readLine()!!.toInt() % 4
    var sol = if (fromTo[2] == positions[(positions.indexOf(fromTo[0]) + duration) % 4]) 1 else 0
    if (fromTo[2] == positions[(positions.indexOf(fromTo[0]) + 4 - duration) % 4]) sol = sol or 2
    print(
        when (sol) {
            1 -> "cw"
            2 -> "ccw"
            else -> "undefined"
        }
    )
}


import java.io.InputStream

private val input = FastScanner()

fun main(args: Array<String>) = input.run {
    val s = "<^>v"
    val a = nextString()!![0].let { s.indexOf(it) }
    val b = nextString()!![0].let { s.indexOf(it) }
    val n = nextInt()
    if (b == (a + n) % 4 && b == Math.floorMod(a - n, 4)) {
        println("undefined")
    } else if (b == Math.floorMod(a - n, 4)) {
        println("ccw")
    } else {
        println("cw")
    }
}

class FastScanner(private val input: InputStream = System.`in`) {
    private val sb = StringBuilder()
    private val buffer = ByteArray(4096)
    private var pos = 0
    private var size = 0

    fun nextString(): String? {
        var c = skipWhitespace()
        if (c < 0) return null

        return sb.run {
            setLength(0)

            do {
                append(c.toChar())
                c = read()
            } while (c > ' '.toInt())

            toString()
        }
    }

    fun nextLong(): Long {
        var c = skipWhitespace()

        val sign = if (c == '-'.toInt()) {
            c = read()
            -1
        } else 1

        var ans = 0L

        while (c > ' '.toInt()) {
            ans = ans * 10 + c - '0'.toInt()
            c = read()
        }

        return sign * ans
    }

    fun nextInt() = nextLong().toInt()

    private fun skipWhitespace(): Int {
        while (true) {
            val c = read()
            if (c > ' '.toInt() || c < 0) return c
        }
    }

    private fun read(): Int {
        while (pos >= size) {
            if (size < 0) return -1
            size = input.read(buffer, 0, buffer.size)
            pos = 0
        }
        return buffer[pos++].toInt()
    }
}


import java.util.*
import kotlin.test.assertTrue

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
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 solve() {
    var recipe = readLn()
    var (nb, ns, nc) = readInts()
    var (pb, ps, pc) = readInts()
    var r = readLong()

    var needB = false
    var needS = false
    var needC = false
    var cost = 0;
    for (c in recipe) {
        if (c == 'B') {
            needB = true
            cost += pb
        } else if (c == 'S') {
            needS = true
            cost += ps
        } else {
            needC = true
            cost += pc
        }
    }

    if (needB) {
        r += nb * pb
    }
    if (needS) {
        r += ns * ps
    }
    if (needC) {
        r += nc * pc
    }

    val ans = r / cost
    println(ans)
}

fun main() {
    var t = 1;
    // t = readInt();
    for (i in 1..t) {
        solve();
    }
}


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

var nb = 0
var ns = 0
var nc = 0
var pb = 0
var ps = 0
var pc = 0
var r = 0L
var cb = 0
var cs = 0
var cc = 0

private fun f(x: Long):
        Long {
    return Math.max(0, (x * cb - nb) * pb) + Math.max(0, (x * cs - ns) * ps) +
            Math.max(0, (x * cc - nc) * pc)
}

private fun solve() {
    var recipe = readLn()
    val (nb_, ns_, nc_) = readInts()
    nb = nb_
    ns = ns_
    nc = nc_
    val (pb_, ps_, pc_) = readInts()
    pb = pb_
    ps = ps_
    pc = pc_
    r = readLong()

    for (c in recipe) {
        when (c) {
            'B' -> {
                cb++
            }
            'S' -> {
                cs++
            }
            else -> {
                cc++
            }
        }
    }

    var x = 0L
    var jump: Long = 100000000000000L // 1e14
    while (jump >= 1) {
        while (f(x + jump) <= r) {
            x += jump
        }
        jump /= 2
    }

    println(x)
}

fun main() {
    var t = 1;
    // t = readInt();
    for (i in 1..t) {
        solve();
    }
}


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 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 solve() {
    var recipe = readLn()
    var (nb, ns, nc) = readInts()
    var (pb, ps, pc) = readInts()
    var r = readLong()

    var needB = false
    var needS = false
    var needC = false
    var cost = 0;
    for (c in recipe) {
        if (c == 'B') {
            needB = true
            cost += pb
        } else if (c == 'S') {
            needS = true
            cost += ps
        } else {
            needC = true
            cost += pc
        }
    }

    if (needB) {
        r += nb * pb
    }
    if (needS) {
        r += ns * ps
    }
    if (needC) {
        r += nc * pc
    }

    val ans = r / cost
    println(ans)
}

fun main() {
    var t = 1;
    // t = readInt();
    for (i in 1..t) {
        solve();
    }
}


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

fun main(args: Array<String>) {
    with(Scanner(System.`in`)) {
        val pt = mutableListOf<Int>()
        val X2 = nextInt()
        val mk = Array(X2 + 1, { true })
        val mf = Array(X2 + 1, { 0 })

        var counter = 0
        (2..X2).forEach {
            if (mk[it]) {
                pt.add(it)
                for (j in (it * 2)..X2 step it) {
                    mk[j] = false
                    mf[j] = it
                    ++counter
                }
            }
        }

        pt.reverse()

        val lo = fun(x: Int) = x - mf[x] + 1

        var ans = X2
        (lo(X2)..X2).forEach {
            if (!mk[it]) {
                val c = lo(it)
                if (c > 3) {
                    ans = min(ans, c)
                }
            }
        }
        println(ans)
    }
}


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

fun main(args: Array<String>) {
    with(Scanner(System.`in`)) {
        val pt = mutableListOf<Int>()
        val X2 = nextInt()
        val mk = Array(X2 + 1, { true })

        var counter = 0
        (2..X2).forEach {
            if (mk[it]) {
                pt.add(it)
                for (j in (it * 2)..X2 step it) {
                    mk[j] = false
                    ++counter
                }
            }
        }

        pt.reverse()

        val maxFactor = fun(x: Int): Int {
            return pt.first { x%it == 0 }
        }

        val lo = fun(x: Int) = x - maxFactor(x) + 1

        var ans = X2
        (lo(X2)..X2).forEach {
            val c = lo(it)
            if (c > 3) {
                ans = min(ans, c)
            }
        }
        println(ans)
    }
}


fun main(args: Array<String>) {
  val X2 = readLine() ?. toInt() ?: return

  val C = 1000000
  val mxp = IntArray(C+5) { -1 }
  for(i in 2 .. C) {
    if(mxp[i] == -1) {
      for(j in i .. C step i) {
        mxp[j] = i
      }
    }
  }

  val a = X2 - mxp[X2]
  val b = (X2 - mxp[X2] + 1 .. X2).filter({ mxp[it] != it }).map { it - mxp[it] }.min() ?: return
  println(Math.min(a, b) + 1)
}


import kotlin.math.ceil
import kotlin.math.sqrt

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

    val (r, x, y, x2, y2) = readInts()
    val d = sqrt(((x - x2) * (x - x2) + (y - y2) * (y - y2)).toDouble())
    print(ceil(d / (r * 2)).toLong())
}


import kotlin.math.abs
import kotlin.math.ceil
import kotlin.math.sqrt

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

    val (r, x, y, x2, y2) = readInts()
    val d = sqrt((abs(x - x2) * abs(x - x2) + abs(y - y2) * abs(y - y2)).toDouble())
    print(ceil(d / (r * 2)).toLong())
}


import kotlin.math.pow
import kotlin.math.sqrt

fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    //val len = r.readLine()!!.toInt()
    val (radius, x, y, x1, y1) = r.readLine()!!.split(" ").map { it.toDouble() }
    val dis = sqrt((x-x1).pow(2)+(y-y1).pow(2))
    val ans = (dis/(2*radius)).toInt() + if (dis-dis/(2*radius)*(2*radius)>=0.0) 1 else 0
    //println((dis/(2*radius)).toInt())
    println(ans)
}


// 8/5/2020 7:05 AM

//package p507

import kotlin.math.ceil
import kotlin.math.sqrt

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

fun main() {
    val (r, x, y, x2, y2) = readInts()
    val distanceTo = sqrt(((x-x2)*(x-x2) + (y-y2)*(y-y2)).toDouble())
    if (x == x2 && y == y2) {
        println(0)
        return
    }

    if (distanceTo < r) {
        println(2)
        return
    }

    println( ceil((distanceTo) / (2*r)).toInt() )

}


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

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

    val (r, x, y, x2, y2) = readInts()
    print(max(abs(x2 - x) / (2 * r), abs(y2 - y) / (2 * r)))
}


import kotlin.math.pow
import kotlin.math.sqrt

fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    //val len = r.readLine()!!.toInt()
    val (radius, x, y, x1, y1) = r.readLine()!!.split(" ").map { it.toDouble() }
    val dis = sqrt((x-x1).pow(2)+(y-y1).pow(2))
    val ans = (dis/(2*radius)).toInt() + if (dis%radius!=0.0) 1 else 0
    println(ans)
}


// 8/5/2020 7:05 AM
/*
https://codeforces.com/problemset/problem/507/B
 */
//package p507

import kotlin.math.ceil
import kotlin.math.sqrt

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

fun main() {
    val (r, x, y, x2, y2) = readInts().map{ it.toLong() }
    val distanceTo = sqrt(((x-x2)*(x-x2) + (y-y2)*(y-y2)).toDouble())

    println( ceil((distanceTo) / (2*r)).toInt() )

}


import kotlin.math.abs
import kotlin.math.ceil
import kotlin.math.sqrt

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

    val (r, x, y, x2, y2) = readLongs()
    val d = sqrt(((x - x2) * (x - x2) + (y - y2) * (y - y2)).toDouble())
    print(ceil(d / (r * 2)).toLong())
}


//package com.happypeople.codeforces.c1097

import java.io.ByteArrayInputStream
import java.io.InputStream
import java.util.*

fun main(args: Array<String>) {
    try {
        B().run()
    } catch (e: Throwable) {
        B.log("" + e)
    }
}

class B {
    fun run() {
        val sc = Scanner(systemIn())
        val n=sc.nextInt()
        val a=(1..n).map { sc.nextInt() }

        val res=binsearch(a, 0, 0)
        if(res)
            println("YES")
        else
            println("NO")
    }

    fun binsearch(a:List<Int>, next:Int, sum:Int):Boolean {
        if(next==a.size)
            return sum%360==0
        else
            return binsearch(a, next+1, sum+a[next]) ||
                binsearch(a, next+1, sum-a[next])
    }

    companion object {
        var inputStr: String? = null

        fun systemIn(): InputStream {
            if (inputStr != null)
                return ByteArrayInputStream(inputStr!!.toByteArray())
            else
                return System.`in`
        }

        var printLog = false
        fun log(str: String) {
            if (printLog)
                println(str)
        }
    }
}


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

fun BufferedReader.readIntList() = readLine().split(' ').map(String::toInt)
fun BufferedReader.readLongList() = readLine().split(' ').map(String::toLong)

class Solution(private val inf: BufferedReader, private val ouf: PrintWriter) : Runnable {
    constructor() : this(BufferedReader(InputStreamReader(System.`in`)), PrintWriter(System.out))

    fun solve() {
        val n = inf.readLine().toInt()
        val a = IntArray(n) {
            inf.readLine().toInt()
        }
        var ans = false
        for (i in 0 until (1 shl n)) {
            var sum = 0
            for (j in a.indices) {
                if ((i and (1 shl j)) == 0) sum += a[j] else sum -= a[j]
            }
            if ((sum % 360 + 360) % 360 == 0) ans = true
        }
        ouf.println(if (ans) "YES" else "NO")
    }

    override fun run() {
//        for (testNum in 1..inf.readLine().toInt()) {
            solve()
//        }

        ouf.close()
    }
}

fun main(args: Array<String>) {
    Thread(null, Solution(), "name", 1 shl 27).start()
}


fun main() {
    //println((4 or 6)xor(4 or 5))
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    //val n = r.readLine()!!.toInt()
    var v = mutableListOf<Int>(0)
    repeat(r.readLine()!!.toInt()) {
        val n = r.readLine()!!.toInt()
        val newList = mutableListOf<Int>()
        v.forEach {
            newList += it+n
            newList += it-n
        }
        v = newList
    }
    val ans = v.any { it%360==0 }
    println(if (ans) "YES" else "NO")
}


fun main() {
    val n = readInt()

    var possibilities = setOf(0)

    repeat(n) {
        val a = readInt()

        possibilities = sequence {
            for(p in possibilities) {
                yield((p + a) umod 360)
                yield((p - a) umod 360)
            }
        }.toSet()
    }

    if(0 in possibilities) println("YES") else println("NO")
}

infix fun Int.umod(divisor: Int) =
    (this % divisor).let { if(it >= 0) it else it + divisor }

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


import kotlin.math.*

fun main(arg: Array<String>){
	var N = readLine()!!.toInt()
	val NN = N
	val M = 2.0.pow(N.toDouble()).toInt()
	val L = mutableListOf<Int>()
	var S = 0
	while(N > 0){
		L.add(readLine()!!.toInt())
		N--
	}
	L.forEach(){
		S += it
	}
	for(i in 0..M-1){
		val opts = i.toString(2).padStart(NN,'0')
		//println(opts)
		var Sum = 0
		for (i in 1..opts.length){
			if(opts[i-1] == '0'){
				Sum -= L[i-1]
			}else{
				Sum += L[i-1]
			}
		}
		if(Sum.rem(360) == 0){
			//println("OGON: $opts $Sum")
			println("YES")
			return
		}

	}
	println("NO")
}


fun main() {
    val r = System.`in`.bufferedReader()
    val s1 = StringBuilder()
    //val (n, k) = r.readLine()!!.split(" ").map { it.toInt() }
    val n = r.readLine()!!.toInt()
    println((n/2-1)/2)
}


fun main() {
    val r = System.`in`.bufferedReader()
    val s1 = StringBuilder()
    //val (n, k) = r.readLine()!!.split(" ").map { it.toInt() }
    val n = r.readLine()!!.toInt()
    println(n/2/2)
}