
object Main extends App {
  import scala.io.StdIn._
  val Array(l, k) = readLine.trim.split(' ').map(_.toInt)
  println(
    count(l - 1, k) + count(l - k, k)
  )
  def count(l: Int, k: Int)(implicit memo: Array[Long] = Array.tabulate(l + 1){_ => -1}): Long = {
    if (l == 0) 1
    else if (l < 0) 0
    else {
      if (memo(l) < 0)
        (count(l - k - 1, k) + count(l - 2, k) + 1).also(memo(l) = _)
      else memo(l)
    }
  }
  implicit class ScopeFunc[T](private val value: T) {
    def let[A](func:T ⇒ A): A = func(value)
    def also(func:T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}

