#include <iostream>
#include <cstdio>
using namespace std;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
const int MOD=1e9+7;
int n,k;
int power(int x) {
int mul=1;
for(int i=1;i<=x;i++) {
mul=(mul*2)%MOD;
}
return mul;
}
int main() {
n=read(),k=read();
if(k>=n) {
cout<<power(n)<<endl;
}
else {
cout<<(power(n-1)+(k*2)%MOD-1)%MOD<<endl;
}
return 0;
}