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

public class Main {
    static PrintWriter pw;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int dp[][] = new int[n][2];
        dp[0][0] = 2;
        dp[0][1] = 0;
        for (int i = 1; i < n; i++) {
            dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
            dp[i][1] = dp[i - 1][0];
        }
        if(m==1){
            pw.println((dp[n - 1][0] + dp[n - 1][1]));
        }
        else
        pw.println((dp[n - 1][0] + dp[n - 1][1]) * 2);
        pw.close();
    }
}