import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    solve(in,out);
    out.close();
  }

  private static final int MOD = (int)1e9 + 7;

  private static long pow(long a, int b) {
	  long ans = 1;
	  while (b > 0) {
		  if ((b % 2) > 0) {
			  ans = ans * a %MOD;
		  }
		  a = a * a % MOD;
		  b >>= 1;
	  }
	  return ans;
  }

  private static void solve(InputReader in, PrintWriter out) {
	  int n = in.nextInt();
	  long m = in.nextLong();
	  long ans = n + 1;
	  if (m != 1) {
		  ans = pow(2 * m - 1, n) * m % MOD - pow(m, n) + MOD;
		  ans = ans * pow(m - 1, MOD - 2) %MOD;
	  }
	  //(2m-1)^n *m - m^n
	  //(m-1)
	  out.print(ans);
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

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

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

  }
}


import java.util.Arrays;
import java.util.Scanner;

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

        solve(s.nextInt(), s.nextInt(), s.nextInt(), s.nextInt(), s.nextInt(), s.nextInt());
    }

    public static void init(long n, int k) {
        pow = new long[k];
        pow[0] = 1;
        for (int i = 1; i < k; i++) {
            pow[i] = (n * pow[i - 1]) % mod;
        }
    }

    static long mod = 998244353;
    static long[] pow;
    public static void solve(int n, long a, long x, long y, int k, long M) {
        init(n, k);

        int gcdR = gcdRange(k - 1);

        long[][] r = new long[gcdR][k + 1];

        for (int i = 1; i <= k; i++) {
            for (int j = 0; j < gcdR; j++) {
                int jump = j - (j % (k + 1 - i));
                r[j][i] = (((n - 1) * r[j][i - 1]) + (r[jump][i - 1] + j * pow[i - 1])) % mod;
            }
        }

        long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += r[(int)(a % gcdR)][k] + ((((a / gcdR) * gcdR * k) % mod) * pow[k - 1]) % mod;
            sum %= mod;
            a = (a * x + y) % M;
        }

        System.out.println(sum);
    }

    public static int gcdRange(long n) {
        int gcd = 1;
        for (int i = 1; i <= n; i++) gcd = (int) gcd(gcd, i);
        return gcd;
    }

    public static long gcd(long a, long b) {
        return a * b / ggt(a, b);
    }

    public static long ggt(long a, long b) {
        if (a < b) return ggt(b, a);
        if (b == 0) return a;
        return ggt(b, a % b);
    }
}


//package work5march;

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

public class A_VK_CUP2017 {

	public static void main(String[] args) throws IOException
	{
		 new A_VK_CUP2017().run();
	   }

	   StreamTokenizer in;
	   PrintWriter out;

	   int nextInt() throws IOException
	   {
	      in.nextToken();
	      return (int)in.nval;
	   }

	   void run() throws IOException
	   {
	      in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
	      out = new PrintWriter(new OutputStreamWriter(System.out));
	      solve();
	      out.flush();
	   }

	   void solve() throws IOException
	   {
		   int n=nextInt();
		   //int n=in.nextToken();
		   int a[]=new int[n+1];
		   float s=0;
		   for (int i=1;i<=n;i++)
		   {
			   a[i]=nextInt();
			   s=s+a[i];
		   }
		   s=s/n;
		   int min=1;
		   float b;

		   for (int i=1;i<=n;i++)
		   {
			   b=Math.abs(s-a[i]);
			   if (i>1 & b<Math.abs(s-a[min])){
				   min=i;
			   }
		   }
		   int res=a[min];
		   out.println(res);

	   }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class D {

	public D () throws IOException {
		String S = sc.next();
		String E = sc.next();
		int K = sc.nextInt();
		solve(S,E,K);
	}

	int MOD = 1000000007;
	BigInteger BMOD = BigInteger.valueOf(MOD);
	int mod(long x) { return (int)((x + 1L*MOD*MOD) % MOD); }

	public void solve (String S, String E, int K) {
		int N = S.length();
		BigInteger
			BB = BigInteger.valueOf(N-1),
			BN = BigInteger.valueOf(N),
			BK = BigInteger.valueOf(K),
			M1 = BigInteger.valueOf(-1);

		BigInteger
			BS = BB.modPow(BK, BMOD),
			BM = M1.modPow(BK, BMOD),
			BT = BS.subtract(BM).multiply(BN.modInverse(BMOD)).mod(BMOD);

		int A0 = mod(BT.add(BM).intValue()), A = mod(BT.intValue()), res = 0;
		if (S.equals(E))
			res = mod(res + A0);
		for (int i = 1; i < N; ++i)
			if ((S.substring(i, N) + S.substring(0, i)).equals(E))
					res = mod(res + A);

		exit(res);
	}

	////////////////////////////////////////////////////////////////////////////////////

	static MyScanner sc;
	static long t;

	static void print (Object o) {
		System.out.println(o);
	}

	static void exit (Object o) {
		print(o);
		//print2((millis() - t) / 1000.0);
		System.exit(0);
	}

	static void run () throws IOException {
		sc = new MyScanner ();
		new D();
	}

	public static void main(String[] args) throws IOException {
		run();
	}

	static long millis() {
		return System.currentTimeMillis();
	}

	static void start() {
		t = millis();
	}

	static class MyScanner {
		String next() throws IOException {
			newLine();
			return line[index++];
		}

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

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

		String nextLine() throws IOException {
			line = null;
			return r.readLine();
		}

		//////////////////////////////////////////////

		private final BufferedReader r;

		MyScanner () throws IOException {
			this(new BufferedReader(new InputStreamReader(System.in)));
		}

		MyScanner(BufferedReader r) throws IOException {
			this.r = r;
		}

		private String [] line;
		private int index;

		private void newLine() throws IOException {
			if (line == null || index == line.length) {
				line = r.readLine().split(" ");
				index = 0;
			}
		}
	}
}


import java.io.*;
import java.util.*;
public class E15 {
public static void main(String[] args) throws IOException {
	input.init(System.in);
	PrintWriter out = new PrintWriter(System.out);
	int n = input.nextInt();
	long mod = (long)1e9+9;
	long b = 2;
	long add = 4;
	long mult = 1;
	for(int i = 0; i<n/2 - 1; i++)
	{
		mult = (mult*2+3)%mod;
		b = (b + add)%mod;
		add = (add*mult)%mod;
	}
	long res = ((b*b + 1))*2%mod;
	out.println(res);

	out.close();
}

public static class input {
	static BufferedReader reader;
	static StringTokenizer tokenizer;

	static void init(InputStream input) {
		reader = new BufferedReader(new InputStreamReader(input));
		tokenizer = new StringTokenizer("");
	}

	static String next() throws IOException {
		while (!tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(reader.readLine());
		return tokenizer.nextToken();
	}

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

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

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


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

public class increasing_prefix_ors_3xNTT {

    final static long p = 1000000007;

    static class Value {
        int[] poly;
        long mul;

        public Value(int[] poly, long mul) {
            this.poly = poly;
            this.mul = mul;
        }

        Value mul(Value o) {
            return new Value(Arrays.copyOf(polyMul(substitute(poly, o.mul), o.poly), poly.length), mul * o.mul % p);
        }
    }

    static Value pow(Value x, Value one, long pow) {
        while (pow > 0) {
            if (pow % 2 == 1) {
                one = one.mul(x);
            }
            pow /= 2;
            x = x.mul(x);
        }
        return one;
    }

    public static void solve(Input in, PrintWriter out) throws IOException {
        // d'_j*(k-j)! += d_i*(k-i)! / (j-i)! * 2^i
        long n = in.nextLong();
        int k = in.nextInt();
        if (n > k + 1) {
            out.println(0);
            return;
        }
        int[] poly0 = new int[k + 1];
        int[] poly1 = new int[k + 1];
        for (int i = 1; i <= k; ++i) {
            poly0[i] = (int) (fact[k] * invFact[i] % p);
            poly1[i] = (int) invFact[i];
        }
        Value v = pow(new Value(poly1, 2), new Value(poly0, 1), n - 1);
        long ans = 0;
        for (int i = 0; i <= k; ++i) {
            ans = (ans + v.poly[i] * invFact[k - i]) % p;
        }
        out.println(ans);
    }

    static int max = 30000;
    static long[] fact, invFact, invs;
    static {
        fact = new long[max + 1];
        invFact = new long[max + 1];
        fact[0] = 1;
        invFact[0] = 1;
        invs = new long[max + 1];
        for (int i = 1; i <= max; ++i) {
            invs[i] = i == 1 ? 1 : (int) (p - invs[((int) (p % i))] * (p / i) % p);
            fact[i] = fact[i - 1] * i % p;
            invFact[i] = invFact[i - 1] * invs[i] % p;
        }
    }

    static long modInverse(long x, long mod) {
        return modPow(x, mod - 2, mod);
    }

    static long modPow(long x, long pow, long mod) {
        long r = 1;
        while (pow > 0) {
            if (pow % 2 == 1) {
                r = (r * x) % mod;
            }
            pow /= 2;
            x = (x * x) % mod;
        }
        return r;
    }

    static int[] substitute(int[] a, long c) {
        int[] r = new int[a.length];
        long pow = 1;
        for (int i = 0; i < a.length; ++i) {
            r[i] = (int) (a[i] * pow % p);
            pow = pow * c % p;
        }
        return r;
    }

    static class FFT {
        int[][] tail;
        int[][] omegas;
        final int mod;
        final int LOG = 18;

        int G;

        FFT(int mod, int g) {
            this.mod = mod;
            G = g;
            tail = new int[LOG][];
            omegas = new int[LOG][];
            for (int l = 0; l < LOG; l++) {
                tail[l] = new int[1 << l];
                omegas[l] = new int[1 << l];
                int w = (int)modPow(G, (mod - 1) / (1 << l), mod);

                omegas[l][0] = 1;
                for (int i = 1; i < 1 << l; i++) {
                    tail[l][i] = (tail[l][i >> 1] >> 1) | ((i & 1) << (l - 1));
                    omegas[l][i] = (int) ((1l * omegas[l][i - 1] * w) % mod);
                }
            }
        }

        void doFFT(int[] a, int size, boolean inverse) {
            int l = Integer.numberOfTrailingZeros(size);
            int[] tail = this.tail[l], omegas = this.omegas[l];
            for (int i = 0; i < size; i++) {
                if (i < tail[i]) {
                    int tmp = a[i];
                    a[i] = a[tail[i]];
                    a[tail[i]] = tmp;
                }
            }
            for (int len = 2; len <= size; len *= 2) {
                int add = size / len;
                for (int i = 0; i < size; i += len) {
                    int pos = 0;
                    for (int j = 0, k = len / 2; k < len; j++, k++) {
                        int u = a[i + j], v = (int) ((1l * a[i + k] * omegas[pos]) % mod);
                        a[i + j] = (u + v);
                        a[i + k] = (u - v + mod);
                        if (a[i + j] >= mod) {
                            a[i + j] -= mod;
                        }
                        if (a[i + k] >= mod) {
                            a[i + k] -= mod;
                        }

                        if (inverse) {
                            pos -= add;
                            if (pos < 0) {
                                pos += size;
                            }
                        } else {
                            pos += add;
                        }
                    }
                }
            }
            if (inverse) {
                int inv = (int)modInverse(size, mod);
                for (int i = 0; i < size; i++) {
                    a[i] = (int) ((1L * inv * a[i]) % mod);
                }
            }
        }

        int[] conv(int[] a, int[] b) {
            int size = 1;
            while (size < a.length || size < b.length) {
                size *= 2;
            }
            size *= 2;
            a = Arrays.copyOf(a, size);
            b = Arrays.copyOf(b, size);
            doFFT(a, size, false);
            doFFT(b, size, false);
            for (int i = 0; i < size; ++i) {
                a[i] = (int) (1L * a[i] * b[i] % mod);
            }
            doFFT(a, size, true);
            return a;
        }
    }

    final static int mod1 = 998244353; // G = 3
    final static int mod2 = 1012924417; // G = 5
    final static int mod3 = 1045430273; // G = 3

    final static CRT e = new CRT(mod1, mod2, mod3);
    final static FFT fft1 = new FFT(mod1, 3);
    final static FFT fft2 = new FFT(mod2, 5);
    final static FFT fft3 = new FFT(mod3, 3);

    private static int[] polyMul(int[] a, int[] b) {
        int n = a.length;
        int[] a1 = fft1.conv(a, b);
        int[] a2 = fft2.conv(a, b);
        int[] a3 = fft3.conv(a, b);
        a = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = (int) (e.crt(a1[i], a2[i], a3[i]).mod(BigInteger.valueOf(p)).longValue());
        }
        return a;
    }

    static class CRT {
        long[] mods;
        long[][] r;

        public CRT(long... mods) {
            this.mods = mods;
            r = new long[mods.length][mods.length];
            for (int i = 0; i < mods.length; ++i) {
                for (int j = i + 1; j < mods.length; ++j) {
                    r[i][j] = modInverse(mods[i], mods[j]);
                }
            }
        }

        BigInteger crt(long... rs) {
            BigInteger result = BigInteger.ZERO, mult = BigInteger.ONE;
            for (int i = 0; i < rs.length; ++i) {
                for (int j = 0; j < i; ++j) {
                    long cur = (rs[i] - rs[j]) * r[j][i];
                    rs[i] = (int)((cur % mods[i] + mods[i]) % mods[i]);
                }
                result = result.add(mult.multiply(BigInteger.valueOf(rs[i])));
                mult = mult.multiply(BigInteger.valueOf(mods[i]));
            }
            return result;
        }
    }

    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        solve(new Input(new BufferedReader(new InputStreamReader(System.in))), out);
        out.close();
    }

    static class Input {
        BufferedReader in;
        StringBuilder sb = new StringBuilder();

        public Input(BufferedReader in) {
            this.in = in;
        }

        public Input(String s) {
            this.in = new BufferedReader(new StringReader(s));
        }

        public String next() throws IOException {
            sb.setLength(0);
            while (true) {
                int c = in.read();
                if (c == -1) {
                    return null;
                }
                if (" \n\r\t".indexOf(c) == -1) {
                    sb.append((char)c);
                    break;
                }
            }
            while (true) {
                int c = in.read();
                if (c == -1 || " \n\r\t".indexOf(c) != -1) {
                    break;
                }
                sb.append((char)c);
            }
            return sb.toString();
        }

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

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

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


import java.util.*;

public class UpTheStrip_1558B {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		sc.close();
		long[] dp = new long[n + 1];
		dp[1] = 1;
		for (int i=2; i<n+1; i++) {
			dp[i] = (dp[i] + 2*dp[i-1] + 1)%m;

			if (i==2) {
				dp[i]--;
			}

			for (int j = 2; j<=n; j++) {
				if (i*j > n) break;
				dp[i*j] = (dp[i*j] + dp[i] - dp[i-1])%m;
			}
			if (dp[i] < 0) {
				dp[i] += m;
			}
		}
		System.out.println(dp[n]);
	}
}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;

import java.util.StringTokenizer;

 public class Test
 {
     static PrintWriter pw = new PrintWriter(System.out);
     static ArrayList<Integer> list = new ArrayList();

    public static void main(String[] args)throws Exception
    {
        Reader.init(System.in);
        int n = Reader.nextInt();
        int k = Reader.nextInt();
        HashMap<Integer , Integer> set = new HashMap();
        boolean[] flags = new boolean[n+1];
        int[] res = new int[n+1];
        int[] game = new int[k];
        int count = 0;
        int temp = 0;

        for(int i = 0 ; i<k ; i++)game[i] = Reader.nextInt();

        for(int i = 0 ; i<k-1 ; i++)
        {

            int a = game[i];
            int b = game[i+1];

            if(b>a)
                temp = b - a;
            else
                temp =  b + (n-a);

            if(set.containsKey(temp) && set.get(temp) != a)
            {
                pw.print(-1);
                pw.close();
                return;
            }
            else if(res[a] != 0 && res[a] != temp)
            {
                pw.print(-1);
                pw.close();
                return;
            }
            else if(!set.containsKey(res[a]))
            {

                set.put(temp , a);
                res[a] = temp;
                count ++;
                flags[res[a]] = true;
            }

        }

        if(count <n)
        {
            for(int i = 1 ; i<=n ; i++)
                if(!flags[i])
                {
                    list.add(i);

                }
        }

        StringBuilder str = new StringBuilder();
        Iterator<Integer> itr = list.iterator();

        for(int i = 1 ; i<=n ; i++)
            if(res[i] == 0)
            {
                str.append(itr.next()).append(" ");

            }
            else
                str.append(res[i]).append(" ");

        pw.print(str);
        pw.close();
    }

}

class Reader {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    public static int pars(String x) {
        int num = 0;
        int i = 0;
        if (x.charAt(0) == '-') {
            i = 1;
        }
        for (; i < x.length(); i++) {
            num = num * 10 + (x.charAt(i) - '0');
        }

        if (x.charAt(0) == '-') {
            return -num;
        }

        return num;
    }

    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    static void init(FileReader input) {
        reader = new BufferedReader(input);
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return pars(next());
    }

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

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


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

public class HeidiAndTheTuringTest {
    public static void main(String[] args) throws IOException
    {
       int N = nextInt();
       int[] xCoords = new int[51];
       int[] yCoords = new int[51];
       int[][] coords = new int[51][2];
       for (int i = 0; i < ((4 * N) + 1); i++)
       {
           int X = nextInt();
           int Y = nextInt();
           xCoords[X]++;
           yCoords[Y]++;
           coords[i] = new int[] {X, Y};
       }
       int bottomX = -1;
       int topX = -1;
       int bottomY = -1;
       int topY = -1;
       for (int i = 0; i < 51; i++)
       {
           if (xCoords[i] > 1 && bottomX == -1)
           {
               bottomX = i;
           }
           if (yCoords[i] > 1 && bottomY == -1)
           {
               bottomY = i;
           }
           if (bottomX != -1)
           {
               if (xCoords[i] > 1)
               {
                   topX = i;
               }
           }
           if (bottomY != -1)
           {
               if (yCoords[i] > 1)
               {
                   topY = i;
               }
           }
       }
       for (int i = 0; i < 51; i++)
       {
           int X = coords[i][0];
           int Y = coords[i][1];
           if (X < topX && X > bottomX && Y != topY && Y != bottomY || Y < topY && Y > bottomY && X != bottomX && X != topX)
           {
               System.out.println(X + " " + Y);
               break;
           } else if (X > topX || X < bottomX || Y > topY || Y < bottomY)
           {
               System.out.println(X + " " + Y);
               break;
           }
       }

    }

    //Template
    private static StringTokenizer line = new StringTokenizer("");
    private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    private static int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    private static long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    private static String nextString() throws IOException
    {
        if (line.hasMoreTokens())
        {
            return line.nextToken();
        } else {
            line = new StringTokenizer(in.readLine());
            return line.nextToken();
        }
    }
    private static String[] nextStringArray() throws IOException
    {
        return in.readLine().split(" ");
    }
    private static int[] nextIntArray() throws IOException
    {
        return Arrays.stream(nextStringArray()).mapToInt(Integer::parseInt).toArray();
    }
}


//package ecr012;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;

public class F3 {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	public long[][] divsieve(long n)
	{
//		int K = n == 1 ? 1 : (int)Math.pow(n/Math.log(n)*Math.log(2), 2./3);
		int K = n == 1 ? 1 : (int)Math.pow(n, 2./3);
		tr(K);
//		int nK = (int)(n/K);
		int[] primes = sieveEratosthenes((int)Math.sqrt(n));

		List<Long> qs = new ArrayList<>(50000000);
		dfs1(n, 0, K, qs, primes);
		tr(qs.size());

		return null;
	}

	int ct = 0;

	void dfs1(long n, int prev, int K, List<Long> qs, int[] primes)
	{
		if(n < K) {
//			qs.add(new int[] {(int)n, prev});
			qs.add(n<<32|prev);
			if(qs.size() % 100000 == 0)tr(qs.size());
			ct++;
			if(ct % 1000000 == 0)tr(ct);
		}else {
			int u = Arrays.binarySearch(primes, (int)Math.sqrt(n));
			if(u < 0)u = -u-2;
			for(int i = u;i >= 0;i--) {
				dfs1(n/primes[i], i, K, qs, primes);
			}
		}
	}

	public static int[] sieveEratosthenes(int n) {
		if (n <= 32) {
			int[] primes = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 };
			for (int i = 0; i < primes.length; i++) {
				if (n < primes[i]) {
					return Arrays.copyOf(primes, i);
				}
			}
			return primes;
		}

		int u = n + 32;
		double lu = Math.log(u);
		int[] ret = new int[(int) (u / lu + u / lu / lu * 1.5)];
		ret[0] = 2;
		int pos = 1;

		int[] isnp = new int[(n + 1) / 32 / 2 + 1];
		int sup = (n + 1) / 32 / 2 + 1;

		int[] tprimes = { 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 };
		for (int tp : tprimes) {
			ret[pos++] = tp;
			int[] ptn = new int[tp];
			for (int i = (tp - 3) / 2; i < tp << 5; i += tp)
				ptn[i >> 5] |= 1 << (i & 31);
			for (int j = 0; j < sup; j += tp) {
				for (int i = 0; i < tp && i + j < sup; i++) {
					isnp[j + i] |= ptn[i];
				}
			}
		}

		// 3,5,7
		// 2x+3=n
		int[] magic = { 0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4, 13, 31, 22, 28, 18, 26, 10, 7, 12, 21, 17,
				9, 6, 16, 5, 15, 14 };
		int h = n / 2;
		for (int i = 0; i < sup; i++) {
			for (int j = ~isnp[i]; j != 0; j &= j - 1) {
				int pp = i << 5 | magic[(j & -j) * 0x076be629 >>> 27];
				int p = 2 * pp + 3;
				if (p > n)
					break;
				ret[pos++] = p;
				if ((long) p * p > n)
					continue;
				for (int q = (p * p - 3) / 2; q <= h; q += p)
					isnp[q >> 5] |= 1 << q;
			}
		}

		return Arrays.copyOf(ret, pos);
	}

	int[] primes = sieveEratosthenes(1000000);

	void solve()
	{
		long n = nl();
		long ans = 0;
		MeisselLehmer2 ml = new MeisselLehmer2(n);
		for(int i = 0;i < primes.length;i++) {
			long plus = ml.pi(n/primes[i]) - (i+1);
			if(plus <= 0)break;
			ans += plus;
		}

		for(int p : primes) {
			if((long)p*p*p <= n) {
				ans++;
			}else {
				break;
			}
		}
		out.println(ans);
	}

	public static class MeisselLehmer2 {
		int[] primes;
//		int[] cump;
		int[] xcums;
		long[] isp;

		int cachelimit;
//		Map<Long, Long> picache;
//		Map<Long, Long> phicache;
		LongHashCounterL picache;
		LongHashCounterL phicache;
		boolean cachePhi = true;

		int[][] cumps;
//		int[] FP = {2,3,5,7,11,13,17};
		int[] FP = {2,3,5,7,11,13,17,19};
		int M = FP.length;

		int B = 100;
		// 10^14 -> 200
		// 10^14/8 -> 100~200

		public MeisselLehmer2(long n)
		{
			assert n >= 4;
//			picache = new HashMap<>();
//			phicache = new HashMap<>();
			picache = new LongHashCounterL();
			phicache = new LongHashCounterL();

			int s = (int)Math.sqrt(n)*B; // not overflow!
			cachelimit = s;
			this.primes = sieveEratosthenes(s);
			xcums = new int[(s>>>6)+1];
			isp = new long[(s>>>6)+1];
			for(int p : primes)isp[p>>>6] |= 1L<<p;
			for(int i = 0;i < xcums.length-1;i++)xcums[i+1] = xcums[i] + Long.bitCount(isp[i]);

			cumps = new int[M][];
			boolean[] b = {true};
			int len = 1;
			for(int i = 0;i < M;i++){
				len *= FP[i];
				boolean[] c = new boolean[len];
				for(int j = 0;j < FP[i];j++){
					System.arraycopy(b, 0, c, j*b.length, b.length);
				}
				for(int k = 0;k < len;k+=FP[i])c[k] = false;
				cumps[i] = new int[len+1];
				for(int j = 0;j < len;j++)cumps[i][j+1] = cumps[i][j] + (c[j] ? 1 : 0);
				FP[i] = len;
				b = c;
			}
		}

		private long sqrt(long n)
		{
			long i = Math.max(0, (long)Math.sqrt(n)-2);
			while(i*i <= n)i++;
			return i-1;
		}

		private long cbrt(long n)
		{
			long i = Math.max(0, (long)Math.cbrt(n)-2);
			while(i*i*i <= n)i++;
			return i-1;
		}

		public long pi(long x)
		{
			if(x <= cachelimit){
				int ix = (int)x;
				return xcums[ix>>>6] + Long.bitCount(isp[ix>>>6]<<~ix);
//				return cump[(int)x];
			}
			if(picache.containsKey(x))return picache.get(x);

			int A = (int)pi(sqrt(sqrt(x)));
			long ret = A + phi(x, A) - P2(x, A) - P3(x, A) - 1;
			picache.put(x, ret);
			return ret;
		}

		private long phi(long x, int A)
		{
			if(A > 0 && A-1 < M){
				return cumps[A-1][FP[A-1]] * (x/FP[A-1]) + cumps[A-1][(int)(x%FP[A-1]+1)];
			}
			if(A > 0 && x <= (long)primes[A-1]*primes[A-1]){
				return pi(x) - A + 1;
			}
			long code = x<<13|A;
			if(phicache.containsKey(code))return phicache.get(code);

			long ret = x;
			for(int i = A-1;i >= 0;i--)ret -= phi(x/primes[i], i);

			if(cachePhi)phicache.put(code, ret);
			return ret;
		}

		private long P2(long x, int A)
		{
			int B = (int)pi(sqrt(x));
			long ret = 0;
			for(int i = A;i < B;i++){
				ret += pi(x/primes[i]);
			}
			ret -= (long)(B-A)*(B+A-1)/2;
			return ret;
		}

		private long P3(long x, int A)
		{
			int C = (int)pi(cbrt(x));
			long ret = 0;
			for(int i = A;i < C;i++){
				long xi = x/primes[i];
				int B = (int)pi(sqrt(xi));
				for(int j = i;j < B;j++){
					ret += pi(xi/primes[j]) - j;
				}
			}
			return ret;
		}

		public static int[] sieveEratosthenes(int n) {
			if (n <= 32) {
				int[] primes = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 };
				for (int i = 0; i < primes.length; i++) {
					if (n < primes[i]) {
						return Arrays.copyOf(primes, i);
					}
				}
				return primes;
			}

			int u = n + 32;
			double lu = Math.log(u);
			int[] ret = new int[(int) (u / lu + u / lu / lu * 1.5)];
			ret[0] = 2;
			int pos = 1;

			int[] isnp = new int[(n + 1) / 32 / 2 + 1];
			int sup = (n + 1) / 32 / 2 + 1;

			int[] tprimes = { 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 };
			for (int tp : tprimes) {
				ret[pos++] = tp;
				int[] ptn = new int[tp];
				for (int i = (tp - 3) / 2; i < tp << 5; i += tp)
					ptn[i >> 5] |= 1 << (i & 31);
				for (int j = 0; j < sup; j += tp) {
					for (int i = 0; i < tp && i + j < sup; i++) {
						isnp[j + i] |= ptn[i];
					}
				}
			}

			// 3,5,7
			// 2x+3=n
			int[] magic = { 0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4, 13, 31, 22, 28, 18, 26, 10, 7, 12, 21, 17,
					9, 6, 16, 5, 15, 14 };
			int h = n / 2;
			for (int i = 0; i < sup; i++) {
				for (int j = ~isnp[i]; j != 0; j &= j - 1) {
					int pp = i << 5 | magic[(j & -j) * 0x076be629 >>> 27];
					int p = 2 * pp + 3;
					if (p > n)
						break;
					ret[pos++] = p;
					if ((long) p * p > n)
						continue;
					for (int q = (p * p - 3) / 2; q <= h; q += p)
						isnp[q >> 5] |= 1 << q;
				}
			}

			return Arrays.copyOf(ret, pos);
		}

		private static class LongHashCounterL {
			public long[] keys;
			public long[] allocated;
			private int scale = 1<<2;
			private int rscale = 1<<1;
			private int mask = scale-1;
			public int size = 0;

			public LongHashCounterL(){
				allocated = new long[scale];
				Arrays.fill(allocated, NG);
				keys = new long[scale];
			}

			// if value is NG, entry is removed. (e.g. 0)
			private static final int NG = 0;

			public boolean containsKey(long x)
			{
				int pos = h(x)&mask;
				while(allocated[pos] != NG){
					if(x == keys[pos])return true;
					pos = pos+1&mask;
				}
				return false;
			}

			public long get(long x)
			{
				int pos = h(x)&mask;
				while(allocated[pos] != NG){
					if(x == keys[pos])return allocated[pos];
					pos = pos+1&mask;
				}
				return NG;
			}

			public long put(long x, long v)
			{
				int pos = h(x)&mask;
				while(allocated[pos] != NG){
					if(x == keys[pos]){
						long oldval = allocated[pos];
						allocated[pos] = v;
						return oldval;
					}
					pos = pos+1&mask;
				}
				if(size == rscale){
					resizeAndPut(x, v);
				}else{
					keys[pos] = x;
					allocated[pos] = v;
				}
				size++;
				return 0;
			}

			public long inc(long x, long v)
			{
				int pos = h(x)&mask;
				while(allocated[pos] != NG){
					if(x == keys[pos]){
						allocated[pos] += v;
						return allocated[pos];
					}
					pos = pos+1&mask;
				}
				if(size == rscale){
					resizeAndPut(x, v);
				}else{
					keys[pos] = x;
					allocated[pos] = v;
				}
				size++;
				return v;
			}

			public boolean remove(long x)
			{
				int pos = h(x)&mask;
				while(allocated[pos] != NG){
					if(x == keys[pos]){
						size--;
						// take last and fill rmpos
						int last = pos;
						pos = pos+1&mask;
						while(allocated[pos] != NG){
							int lh = h(keys[pos])&mask;
							// lh <= last < pos
							if(
									lh <= last && last < pos ||
									pos < lh && lh <= last ||
									last < pos && pos < lh
									){
								keys[last] = keys[pos];
								allocated[last] = allocated[pos];
								last = pos;
							}
							pos = pos+1&mask;
						}
						keys[last] = 0;
						allocated[last] = NG;

						return true;
					}
					pos = pos+1&mask;
				}
				return false;
			}

			private void resizeAndPut(long x, long v)
			{
				int nscale = scale<<1;
				int nrscale = rscale<<1;
				int nmask = nscale-1;
				long[] nallocated = new long[nscale];
				Arrays.fill(nallocated, NG);
				long[] nkeys = new long[nscale];
				for(int i = next(0);i < scale;i = next(i+1)){
					long y = keys[i];
					int pos = h(y)&nmask;
					while(nallocated[pos] != NG)pos = pos+1&nmask;
					nkeys[pos] = y;
					nallocated[pos] = allocated[i];
				}
				{
					int pos = h(x)&nmask;
					while(nallocated[pos] != NG)pos = pos+1&nmask;
					nkeys[pos] = x;
					nallocated[pos] = v;
				}
				allocated = nallocated;
				keys = nkeys;
				scale = nscale;
				rscale = nrscale;
				mask = nmask;
			}

			public int next(int itr)
			{
				while(itr < scale && allocated[itr] == NG)itr++;
				return itr;
			}

			private int h(long x)
			{
				x ^= x>>>33;
				x *= 0xff51afd7ed558ccdL;
				x ^= x>>>33;
				x *= 0xc4ceb9fe1a85ec53L;
				x ^= x>>>33;
				return (int)x;
			}

			@Override
			public String toString()
			{
				StringBuilder sb = new StringBuilder();
				for(int i = next(0);i < scale;i = next(i+1)){
					sb.append(",");
					sb.append(keys[i] + ":" + allocated[i]);
				}
				return sb.length() == 0 ? "" : sb.substring(1);
			}
		}
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception { new F3().run(); }

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


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

public class Main implements Runnable{
    public static void main(String[] args){
        //new Thread(null,new Main(),"Thread-1",1024*1024*10).start();
        new Main().run();
    }
    int mod=998244353;
    private void solve() throws Exception {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int n=in.nextInt(),k=in.nextInt(),l=in.nextInt();
        long[]fac=new long[n+1];
        fac[0]=1;
        for(int i=1;i<=n;i++){
            fac[i]=fac[i-1]*i%mod;
        }
        long[][]dp=new long[2*n+1][2*n+2];
        dp[0][0]=1;
        for(int i=1;i<=2*n;i++){
            for(int j=0;j<=i;j++){
                if(j>0) dp[i][j]=(dp[i][j]+dp[i-1][j-1])%mod;
                dp[i][j]=(dp[i][j]+dp[i-1][j+1]*(j+1)%mod)%mod;
            }
        }
        long ans=0;
        for(int i=k;i<=2*n;i++){
            for(int j=k;j<=n;j++){
                ans=(ans+dp[i][j]*dp[2*n-i][j]%mod*fac[j]%mod)%mod;
            }
        }
        out.println(l*ans%mod*Pow(dp[2*n][0],mod-2)%mod*Pow(2*n+1,mod-2)%mod);
        out.flush();
    }
    long Pow(long a,long b){
        long ans=1;
        while(b>0){
            if((b&1)!=0)ans=(ans*a)%mod;
            a=(a*a)%mod;
            b>>=1;
        }
        return ans;
    }
    @Override
    public void run() {
        try {
            solve();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    class InputReader{
        StreamTokenizer tokenizer;
        public InputReader(InputStream stream){
            tokenizer=new StreamTokenizer(new BufferedReader(new InputStreamReader(stream)));
            tokenizer.ordinaryChars(33,126);
            tokenizer.wordChars(33,126);
        }
        public String next() throws IOException {
            tokenizer.nextToken();
            return tokenizer.sval;
        }
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
        public boolean hasNext() throws IOException {
            int res=tokenizer.nextToken();
            tokenizer.pushBack();
            return res!=tokenizer.TT_EOF;
        }
    }
}


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

public class E {

	static int[] tree;

	static void fill(int idx) {
		if (idx >= tree.length) return;
		fill(2 * idx);
		fill(2 * idx + 1);
		tree[idx] = 1;
		if (2 * idx < tree.length) tree[idx] += tree[2 * idx];
		if (2 * idx + 1 < tree.length) tree[idx] += tree[2 * idx + 1];
	}

	static boolean shouldAdd(int idx) {
		if (idx % 2 == 1) return true;
		while (idx % 2 == 0) {
			idx /= 2;
		}
		return tree[2 * idx] % 2 == 0;
	}

	static void add(int idx) {
		while (idx >= 1) {
			tree[idx]++;
			idx /= 2;
		}
	}

	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		int level = 0, got = 1;
		while (N >= got) {
			N -= got;
			level++;
			got *= 2;
		}
		tree = new int[1 << level];
		fill(1);
		for (int i = tree.length - 1; i > 1 << (level-1); i--) {
			if (shouldAdd(i)) {
				add(i);
				N--;
			}
		}

		out.println(N == 0 || N == 1 ? 1 : 0);

		out.flush();
	}

	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

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


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

public class Main implements Runnable {
  final boolean isFileIO = false;
  BufferedReader in;
  PrintWriter out;
  StringTokenizer st = new StringTokenizer("");
  String delim = " ";

  public static void main(String[] args) {
    new Thread(null, new Main(), "", 268435456).start();
  }

  public void run() {
    try {
      initIO();
      solve();
      out.close();
    } catch(Exception e) {
      e.printStackTrace(System.err);
      System.exit(-1);
    }
  }

  public void initIO() throws IOException {
    if(!isFileIO) {
      in = new BufferedReader(new InputStreamReader(System.in));
      out = new PrintWriter(System.out);
    } else {
      in = new BufferedReader(new FileReader("input.txt"));
      out = new PrintWriter("output.txt");
    }
  }

  String nextToken() throws IOException {
    if(!st.hasMoreTokens()) {
      st = new StringTokenizer(in.readLine());
    }
    return st.nextToken(delim);
  }

  String readLine() throws IOException {
    return in.readLine();
  }

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

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

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

  void solve() throws IOException {
    int[] a = new int[4];
    int[] b = new int[4];
    for(int i = 0; i < 4; i++) {
      a[i] = nextInt(); b[i] =nextInt();
    }

    boolean isWin = true;
    for(int i = 0; i < 2; i++) {
      isWin = true;
      for(int j = 0; j < 2; j++) {
        if(!(a[i] > b[j + 2] && b[1 - i] > a[3 - j]))
          isWin = false;
      }
      if(isWin) {
        out.println("Team 1");
        return;
      }
    }
    for(int i = 0; i < 2; i++) {
      isWin = false;
      for(int j = 0; j < 2; j++) {
        if(b[i] < a[j + 2] && a[1 - i] < b[3 - j]) {
          isWin = true;
          break;
        }
      }
      if(!isWin) {
        out.println("Draw");
        return;
      }
    }
    if(isWin) {
      out.println("Team 2");
      return;
    }
  }
}


import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);

        //System.out.println(qmod(2,5,100));

        long S[][]=new long[5005][5005];
        long mod=998244353;
        S[1][1]=1;
        S[0][0]=0;
        for(int i=1;i<=5000;i++){
            S[i][i]=1;S[i][0]=0;
        }
        for(int i=2;i<=5000;i++){
            for(int j=1;j<=i;j++){
                S[i][j]=(S[i-1][j]*j%mod+S[i-1][j-1])%mod;
            }
        }
        long n=sc.nextLong();long m=sc.nextLong();int k=sc.nextInt();
        m=qmod(m,mod-2,mod);
        long dp[]=new long[5005];dp[0]=1;
        for(int i=1;i<=Math.min(n,k);i++)dp[i]=dp[i-1]*(n-i+1)%mod;

        long ans=0;
        for(int i=1;i<=Math.min(n,k);i++){
            ans=(ans+dp[i]*qmod(m,i,mod)%mod*S[k][i]%mod)%mod;
        }
        System.out.println(ans);

    }
    public static long qmod(long a,long b,long mod){
        long ans=1;
        while(b>=1){

            if((b&1)!=0){
                ans=ans*a%mod;
            }
            a=a*a%mod;
            b=b>>1;
        }return ans;
    }
}


import java.io.IOException;
import java.io.InputStreamReader;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.StringTokenizer;
import java.io.InputStream;

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

class TaskD {
    public void solve(int testNumber, Reader in, OutputWriter out) {
        long n = in.nextLong();
        ArrayList<Integer> lengths = new ArrayList<Integer>();
        long ones = n;
        boolean[] used = new boolean[101010];
        for(int i = 2; i * i <= n; ++i){
            if (used[i])
                continue;
            long j = i;
            int len = 0;
            while(j <= n) {
                if(j < 101010)
                    used[(int)j] = true;
                ++len;
                j *= i;
            }

            lengths.add(len);
            ones -= len;
        }

        long gandy = 0;

        if(ones % 2 != 0)
            gandy ^= gandy(1);
        long[] dp = new long[30];
        for(int i = 0; i < 30; ++i) {
            dp[i] = gandy(i);
        }
        for (Integer length : lengths) {
            gandy ^= dp[length];
        }

        out.println(gandy == 0 ? "Petya" : "Vasya");
    }

    private long gandy(int length) {
        if (length == 0) return 0;
        if (length == 1) return 1;
        if (length == 2) return 2;
        if (length == 3) return 1;
        if (length == 4) return 4;
        if (length == 5) return 3;
        if (length == 6) return 2;
        if (length == 7) return 1;
        if (length == 8) return 5;
        if (length == 9) return 6;
        if (length == 10) return 2;
        if (length == 11) return 1;
        if (length == 12) return 8;
        if (length == 13) return 7;
        if (length == 14) return 5;
        if (length == 15) return 9;
        if (length == 16) return 8;
        if (length == 17) return 7;
        if (length == 18) return 3;
        if (length == 19) return 4;
        if (length == 20) return 7;
        if (length == 21) return 4;
        if (length == 22) return 2;
        if (length == 23) return 1;
        if (length == 24) return 10;
        if (length == 25) return 9;
        if (length == 26) return 3;
        if (length == 27) return 6;
        if (length == 28) return 11;
        if (length == 29) return 12;
        throw new AssertionError();
    }
}

class Reader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public Reader(BufferedReader reader) {
        this.reader = reader;
    }

    public Reader(InputStream stream) {
        this(new BufferedReader(new InputStreamReader(stream)));
    }

    public String nextString() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(readLine());
        }
        return tokenizer.nextToken();
    }

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

    private String readLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

class OutputWriter extends PrintWriter {

	public OutputWriter(OutputStream out) {
		super(out);
	}

	public OutputWriter(java.io.Writer writer){
		super(writer);
	}

	}


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

public class A {
    FastScanner in;
    PrintWriter out;

    int gcd(int x, int y) {
        return x == 0 ? y : gcd(y % x, x);
    }

    int getCost(int n, boolean[] already) {
        boolean[] z = new boolean[n];
        for (int x = 3; x < n; x++) {
            if (!already[x]) {
                continue;
            }
            int g = gcd(n, x);
            int add = n / g;
            for (int i = 0; i < n; i += add) {
                z[i] = true;
            }
        }
        int cost = 0;
        for (int i = 0; i < n; i++) {
            cost += z[i] ? 0 : 1;
        }
        return cost;
    }

    int getAns(int maxN, int k) {
        int res = 0;
        boolean[] already = new boolean[maxN + 1];
        int[] costA = new int[maxN + 1];
        for (int it = 0; it < k; it++) {
            int mincost = Integer.MAX_VALUE;
            int minVal = -1;
            for (int n = 3; n <= maxN; n++) {
                if (already[n]) {
                    continue;
                }
                int cost = getCost(n, already);
                if (cost < mincost) {
                    mincost = cost;
                    minVal = n;
                }
            }
            already[minVal] = true;
            res += mincost;
//            System.err.println("! " + minVal + " " + mincost);
            costA[minVal] = mincost;
        }
//        System.err.println(Arrays.toString(costA));
        return res;
    }

    void solve() {
        int n = in.nextInt();
        int k = in.nextInt();
        out.println(solve(n, k));
    }

    void solvesd() {
        for (int n = 10; n <= 15; n++) {
            System.err.println("n = " + n);
            for (int k = 1; k + 2 <= n; k++) {
                long correct = getAns(n, k);
                long my = solve(n, k);
                if (correct != my) {
                    throw new AssertionError(n + " " + k + " " + correct + " " + my);
                }
            }
        }
    }

    long solve(int maxN, int k) {
        final int MAX = (int) 1e6 + 10;
        int[] prime = new int[MAX];
        Arrays.fill(prime, -1);
        for (int i = 2; i < MAX; i++) {
            if (prime[i] == -1) {
                for (int j = i; j < MAX; j += i) {
                    prime[j] = i;
                }
            }
        }
        int[] phi = new int[MAX];
        for (int i = 2; i < MAX; i++) {
            int n = i;
            int result = n;
            while (n != 1) {
                int pr = prime[n];
                while (n % pr == 0) {
                    n /= pr;
                }
                result -= result / pr;
            }
            phi[i] = result;
        }
        long cost = 1;
        if (k >= 2) {
            cost++;
        }
        List<Integer>[] where = new ArrayList[MAX + 1];
        for (int i = 0; i < where.length; i++) {
            where[i] = new ArrayList<>();
        }
//        System.err.println("NEED " + k);
        for (int i = 3; i <= maxN; i++) {
            where[phi[i]].add(i);
//            System.err.println("!" + phi[i]);
        }
        for (int c = 2; k != 0; c++) {
            int sz = where[c].size();
            int use = Math.min(k, sz);
            k -= use;
            cost += c * 1L * use;
        }
        return cost;
    }

    void solve22() {
//        for (int n = 3; n <= 40; n++) {
//            for (int k = 1; k <= n - 3; k++) {
//                System.err.print(getAns(n, k) + " ");
//            }
//            System.err.println();
//        }
        getAns(60, 50);
//        out.println(getAns(in.nextInt(), in.nextInt()));
    }

    void solve123() {
        for (int n = 3; n <= 50; n++) {
            boolean[] z = new boolean[n];
            for (int x = 3; x < n; x++) {
                int g = gcd(n, x);
                int add = n / g;
                for (int i = 0; i < n; i += add) {
                    z[i] = true;
                }
            }
            int cost = 0;
            for (int i = 0; i < n; i++) {
                cost += z[i] ? 0 : 1;
            }
            System.err.println(n + " -> " + cost);
        }
    }

    void run() {
        try {
            in = new FastScanner(new File("A.in"));
            out = new PrintWriter(new File("A.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {

        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();

        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

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

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

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

    public static void main(String[] args) {
        new A().runIO();
    }
}