import java.util.Scanner;

public class Program1
{
	static int mod = 1000000007;
    public static void main(String[] args) throws InterruptedException
    {
    	Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
    	int b = sc.nextInt();
    	int ans = power(a,b)%mod;
    	System.out.println(ans);
    	sc.close();	
    }

	private static int power(int a, int b) 
	{
		if(b == 0)
			return 1;
		int pow = power(a,b/2);
		if(b%2 == 0)
		{
			return (pow*pow);
		}
		else
		{
			return (a*pow*pow);
		}
	}
}