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

public class Main
{
    static final int MOD=  (int)1e9 + 7 ;

    static int [][] mat ;
    static int [] dx = {-1 , 1 , 0 , 0} , dy = {0 , 0 , -1 , 1} ;
    static boolean isValid(int x , int y)
    {
        return x >= 0 && y >=0 && x < mat.length && y < mat[0].length ;
    }
    static int bt(int idx , int n , int m)
    {
        if(idx == n * m )
        {
            boolean can = true ;
            for(int i  = 0; i < mat.length ; i++)
                for(int j = 0 ; j < mat[0].length ; j ++) {
                    int cnt =0 ;
                    for (int k = 0; k < 4; k++)
                        if (isValid(i + dx[k], j + dy[k]))
                            cnt += mat[i][j] == mat[i + dx[k]][j + dy[k]] ? 1 : 0;
                    can &= cnt <= 1 ;
                }
            return can ? 1 : 0 ;
        }
        int ans =0 ;
        mat[idx / m][idx % m] = 0 ;
        ans += bt(idx+  1 , n, m) ;
        mat[idx / m][idx % m] = 1 ;
        ans += bt(idx + 1 , n , m) ;
        return ans ;
    }
    static int solve(int n , int m)
    {
        mat = new int [n][m] ;
        return bt(0 , n , m) ;
    }
    static int memo[][][]; // idx , last,cur
    static int n ;
    static int dp(int idx , int last , int cur)
    {
        if(idx == n - 1) return 1 ;
        if(memo[idx][last][cur] != -1)
            return memo[idx][last][cur] ;
        int ans = 0 ;
        for(int nxt = 1 ; nxt <= 2 ; nxt++) {
            int same = 0 ;
            if (last == cur) same ++ ;
            if(cur == nxt && idx < n - 1) same ++ ;
            if(same <= 1)
                ans += dp(idx + 1 , cur , nxt) ;
            ans %= MOD ;
        }
        return memo[idx][last][cur] = ans ;
    }

    // 0 ,2, 4,8,14,24 , 40,66
    public static void main(String[] args) throws Exception
    {
        Scanner sc = new Scanner(System.in) ;
        PrintWriter out = new PrintWriter(System.out) ;
//        for(int i = 1 ; i <= 6 ; i++)
//            System.out.println(3+" "+i+" "+solve(3 , i));
        n = sc.nextInt() ;
        int m = sc.nextInt() ;
        int [] fib = new int [m + 1] ;
        memo = new int [n][3][3] ;
        for(int i  = 0 ;i < n ; i ++)
            for(int j = 0 ; j < 3 ; j++)
                Arrays.fill(memo[i][j] , -1);
        fib[1] = (dp(0 , 0 , 1) + dp(0 , 0 , 2)) % MOD ;
        if(m == 1)
        {
            System.out.println(fib[1]);
            return;
        }
        else if(m == 2)
        {
            System.out.println((fib[1] + 2) % MOD);
            return;

        }
        fib[2] = fib[1] + 2;
        fib[3] = fib[2] + 2 ;
        int diff = (((fib[1] + fib[2] - fib[3]) % MOD) + MOD) % MOD;
        for(int i = 4 ; i <= m ; i ++)
            fib[i] = (((fib[i - 1] + fib[i - 2] - diff) % MOD) + MOD) % MOD;
        out.println(fib[m] % MOD);
        out.flush();
    }



    static class Scanner
    {
        BufferedReader br ;
        StringTokenizer st ;

        Scanner(String path) throws Exception
        {
            br = new BufferedReader(new FileReader(path)) ;
        }
        Scanner (InputStream in) throws Exception
        {
            br = new BufferedReader(new InputStreamReader(in)) ;
        }
        String next() throws Exception
        {
            while (st == null || !st.hasMoreElements())
                st = new StringTokenizer(br.readLine()) ;
            return st.nextToken() ;
        }
        int nextInt() throws Exception
        {
            return Integer.parseInt(next()) ;
        }
        long nextLong() throws Exception
        {
            return Long.parseLong(next()) ;
        }
    }
}
