#include <fstream>
#include <functional>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    //ifstream cin("/Volumes/env1/work/aoj/1378/a");
    int l, k;
    cin >> l >> k;

    vector<vector<int>> memo(10, vector<int>(2, 10));
    // ??????????????????
    // w -> bs or bt
    // bin -> bin - 1
    // b -> w
    // function<int(int, int)> f = [&f, &memo, l](int h, int c) {

    //};

    vector<vector<long>> dp(l + 2, vector<long>(k + 1, 0));

    auto p = [&dp] {
        for (auto &&i : dp) {
            for (auto &&j : i) {
                cout << j << ' ';
            }
            cout << endl;
        }
    };
    dp[1][1] = 1;
    dp[1][k] = 1;
    for (int h = 1; h <= l; ++h) {
        for (int i = 0; i < k; ++i) {
            dp[h + 1][i] += dp[h][i + 1];
        }
        if (dp[h][0] > 0) {
            dp[h + 1][1] += dp[h][0];
            dp[h + 1][k] += dp[h][0];
        }
        //cout << "end of " << h << endl;
        //p();
        //cout << endl;
    }

    long sum_ = 0;
    for (int h = 1; h <= l; ++h) {
        sum_ += dp[h][1];
    }
    cout << sum_ << endl;

    // dp[1][1] = 1;
    // dp[1][k] = 1;
    // for (int h = 2; h <= l; ++h) {
    //    for (int i = 0; i < k; ++i) {
    //        dp[h][i] = dp[h - 1][i + 1];
    //    }

    //    //if (dp[h][0] > 0) {
    //    //    dp[h][1] = dp[h][0] + 1;
    //    //    dp[h][k] = dp[h][0] + 1;
    //    //}
    //    cout << h << endl;
    //    p();
    //}
    //p();
    //cout << dp[l][1] << endl;
}