codeparrot/codecomplex huggingface dataset:
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        int MOD = 1000000007;

        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            long x = in.nextLong();
            long k = in.nextLong();
            if (x == 0) {
                out.print(0);
                return;
            }
            long b = fast_expo(2, k);
            long a = (b * 2) % MOD;

            long u = ((x % MOD) * a) % MOD;
            long v = (b - 1 + MOD) % MOD;
            out.print((u - v + MOD) % MOD);
        }

        private long fast_expo(long a, long b) {
            long res = 1L;
            a = a % MOD;
            while (b > 0) {
                if ((b & 1) != 0) {
                    res = (res * a) % MOD;
                }
                b = b >> 1;
                a = (a * a) % MOD;
            }
            return res % MOD;
        }

    }

    static class FastScanner {
        private BufferedReader bufferedReader;
        private StringTokenizer stringTokenizer;

        public FastScanner(InputStream inputStream) {
            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        }

        public String next() {
            while (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jenish
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C489 solver = new C489();
        solver.solve(1, in, out);
        out.close();
    }

    static class C489 {
        int mod = 1000000007;

        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            long x = in.scanLong();
            long k = in.scanLong();
            if (x == 0) {
                out.println(0);
                return;
            }
            long p = CodeX.power(2, k, mod);
            long ans = (2 * p * (x % mod)) % mod;
            ans = (ans + 1) % mod;
            ans = (ans - p + mod) % mod;
            out.println(ans);
        }

    }

    static class CodeX {
        public static long power(long x, long y, long p) {
            long res = 1;
            x = x % p;
            while (y > 0) {
                if ((y & 1) != 0)
                    res = (res * x) % p;
                y = y >> 1;
                x = (x * x) % p;
            }
            return res;
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int INDEX;
        private BufferedInputStream in;
        private int TOTAL;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (INDEX >= TOTAL) {
                INDEX = 0;
                try {
                    TOTAL = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (TOTAL <= 0) return -1;
            }
            return buf[INDEX++];
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

        public long scanLong() {
            long I = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    I *= 10;
                    I += n - '0';
                    n = scan();
                }
            }
            return neg * I;
        }

    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/** Built using CHelper plug-in Actual solution is at the top */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskC solver = new TaskC();
    solver.solve(1, in, out);
    out.close();
  }

  static class TaskC {
    static final long MODULO = (int) (1e9 + 7);

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      long x = in.nextLong();
      long k = in.nextLong();

      if (x == 0) {
        out.println(0);
      } else {
        long e = modPow(2, k, MODULO);
        long y = 2 * x - 1;
        long w = ((e % MODULO) * (y % MODULO)) % MODULO;
        long z = (w + 1) % MODULO;
        out.println(z);
      }
    }

    private long modPow(long a, long b, long m) {
      if (b == 0) return 1 % m;
      if (b == 1) return a % m;
      long res = modPow(a, b / 2, m);
      res = (res * res) % m;
      if (b % 2 == 1) res = (res * a) % m;
      return res;
    }
  }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        new Solver().run(1);
    }
}

class Solver {

    private BufferedReader reader = null;
    private StringTokenizer st = null;

    private static final long MOD = (long)1e9 + 7;
    private long x, k;

    public void run(int inputType) throws Exception {
        if (inputType == 0)
            reader = new BufferedReader(new FileReader("input.txt"));
        else
            reader = new BufferedReader(new InputStreamReader(System.in));

        st = new StringTokenizer(reader.readLine());
        x = Long.parseLong(st.nextToken());
        k = Long.parseLong(st.nextToken());

        if (x == 0) {
            System.out.println(0);
            return;
        }

        long pow = binpow(2, k);
        long m = (2 * x) % MOD;

        m = (m - 1 < 0) ? MOD - 1 : m - 1;

        m = (m * pow) % MOD;
        m = (m + 1) % MOD;

        System.out.println(m);

        reader.close();
    }

    long binpow(long v, long p) {
        long res = 1L;
        while(p > 0) {

            if ((p & 1) > 0)
                res = (res * v) % MOD;

            v = (v * v) % MOD;
            p /= 2;
        }

        return res;
    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.math.BigInteger;
import java.util.Scanner;

public class TaskC {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		BigInteger x = new BigInteger(sc.next());
		BigInteger k = new BigInteger(sc.next());

		BigInteger mod = new BigInteger(String.valueOf((int) (Math.pow(10, 9) + 7)));

		BigInteger two = new BigInteger("2");
		BigInteger interm = two.modPow(k, mod);

		BigInteger res = interm.multiply(x).add(interm.multiply(x)).subtract(interm).add(BigInteger.ONE).mod(mod);

		if(x.equals(BigInteger.ZERO)) {
			System.out.println("0");
			return;
		}
		System.out.println(res);
	}

}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Tester
{
    
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    
    static long mod = 1000000007;
    public static void main(String[] args) {
    	
    	solveQ3();
    
    }

	private static void solveQ3() {
		// TODO Auto-generated method stub
		
		FastReader sc = new FastReader();
		
		long x = sc.nextLong();
		long k = sc.nextLong();
		
		if(x == 0) {
			System.out.println(0);
			return;
		}
		long ans = modExp(2, k);
		x = (2*x)%mod;
		x = (x - 1 + mod)%mod;
		ans = (ans*x)%mod;
		ans = (ans + 1)%mod;
		
		System.out.println(ans);
		
	}
	
	private static long modExp(long a, long n) {
		
		if(n == 0)
			return 1;
		if(n%2 == 0)
			return modExp((a*a)%mod, n/2);
		else
			return (a*modExp((a*a)%mod, n/2))%mod;
		
	}

	private static void solveQ2() {
		// TODO Auto-generated method stub
		
		FastReader sc = new FastReader();
		long l = sc.nextLong();
		long r = sc.nextLong();
		
		long x = sc.nextLong();
		long y = sc.nextLong();
		
		long n = x*y;
		long count = 0;
		
		for(long i=l; (i<=Math.sqrt(n)) && (n/i<=r); i++) {
			
			if((n%i == 0) && (gcd(i, n/i)==x)) {
				
				if(i*i != n)
					count += 2;
				else
					count += 1;
				
			}
			
		}
		
		System.out.println(count);
		
		
	}
	
	public static long gcd(long a, long b) {
		
		if(b==0)
			return a;
		else
			return gcd(b, a%b);
		
	}

	private static void solveQ1() {
		// TODO Auto-generated method stub
		
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		
		HashSet<Integer> hs = new HashSet<Integer>();
		for(int i=0; i<n; i++) {
			int x = sc.nextInt();
			if(x != 0) {
				hs.add(x);
			}
		}
		
		System.out.println(hs.size());
				
		
	}
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
//package pack;

import java.util.*;

public class first
{
	public static long power(long x, long y, long p)
    {
        long res = 1;
        x = x % p; 
        while (y > 0)
        {	if((y & 1)==1)
                res = (res * x) % p;
            y = y >> 1; 
            x = (x * x) % p; 
        }
        return res;
    }
	
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		long x=sc.nextLong();
		long k=sc.nextLong();
		long mod=1000000007;
		if(k==0 || x==0)
			System.out.println((2*x)%mod);
		else
		{	long answer=1;
			answer+=(power(2,k,mod))*(((2*x)-1)%mod);
			System.out.println(answer%mod);
		}
	}
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
 
public class Main
{	
	
	long mod = 1000000007;
	
	long pow(long x,long y)
	{
		if(y==0)
			return 1;
		else if(y==1)
			return x%mod;
		else if(y%2==0)
			return pow((x*x)%mod,y/2)%mod;
		else
			return (x*pow((x*x)%mod,y/2)%mod)%mod;
	}
	
	void solve()
	{
		FastReader sc =new FastReader();
		long x = sc.nextLong();
		long k = sc.nextLong();
		
		if(x == 0) {
			System.out.println(0);
			return;
		}
		long ans = pow(2, k);
		x = (2*x)%mod;
		x = (x - 1 + mod)%mod;
		ans = (ans*x)%mod;
		ans = (ans + 1)%mod;
		
		System.out.println(ans);
	}

    public static void main(String[] args)
    {
        new Main().solve();
    }
	
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CNastyaAndAWardrobe solver = new CNastyaAndAWardrobe();
        solver.solve(1, in, out);
        out.close();
    }

    static class CNastyaAndAWardrobe {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            long x = in.nextLong();
            long k = in.nextLong();
            if (x == 0) {
                out.println(0);
            } else {
                long mod = (long) (1e9 + 7);
                long ans = (((((2 * x - 1) % mod)) * power(2, k, mod)) % mod) + 1;
                ans %= mod;
                out.println(ans);
            }

        }

        long power(long x, long y, long p) {
            long res = 1;
            x = x % p;
            while (y > 0) {
                if ((y & 1) > 0)
                    res = (res * x) % p;
                y = y >> 1;
                x = (x * x) % p;
            }
            return res;
        }

    }

    static class FastScanner {
        private final InputStream stream;
        private final byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public FastScanner(InputStream stream) {
            this.stream = stream;
        }

        int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
//package com.company;

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

public class Main {
    static long TIME_START, TIME_END;
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//        Scanner sc = new Scanner(new FileInputStream("Test.in"));
        PrintWriter pw = new PrintWriter(System.out);
//        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.out"));
//        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.in"));
        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
        System.out.println("Memory increased:" + (usedMemoryAfter-usedMemoryBefore) / 1000000 );
        System.out.println("Time used: " + (TIME_END - TIME_START) + ".");
    }

    public static class Task {
        int mod = 1_000_000_007;
        public long pow(long a, long b) {
            if (b == 0) return 1L;
            if (b % 2 == 0) return pow(a * a % mod, b >> 1);
            return a * pow(a * a % mod, b >> 1) % mod;
        }
        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            long T = sc.nextLong();
            long k = sc.nextLong();
            if (T == 0) {
                pw.println(0);
                return;
            }
            long a1 = pow(2, k + 1);
            long a2 = pow(2, k);
            long s = a1 * (T % mod) % mod;
            long t = ((1 - a2) + mod) % mod;
            long y = (s + t) % mod;
            pw.println((y + 5L * mod) % mod);
        }





    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

        public Scanner(FileReader s) throws FileNotFoundException {br = new BufferedReader(s);}

        public String next() throws IOException
        {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {return Integer.parseInt(next());}

        public long nextLong() throws IOException {return Long.parseLong(next());}

        public String nextLine() throws IOException {return br.readLine();}

        public double nextDouble() throws IOException { return Double.parseDouble(next()); }

        public boolean ready() throws IOException {return br.ready();}
    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.*;

public class C {

	static long x, k;
	static long mod = 1000000007;
	public static void main(String[] args) {
		JS in = new JS();
		x = in.nextLong();
		k = in.nextLong();
		
		if(x==0) {
			System.out.println(0);
			return;
		}
		
		long c = pow(2,k);
		if(c==0) c = mod;
		long sub = c-1;
		
		long low = ((c*(x%mod))%mod - sub);
		while(low < 0) low += mod;
		long res = ((low*2)%mod + sub)%mod;
		
		System.out.println(res);
		
		
	}
	
	static long pow(long a, long p) {
		if(p==0) return 1;
		if(p==1) return a;
		if(p%2==0) {
			long res = pow(a,p/2)%mod;
			return (res*res)%mod;
		}
		else {
			return (pow(a,p-1)*a)%mod;
		}
		
	}
	
	static class JS{
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;
		
		public JS() {
			in = new BufferedInputStream(System.in, BS);
		}
		
		public JS(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}
		
		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}				
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}
		
		public int nextInt() {
			return (int)nextLong();
		}
		
		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}
		
		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}
		
		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}
		
		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
	}
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class C {
	static final int M = 1000000007;	
	
	public static void main(String[] args) throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(in.readLine());
		
		long x = Long.parseLong(st.nextToken());
		if(x == 0){
			System.out.println(0);
			System.exit(0);
		}
		final long k = Long.parseLong(st.nextToken());	
		x = x%M;
		
		long ans = (exp(2, k+1)*x - (exp(2, k) - 1))%M;
		if(ans < 0) ans += M;
		System.out.println(ans);
		/*
		for(long i = 1234567890; i < 1234567999; i++){
			ans = (exp(2, i+1)*x - (exp(2, i) - 1))%M;
			if(ans < 0) ans += M;
			System.out.println(ans);
		}
		/*
		System.out.println((k-1)/2);
		System.out.println(x);
		System.out.println(exp(2, k));
		System.out.println(exp(2, k+1));
		*/
	}
	
	public static long exp(long a, long n){
		if(n == 0) return 1;
		if(n == 1) return a%M;
		if(n%2 == 0) return exp((a*a)%M, n/2);
		else return (a*exp((a*a)%M, (n-1)/2))%M;
	}
}