public class Magic {

  public static void main(String[] args) {
    System.out.println(magic());
  }

  int magic(int a, int n) {
      int r = 1;
      while (n != 0) {
          if (n % 2 == 1) {
              r *= a;
          }
          n /= 2;
          a *= a;
      }
      return r;
  }
}

