//package codeforces;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class E {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter writer = new PrintWriter(System.out);
    StringTokenizer stringTokenizer;

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

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

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

    @SuppressWarnings("unchecked")
    void solve() throws IOException {
        int x = nextInt();
        int k = nextInt();
        double p = 0.01 * nextInt();
        double ans = solve(x, k, p);
        writer.printf(Locale.US, "%.10f\n", ans);
        writer.close();
    }

    private double solve(int x, int k, double p) {
        double q = 1.0 - p;
        final int BIG = 1 << 8;
        class Pair {
            long x;
            int compressed;

            Pair(long x, int compressed) {
                this.x = x;
                this.compressed = compressed;
                check();
            }

            void check() {
                int z = countZeroes(x);
                int zc = countZeroes(compressed);
                if(compressed % BIG == 0) {
                    zc = compressed / BIG;
                }
                if(z != zc) {
                    throw new RuntimeException("so wrong!");
                }
            }

            @Override
            public boolean equals(Object o) {
//                if (this == o) return true;
//                if (o == null || getClass() != o.getClass()) return false;
//
                Pair pair = (Pair) o;
//
//                if (compressed != pair.compressed) return false;
//                if (x != pair.x) return false;
//
//                return true;
                return pair.compressed == compressed;
            }

            @Override
            public int hashCode() {
//                int result = (int) (x ^ (x >>> 32));
//                result = 31 * result + compressed;
//                return result;
                return compressed;
            }

            Pair inc() {
                return new Pair(x + 1, compressed % BIG == 0 ? 1 : bigify(compressed + 1, BIG));
            }
            Pair shift() {
                return new Pair(x * 2, compressed % BIG == 0 ? compressed + BIG : bigify(compressed * 2, BIG));
            }
        }
        Map[] dp = new Map[k + 1];
        for(int i = 0; i <= k; i++) {
            dp[i] = new HashMap<Pair, Double>();
        }
        x = bigify(x, BIG);
        dp[0].put(new Pair(x, x), 1.0);
        for(int i = 0; i < k; i++) {
            Map<Pair, Double> nextMap = dp[i + 1];
            for (Map.Entry<Pair, Double> entry : ((Map<Pair, Double>)dp[i]).entrySet()) {
                Pair pair = entry.getKey();
                increment(nextMap, pair.shift(), p * entry.getValue());
                increment(nextMap, pair.inc(), q * entry.getValue());
                /*int y = entry.getKey();
                if(y % BIG == 0) {
                    int py = y + BIG;
                    int qy = 1;
                    increment(nextMap, py, p * entry.getValue());
                    increment(nextMap, qy, q * entry.getValue());
                } else {
                    int yy = y + k - i;
                    yy ^= y;
                    y &= Math.max(BIG - 1, (1 << Integer.highestOneBit(yy)) - 1);
                    int py = bigify(y * 2, BIG);
                    int qy = bigify(y + 1, BIG);
                    increment(nextMap, py, p * entry.getValue());
                    increment(nextMap, qy, q * entry.getValue());
                }*/
            }
            dp[i].clear();
        }
        double ans = 0;
        for (Map.Entry<Pair, Double> entry : ((Map<Pair, Double>) dp[k]).entrySet()) {
            if(entry.getKey().compressed % BIG == 0) {
                ans += entry.getKey().compressed / BIG * entry.getValue();
            } else {
                ans += countZeroes(entry.getKey().compressed) * entry.getValue();
            }
        }
        return ans;
    }

    private int bigify(int x, int BIG) {
        if(x % BIG == 0) {
            x = countZeroes(x) * BIG;
        }
        return x;
    }

    <K> void increment(Map<K, Double> map, K key, double value) {
        value += map.containsKey(key) ? map.get(key) : 0;
        map.put(key, value);
    }

    int countZeroes(long x) {
        int z = 0;
        while(x % 2 == 0) {
            x /= 2;
            z++;
        }
        return z;
    }

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


//package codeforces;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class E {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter writer = new PrintWriter(System.out);
    StringTokenizer stringTokenizer;

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

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

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

    @SuppressWarnings("unchecked")
    void solve() throws IOException {
        int x = nextInt();
        int k = nextInt();
        double p = 0.01 * nextInt();
        double ans = solve(x, k, p);
        writer.printf(Locale.US, "%.10f\n", ans);
        writer.close();
    }

    private double solve(int x, final int k, double p) {
        double q = 1.0 - p;
        final int BIG = 1 << 8;
        class Pair {
            long x;
            int compressed;

            Pair(long x, int compressed) {
                this.x = x;
                if (compressed % BIG != 0) {
                    int foo = compressed + k;
                    foo ^= compressed;
                    this.compressed = compressed & Math.max(BIG - 1, (Integer.highestOneBit(foo) << 1) - 1);
                } else {
                    this.compressed = compressed;
                }
                check();
            }

            void check() {
                int z = countZeroes(x);
                int zc = countZeroes(compressed);
                if (compressed % BIG == 0) {
                    zc = compressed / BIG;
                }
                if (z != zc) {
                    throw new RuntimeException("so wrong!");
                }
            }

            @Override
            public boolean equals(Object o) {
//                if (this == o) return true;
//                if (o == null || getClass() != o.getClass()) return false;
//
                Pair pair = (Pair) o;
//
//                if (compressed != pair.compressed) return false;
//                if (x != pair.x) return false;
//
//                return true;
                return pair.compressed == compressed;
            }

            @Override
            public int hashCode() {
//                int result = (int) (x ^ (x >>> 32));
//                result = 31 * result + compressed;
//                return result;
                return compressed;
            }

            Pair inc() {
                return new Pair(x + 1, compressed % BIG == 0 ? 1 : bigify(compressed + 1, BIG));
            }

            Pair shift() {
                return new Pair(x * 2, compressed % BIG == 0 ? compressed + BIG : bigify(compressed * 2, BIG));
            }

        }
        Map[] dp = new Map[k + 1];
        for (int i = 0; i <= k; i++) {
            dp[i] = new HashMap<Pair, Double>();
        }
        x = bigify(x, BIG);
        dp[0].put(new Pair(x, x), 1.0);
        for (int i = 0; i < k; i++) {
//            System.out.println(i);
//            System.out.println(dp[i].size());
            Map<Pair, Double> nextMap = dp[i + 1];
            for (Map.Entry<Pair, Double> entry : ((Map<Pair, Double>) dp[i]).entrySet()) {
                Pair pair = entry.getKey();
                increment(nextMap, pair.shift(), p * entry.getValue());
                increment(nextMap, pair.inc(), q * entry.getValue());
                /*int y = entry.getKey();
                if(y % BIG == 0) {
                    int py = y + BIG;
                    int qy = 1;
                    increment(nextMap, py, p * entry.getValue());
                    increment(nextMap, qy, q * entry.getValue());
                } else {
                    int yy = y + k - i;
                    yy ^= y;
                    y &= Math.max(BIG - 1, (1 << Integer.highestOneBit(yy)) - 1);
                    int py = bigify(y * 2, BIG);
                    int qy = bigify(y + 1, BIG);
                    increment(nextMap, py, p * entry.getValue());
                    increment(nextMap, qy, q * entry.getValue());
                }*/
            }
            dp[i].clear();
        }
        double ans = 0;
        for (Map.Entry<Pair, Double> entry : ((Map<Pair, Double>) dp[k]).entrySet()) {
            if (entry.getKey().compressed % BIG == 0) {
                ans += entry.getKey().compressed / BIG * entry.getValue();
            } else {
                ans += countZeroes(entry.getKey().compressed) * entry.getValue();
            }
        }
        return ans;
    }

    private int bigify(int x, int BIG) {
        if (x % BIG == 0) {
            x = countZeroes(x) * BIG;
        }
        return x;
    }

    <K> void increment(Map<K, Double> map, K key, double value) {
        value += map.containsKey(key) ? map.get(key) : 0;
        map.put(key, value);
    }

    int countZeroes(long x) {
        int z = 0;
        while (x % 2 == 0) {
            x /= 2;
            z++;
        }
        return z;
    }

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


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.Random;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Arthur Gazizov - Kazan FU #4.3 [2oo7]
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskRandom solver = new TaskRandom();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskRandom {
        int LIMIT_TIME = 2000;

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            long stepIntoSolve = System.currentTimeMillis();
            int x = in.nextInt();
            int k = in.nextInt();
            int p = in.nextInt();
            Random random = new Random(System.currentTimeMillis());
            int total = 0;
            int count = 0;
            do {
                // BigInteger value = BigInteger.valueOf(x);
                long value = x;
                for (int i = 0; i < k; i++) {
                    int next = Math.abs(random.nextInt()) % 100 + 1;
                    if (next <= p) {
                        value *= 2l;
                        //value = value.multiply(TWO);
                    } else {
                        value++;
                        // value = value.add(BigInteger.ONE);
                    }
                }
                total += Long.numberOfTrailingZeros(value);
                // total += getZerousCount(value);
                count++;
            } while (System.currentTimeMillis() - stepIntoSolve <= LIMIT_TIME);
            out.print((1.0 * total) / count);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void close() {
            writer.close();
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

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

        public 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++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

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

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import javax.sound.sampled.Line;
import java.awt.Point;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.io.*;
import java.math.BigInteger;
import static java.math.BigInteger.*;
import java.util.*;
public class A{

    void solve()throws Exception
    {

    }

     ////////////
    BufferedReader reader;
    PrintWriter writer;
    StringTokenizer stk;
    void run()throws Exception
    {
        reader=new BufferedReader(new FileReader("input.txt"));
        stk=null;
        writer=new PrintWriter(new FileWriter("output.txt"));
        solve();
        reader.close();
        writer.close();
    }
    int nextInt()throws Exception
    {
        return Integer.parseInt(nextToken());
    }

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

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

    }

    String nextString()throws Exception
    {
        return nextToken();
    }
    String nextLine()throws Exception
    {
        return reader.readLine();
    }
    String nextToken()throws Exception
    {
        if(stk==null || !stk.hasMoreTokens())
        {
            stk=new StringTokenizer(nextLine());
            return nextToken();

        }
        return stk.nextToken();
    }

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

}


/**
 * Created by IntelliJ IDEA.
 * User: piyushd
 * Date: 3/29/11
 * Time: 7:56 PM
 * To change this template use File | Settings | File Templates.
 */
public class TaskD {

    final int MOD = 1000000007;

    int modInverse(int x, int M) {
        return (int) expo(x, M - 2);
    }

    long expo(int x, int n) {
        if (n == 0) return 1;

        if (n % 2 == 0) {
            long res = expo(x, n / 2);
            return (res * res) % MOD;
        } else {
            return (x * expo(x, n - 1)) % MOD;
        }
    }

    long[] fact;
    long[] factInv;

    void precal(int N) {
        this.fact = new long[N + 1];
        this.factInv = new long[N + 1];
        fact[0] = 1;
        factInv[0] = modInverse(1, MOD);
        for(int i = 1; i <= N; i++) {
            fact[i] = (i * fact[i - 1]) % MOD;
            factInv[i] = (modInverse(i, MOD) * factInv[i - 1]) % MOD;
        }
    }

    long comb (int n, int k) {
        if(k > n) return 0;
        long res = fact[n];
        res = (res * factInv[k]) % MOD;
        res = (res * factInv[n - k]) % MOD;
        return res;
    }

    void run() {
        int N = nextInt(), M = nextInt();
        int K = nextInt();

        precal(Math.max(N, K));

        long[] waysToFill = new long[N + 1];
        waysToFill[0] = 0;
        for(int i = 1; i <= N; i++) {
            waysToFill[i] = (int) expo(i, N);
            for(int j = 0; j < i; j++)
                waysToFill[i] = (waysToFill[i] - comb(i, j) * waysToFill[j] + MOD) % MOD;
        }

        long res = 0;
        for (int distinct = 1; distinct <= N; distinct++) {
            for (int common = 0; common <= distinct; common++) {
                int required = 2 * distinct - common;
                if (required > K) continue;

                int unique = distinct - common;
                long choose = comb(K, common);
                choose = (choose * comb(K - common, unique)) % MOD;
                choose = (choose * comb(K - common - unique, unique)) % MOD;

                long fill = expo(common, N * (M - 2));
                fill = (fill * waysToFill[distinct]) % MOD;
                fill = (fill * waysToFill[distinct]) % MOD;

                res = (res + choose * fill) % MOD;
            }
        }

        System.out.println(res);
    }

    int nextInt() {
        try {
            int c = System.in.read();
            if (c == -1) return c;
            while (c != '-' && (c < '0' || '9' < c)) {
                c = System.in.read();
                if (c == -1) return c;
            }
            if (c == '-') return -nextInt();
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = System.in.read();
            } while ('0' <= c && c <= '9');
            return res;
        } catch (Exception e) {
            return -1;
        }
    }

    long nextLong() {
        try {
            int c = System.in.read();
            if (c == -1) return -1;
            while (c != '-' && (c < '0' || '9' < c)) {
                c = System.in.read();
                if (c == -1) return -1;
            }
            if (c == '-') return -nextLong();
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = System.in.read();
            } while ('0' <= c && c <= '9');
            return res;
        } catch (Exception e) {
            return -1;
        }
    }

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

    String next() {
        try {
            StringBuilder res = new StringBuilder("");
            int c = System.in.read();
            while (Character.isWhitespace(c))
                c = System.in.read();
            do {
                res.append((char) c);
            } while (!Character.isWhitespace(c = System.in.read()));
            return res.toString();
        } catch (Exception e) {
            return null;
        }
    }

    String nextLine() {
        try {
            StringBuilder res = new StringBuilder("");
            int c = System.in.read();
            while (c == '\r' || c == '\n')
                c = System.in.read();
            do {
                res.append((char) c);
                c = System.in.read();
            } while (c != '\r' && c != '\n');
            return res.toString();
        } catch (Exception e) {
            return null;
        }
    }

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


import java.awt.Point;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.io.*;
import java.math.BigInteger;
import static java.math.BigInteger.*;
import java.util.*;
public class D{
    long mod = 1000000007;
        void solve()throws Exception
        {
            long[] fact = new long[1000000 + 1];
            long[] rev = new long[fact.length];
            long[] temp = new long[fact.length];
           fact[0] = 1;
        rev[0] = 1;
        temp[1] = 1;
        for(int i=2;i<fact.length;i++)
        {
            temp[i] = -temp[(int)mod / i] * (mod / i)%mod;
            temp[i] += mod;
            temp[i] %= mod;
         }
        for (int i = 1; i + 1 < fact.length + 1; i++)
        {
            fact[i] = i * fact[i - 1] % mod;
            rev[i] = rev[i - 1] * temp[i] % mod;
        }
            int n = nextInt();
            int m = nextInt();
            int k = nextInt();
            long res = 0;
            if (m == 1)
                res = pow(k, n);
            else
            {
                long[][] C = new long[n + 1][n + 1];
                for (int i = 0; i <= n; i++)
                {
                    C[i][ 0] = 1;
                    for (int j = 1; j <= i; j++)
                        C[i][j] = (C[i - 1][ j - 1] + C[i - 1][ j]) % mod;
                }
                long[] dp = new long[n + 1];
                for (int i = 1; i <= n; i++)
                {
                    dp[i] = pow(i, n);
                    for (int j = 1; j < i; j++)
                    {
                        dp[i] -= C[i][j] * dp[j] % mod;
                        dp[i] += mod;
                        dp[i] %= mod;
                    }
                }
                long[] pre = new long[n + 1];
                for (int i = 0; i <= n; i++)
                    pre[i] = pow(i, n * m - 2 * n);
                for (int common = 0; common <= Math.min(n, k); common++)
                    for (int other = 0; other + common <=n && 2*other+common<=k; other++)
                    {
                        long cur = 1;
                        cur = cur * fact[k] % mod * rev[common] % mod * rev[k - common] % mod;
                        cur = cur * fact[k - common] % mod * rev[other] % mod * rev[k - common - other] % mod;
                        cur = cur * fact[k - common - other] % mod * rev[other] % mod * rev[k - common - other - other] % mod;
                        cur = cur * dp[common + other] % mod * dp[common + other] % mod;
                        cur = cur * pre[common] % mod;
                        res = (res + cur) % mod;
                    }
            }
            System.out.println(res);
        }

        private long pow(long a, long p)
        {
            if (p == 0)
                return 1;
            long res = pow(a, p / 2);
            res = res * res % mod;
            if (p % 2 == 1)
                res = res * a % mod;
            return res;
        }

    ////////////
    BufferedReader reader;
    PrintWriter writer;
    StringTokenizer stk;
    void run()throws Exception
    {
        reader=new BufferedReader(new InputStreamReader(System.in));
        stk=null;
        writer=new PrintWriter(System.out);
        solve();
        reader.close();
        writer.close();
    }
    int nextInt()throws Exception
    {
        return Integer.parseInt(nextToken());
    }

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

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

    }

    String nextString()throws Exception
    {
        return nextToken();
    }
    String nextLine()throws Exception
    {
        return reader.readLine();
    }
    String nextToken()throws Exception
    {
        if(stk==null || !stk.hasMoreTokens())
        {
            stk=new StringTokenizer(nextLine());
            return nextToken();

        }
        return stk.nextToken();
    }

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

}


//package round85;import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class D {
	Scanner in;
	PrintWriter out;
	String INPUT = "";
	int mod = 1000000007;

	// 1列の場合はなんでもありなのでk^n
	// 2列の場合はどっちも同じi色であればいいので、
	// \sum_i (C(k,i)F(n,i))^2
	// 3列以上の場合は全部同じ配色。
	// \sum_i (C(k,i)F(n,i))^m
	// F(n,i)はn行をちょうどi色で塗る塗り方
	// F(n,i)=i^n-C(i,1)(i-1)^n+C(i,2)(i-2)^n-...
	// これを求めるのにO(i)
	// 全体でO(k^2)かかってしまうので普通の計算では間に合わない。
	//
	//

	void solve()
	{
		int n = ni();
		int m = ni();
		int K = ni();

		long[][] C = new long[1001][1001];
		for(int i = 0;i <= 1000;i++){
			C[i][0] = 1;
			for(int j = 1;j <= i;j++){
				C[i][j] = (C[i-1][j] + C[i-1][j-1])% mod;
			}
		}
		long[] I = new long[1001];
		for(int i = 0;i <= 1000;i++){
			I[i] = modpow(i, n, mod);
		}

		// F(n,i)=i^n-C(i,1)(i-1)^n+C(i,2)(i-2)^n-...
		long[] F = new long[1001];
		for(int i = 0;i <= 1000;i++){
			long val = 0;
			long minus = 1;
			for(int j = i;j >= 0;j--){
				val += modpow(j, n, mod) * minus * C[i][j] % mod;
				minus = -minus;
			}
			F[i] = val % mod;
		}

		if(m == 1){
			out.println(modpow(K, n, mod));
		}else if(m == 2){
			long sum = 0;
			long c = 1;
			for(int i = 1;i <= K;i++){
				c = c * (K-i+1) % mod;
				c = c * inv(i, mod) % mod;
				long cfm = c*F[i]%mod;
				sum += cfm*cfm%mod;
			}
			out.println(sum%mod);
		}else{
			long sum = 0;
			long c = 1;
			for(int i = 1;i <= K;i++){
				c = c * (K-i+1) % mod;
				c = c * inv(i, mod) % mod;
				c = mod - c;
				long all = c*modpow(F[i], m, mod)%mod;
				sum += all;
			}
			out.println(sum%mod);
		}
	}

	public static long inv(long a, int p)
	{
		long ret = 1;
		long mul = a;
		for(long n = p-2;n > 0;n >>>= 1){
			if((n&1)==1)ret = ret * mul % p;
			mul = mul * mul % p;
		}
		return ret;
	}

	public static long modpow(long a, long n, long mod)
	{
		long ret = 1;
		long mul = a;
		for(;n > 0;n >>>= 1){
			if((n&1)==1){
				ret = (ret * mul) % mod;
			}
			mul = (mul * mul) % mod;
		}
		return ret;
	}

	void run() throws Exception
	{
		in = oj ? new Scanner(System.in) : new Scanner(INPUT);
		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 D().run();
	}

	int ni() { return Integer.parseInt(in.next()); }
	long nl() { return Long.parseLong(in.next()); }
	double nd() { return Double.parseDouble(in.next()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


/**
 *  This class contains all kinds of searching techniques.
 *  @author: himself
*/

public class Main {

    // Iterative Binary Search -- O(lg(n))

    static int iterBinSearch(int[] arr, int n) {
        int l = 0, r = arr.length - 1, mid;
        while(l <= r) {
            mid = (l + r) / 2;
            if(arr[mid] == n)
                return mid;
            if(arr[mid] < n)
                l = mid + 1;
            else
                r = mid - 1;
        }
        return -1;
    }

    // Recursive Binary Search -- O(lg(n))

    static int binSearch(int[] arr, int n) {
        return binSearch(arr, n, 0, arr.length - 1);
    }

    static int binSearch(int[] arr, int n, int l, int r) {
        if(l <= r) {
            int mid = (l + r) / 2;
            if(arr[mid] == n)
                return mid;
            if(arr[mid] < n)
                return binSearch(arr, n, mid + 1, r);
            else
                return binSearch(arr, n, l, mid - 1);
        }
        return -1;
    }

    public static void main(String[] args) throws IOException {
        Reader.init(System.in);
        int n = Reader.nextInt();
        int[] arr = new int[n];
        for(int i = 0; i < n; i++)
            arr[i] = Reader.nextInt();
    }
}


import java.util.*;

public class Program2 {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		System.out.printf("%d", (int)((Math.floor(n/2) + 1) * Math.ceil(n/2));
	}
}


import java.util.*;
public class Main{
    public static int main(String[] args){
        Scanner s= new Scanner(System.in);
        int n = s.nextInt();
        if(n%2==0){
            System.out.println(((n/2)+1)*(n/2));
        }else{
            System.out.println(((n/2)+1)*((n/2)+1));
        }
    }
}


import java.util.*
public class Main{
    public static int main(String[] args){
        Scanner s= new Scanner(System.in);
        int n = s.nextInt();
        if(n%2==0){
            System.out.println(((n/2)+1)*(n/2));
        }else{
            System.out.println(((n/2)+1)*((n/2)+1));
        }
    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

import org.omg.CORBA.PUBLIC_MEMBER;

public class my_class {

	public static ArrayList<Integer> nums = new ArrayList<>();
	public static int rec(int i, int num, int arr[]){
		if(i < arr.length){
			rec(i + 1, num + arr[i], arr);
			rec(i + 1, num - arr[i], arr);
			if(i != 0)
				rec(i + 1, num * arr[i], arr);
		}else{
			if(!nums.contains(Math.abs(num)) && (num != 0)){
				nums.add(Math.abs(num));
			}
		}
		return 0;
	}
	public static void rec1(int arr[], int qwer){
		if(arr.length >= 2){
			rec(0,0, arr);
			if(arr.length > 2){
				for(int i = 0; i < arr.length - 1;i++){
					if(i + 1 != qwer){
						int[] tmpA = new int[arr.length - 1];
						for(int s = 0; s < tmpA.length; s++){
							if(s < i)
								tmpA[s] = arr[s];
							if(s == i)
								tmpA[s] = arr[s]*10 + arr[s + 1];
							if(s > i)
								tmpA[s] = arr[s + 1];
						}
						rec1(tmpA,i);
					}
				}
			}
		}
	}
	public static void main(String[] args) throws Exception{
		int  k = nextInt(), m = nextInt();
		int sum = 0;
		for(int counter = 1; counter <= 9999;counter++){
			int arr[] = new int[4];
			nums.clear();
			int tmp = counter;
			for(int i = arr.length - 1;tmp != 0;i--){
				arr[i] = tmp % 10;
				tmp = tmp / 10;
			}
			nums.add(counter);
			rec1(arr,0);
			int l;
			for(int i = 0; i < nums.size();i++){
				if(sum > m - 1)
					break;
				if(nums.get(i)/10000 == 0){
					if(nums.get(i) > k)
						l = nums.get(i) - k;
					else
						l = k - nums.get(i);
					l = (((l*10 + arr[0])*10 + arr[1])*10 + arr[2])*10 + arr[3];
					tmp  = l;
					int s = 0;
					while(tmp/10 != 0){
						tmp = tmp/10;
						s++;
					}
					s = 7 - s;
					while(s != 0){
						print(0);
						s--;
					}
					println(l);
					sum++;
				}
			}
			if(sum > m - 1){
				break;
			}
		}
		//println(sum);
	}
	private static PrintWriter out = new PrintWriter(System.out);
	private static BufferedReader inB = new BufferedReader(new InputStreamReader(System.in));
	private static StreamTokenizer in = new StreamTokenizer(inB);

	private static void exit(Object o) throws Exception {
		out.println(o);
		out.flush();
		System.exit(0);
	}
	private static void println(Object o) throws Exception{
		out.println(o);
		out.flush();
	}
	private static void print(Object o) throws Exception{
		out.print(o);
		out.flush();
	}
	private static long nextLong() throws Exception {
		in.nextToken();
		return (long)in.nval;
	}
	private static int nextInt() throws Exception {
		in.nextToken();
		return (int)in.nval;
	}
	private static String nextString() throws Exception {
		in.nextToken();
		return in.sval;
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.TreeSet;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Trung Pham
 */
public class E {

    public static void main(String[] args) {
        Scanner in = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        int k = in.nextInt();
        int m = in.nextInt();
        for (int i = 0; i < 10000; i++) {
            TreeSet<Integer> set = cal(i, 4);
            for (int j = 0; j < set.size(); j++) {
                int val = k - set.pollFirst();
                if (val < 10000 && val >= 0) {
                    System.out.printf("%04d%04d\n", val, i);
                    m--;
                }
                if (m == 0) {
                    return;
                }
            }
        }
        out.flush();
        //System.out.print(builder.toString());
    }

    public static TreeSet<Integer> cal(int val, int length) {
        TreeSet<Integer> set = new TreeSet();
        set.add(val);
        set.add(-val);
        if (length > 1) {
            for (int i = 1, a = 10; i < length; i++, a *= 10) {
                TreeSet<Integer> set1 = cal(val / a, length - i);
                TreeSet<Integer> set2 = cal(val % a, i);
                for (int j = 0; j < set1.size(); j++) {
                    int val1 = set1.pollFirst();
                    for (int k = 0; k < set2.size(); k++) {
                        int val2 = set2.pollFirst();
                        set.add(val1 + val2);
                        set.add(val1 * val2);
                    }
                }
            }
        }
        return set;

    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

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

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

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

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.TreeSet;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Trung Pham
 */
public class E {

    public static void main(String[] args) {
        Scanner in = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        int k = in.nextInt();
        int m = in.nextInt();
        for (int i = 0; i < 10000; i++) {
            TreeSet<Integer> set = cal(i, 4);
            for (int j = 0; j < set.size(); j++) {
                int val = k - set.pollFirst();
                if (val < 10000 && val >= 0) {
                    out.printf("%04d%04d\n", val, i);
                    m--;
                }
                if (m == 0) {
                    return;
                }
            }
        }
        out.flush();
        //System.out.print(builder.toString());
    }

    public static TreeSet<Integer> cal(int val, int length) {
        TreeSet<Integer> set = new TreeSet();
        set.add(val);
        set.add(-val);
        if (length > 1) {
            for (int i = 1, a = 10; i < length; i++, a *= 10) {
                TreeSet<Integer> set1 = cal(val / a, length - i);
                TreeSet<Integer> set2 = cal(val % a, i);
                for (int j = 0; j < set1.size(); j++) {
                    int val1 = set1.pollFirst();
                    for (int k = 0; k < set2.size(); k++) {
                        int val2 = set2.pollFirst();
                        set.add(val1 + val2);
                        set.add(val1 * val2);
                    }
                }
            }
        }
        return set;

    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

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

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

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

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

import org.omg.CORBA.PUBLIC_MEMBER;

public class my_class {

	public static ArrayList<Integer> nums = new ArrayList<>();
	public static int rec(int i, int num, int arr[]){
		if(i < arr.length){
			rec(i + 1, num + arr[i], arr);
			rec(i + 1, num - arr[i], arr);
			if(i != 0)
				rec(i + 1, num * arr[i], arr);
		}else{
			if(!nums.contains(Math.abs(num)) && (num != 0)){
				nums.add(Math.abs(num));
			}
		}
		return 0;
	}
	public static void rec1(int arr[], int qwer){
		if(arr.length >= 2){
			rec(0,0, arr);
			if(arr.length > 2){
				for(int i = 0; i < arr.length - 1;i++){
					if(i + 1 != qwer){
						int[] tmpA = new int[arr.length - 1];
						for(int s = 0; s < tmpA.length; s++){
							if(s < i)
								tmpA[s] = arr[s];
							if(s == i)
								tmpA[s] = arr[s]*10 + arr[s + 1];
							if(s > i)
								tmpA[s] = arr[s + 1];
						}
						rec1(tmpA,i);
					}
				}
			}
		}
	}
	public static void main(String[] args) throws Exception{
		int  k = nextInt(), m = nextInt();
		int sum = 0;
		ArrayList<Integer> re = new ArrayList<>();
		for(int counter = 1; counter <= 9999;counter++){
			int arr[] = new int[4];
			nums.clear();
			int tmp = counter;
			for(int i = arr.length - 1;tmp != 0;i--){
				arr[i] = tmp % 10;
				tmp = tmp / 10;
			}
			nums.add(counter);
			rec1(arr,0);
			int l, last = -1;
			for(int i = 0; i < nums.size();i++){
				if(sum > m - 1)
					break;
				if(nums.get(i)/10000 == 0){
					if(nums.get(i) > k)
						l = nums.get(i) - k;
					else
						l = k - nums.get(i);
					l = (((l*10 + arr[0])*10 + arr[1])*10 + arr[2])*10 + arr[3];
					int s = 0;
					tmp  = l;
					if(!re.contains(l)){
						while(tmp/10 != 0){
							tmp = tmp/10;
							s++;
						}
						s = 7 - s;
						while(s != 0){
							print(0);
							s--;
						}
						println(l);
						re.add(l);
						sum++;
					}
				}
			}
			if(sum > m - 1){
				break;
			}
		}
	}
	private static PrintWriter out = new PrintWriter(System.out);
	private static BufferedReader inB = new BufferedReader(new InputStreamReader(System.in));
	private static StreamTokenizer in = new StreamTokenizer(inB);

	private static void exit(Object o) throws Exception {
		out.println(o);
		out.flush();
		System.exit(0);
	}
	private static void println(Object o) throws Exception{
		out.println(o);
		out.flush();
	}
	private static void print(Object o) throws Exception{
		out.print(o);
		out.flush();
	}
	private static long nextLong() throws Exception {
		in.nextToken();
		return (long)in.nval;
	}
	private static int nextInt() throws Exception {
		in.nextToken();
		return (int)in.nval;
	}
	private static String nextString() throws Exception {
		in.nextToken();
		return in.sval;
	}
}


/*
  Goal: Become better in CP!
  Key: Consistency and Discipline
  Desire: SDE @ Google USA
  Motto: Do what i Love <=> Love what i do
  If you don't use your brain 100%, it deteriorates gradually
*/

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

public class Code {

  static StringBuffer str=new StringBuffer();
  static BufferedReader bf;
  static PrintWriter pw;
  static long n;

  static void solve(int te) throws Exception{
    if(n==1) return 3;
    return 4 + (4*n-3)/3;
  }

  public static void main(String[] args) throws java.lang.Exception {
    boolean lenv=false;
    if(lenv){
      bf = new BufferedReader(
                          new FileReader("input.txt"));
      pw=new PrintWriter(new
            BufferedWriter(new FileWriter("output.txt")));
    }else{
      bf = new BufferedReader(new InputStreamReader(System.in));
      pw = new PrintWriter(new OutputStreamWriter(System.out));
    }

    // int q1 = Integer.parseInt(bf.readLine().trim());
    // for(int te=1;te<=q1;te++) {
      // String s[]=bf.readLine().trim().split("\\s+");
      n=Long.parseLong(bf.readLine().trim());
      solve(1);
    // }
    pw.print(str);
    pw.flush();
    // System.out.println(str);
  }
}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.function.Supplier;
import java.util.stream.Collectors;

public class cf {

	//-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    public static int cnt;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            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 boolean isPrime(int n)
{
    // Corner cases
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
    public static int reverseBits(int n)
    {
        int rev = 0;

        // traversing bits of 'n'
        // from the right
        while (n > 0)
        {
            // bitwise left shift
            // 'rev' by 1
            rev <<= 1;

            // if current bit is '1'
            if ((int)(n & 1) == 1)
                rev ^= 1;

            // bitwise right shift
            //'n' by 1
            n >>= 1;
        }
        // required number
        return rev;
    }

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
		StringBuilder sb = new StringBuilder();
		int t=sc.nextInt();
//		while(t-->0)
//		{
//			int n=sc.nextInt();
//			ArrayList<Integer> x1=new ArrayList<Integer>();
//			ArrayList<Integer> x2=new ArrayList<Integer>();
//
//			ArrayList<Integer> x3=new ArrayList<Integer>();
//			for(int i=0;i<n;i++)
//			{
//				x1.add(sc.nextInt());
//			}
//			for(int i=0;i<n;i++)
//			{
//				x2.add(sc.nextInt());
//			}
//			for(int i=0;i<n;i++)
//			{
//				x3.add(x2.get(i)-x1.get(i));
//			}
//			Collections.sort(x3);
//			int l=0,r=n-1,ans=0;
//			while(l<r)
//			{
//				if(x3.get(l)+x3.get(r)>=0)
//				{
//					l++;
//					r--;
//					ans++;
//				}
//				else
//				{
//					l++;
//				}
//			}
//			out.println(ans);
//		}
		ArrayList<Long> x=new ArrayList<Long>();
		x.add((long) 3);
		x.add((long) 5);
		long k=5;
		k=k+2;
		while(x.size()<=t)
		{
			x.add(k);
			x.add(k+1);
			x.add(k+2);
			k=k+4;
		}
		Collections.sort(x);
		out.println(x.get(t-1));
		out.close();
	}
}


/*
  Goal: Become better in CP!
  Key: Consistency and Discipline
  Desire: SDE @ Google USA
  Motto: Do what i Love <=> Love what i do
  If you don't use your brain 100%, it deteriorates gradually
*/

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

public class Code {

  static StringBuffer str=new StringBuffer();
  static BufferedReader bf;
  static PrintWriter pw;
  static long n;
  static long d;
  static long p[];

  static void solve(int te) throws Exception{
    long l=3;
    long r=n*2+2;
    long cnt=r/4-1;
    while(cnt>0 && r>=3){
      if(r%2==1 || (r%4==0 && r!=4)) cnt--;
      r--;
    }
    while(r>3 && (r%2==0 && (r%4!=0 || r==4))) r--;
    str.append(r).append("\n");
  }

  public static void main(String[] args) throws java.lang.Exception {
    boolean lenv=false;
    if(lenv){
      bf = new BufferedReader(
                          new FileReader("input.txt"));
      pw=new PrintWriter(new
            BufferedWriter(new FileWriter("output.txt")));
    }else{
      bf = new BufferedReader(new InputStreamReader(System.in));
      pw = new PrintWriter(new OutputStreamWriter(System.out));
    }

    // int q1 = Integer.parseInt(bf.readLine().trim());
    // for(int te=1;te<=q1;te++) {
      // String s[]=bf.readLine().trim().split("\\s+");
      n=Long.parseLong(bf.readLine().trim());
      // d=Long.parseLong(s[1]);
      // p=new long[n];
      // s=bf.readLine().trim().split("\\s+");
      // for(int i=0;i<n;i++) p[i]=Long.parseLong(s[i]);
      solve(1);
    // }
    pw.print(str);
    pw.flush();
    // System.out.println(str);
  }
}


import java.io.Writer;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.*;
import java.io.*;
import java.math.*;
import java.util.concurrent.TimeUnit;
public class check {
    public static int find(ArrayList<Integer> inp, int n, int target){
        Collections.sort(inp);
        Collections.reverse(inp);
        int res = 0;
        int num = n;
        for(int i = 0;i<n && num>0;i++){
            int curr = inp.get(i);
            int times = target/curr;
            if(target%curr != 0)
                times++;
            if(times*curr<=target)
                times++;
            if(times>num)
                return res;
            num = num-times;
            res++;
        }
        return res;
    }

    public static void main(String args[]) throws java.lang.Exception{
        Scanner in;
        try{
            in = new Scanner(new FileReader("./input.txt"));
        }
        catch(Exception e){
            in = new Scanner(System.in);
        }
        int n = in.nextInt();

        long st = 3;
        if(n == 1){
            System.out.println(3);
            return;
        }
        int t = 0;
        int flag = 0;
        for(int i = 2;i<=n;i++){
            if(flag == 1){
                st++;
                flag = 0;
                t++;
            }
            else if(t<2){
                st = st+2;
                t++;
            }
            else{
                st++;
                t = 0;
                flag = 1;
            }
            //System.out.println(i+" "+st);
        }
        System.out.println(st);
    }
}


// package c1749;

//
// Educational Codeforces Round 138 (Rated for Div. 2) 2022-10-20 07:35
// D. Counting Arrays
// https://codeforces.com/contest/1749/problem/D
// time limit per test 2 seconds; memory limit per test 512 megabytes
// public class Pseudo for 'Source should satisfy regex [^{}]*public\s+(final)?\s*class\s+(\w+).*'
//
// Consider an array a of length n with elements numbered from 1 to n. It is possible to remove the
// i-th element of a if gcd(a_i, i) = 1, where gcd denotes the greatest common divisor. After an
// element is removed, the elements to the right are shifted to the left by one position.
//
// An array b with n integers such that 1 <= b_i <= n - i + 1 is a if it is possible to remove all
// elements of a, if you remove the b_1-th element, then the b_2-th, ..., then the b_n-th element.
// For example, let a = [42, 314]:
//  * [1, 1] is a removal sequence: when you remove the 1-st element of the array, the condition
//    gcd(42, 1) = 1 holds, and the array becomes [314]; when you remove the 1-st element again, the
//    condition gcd(314, 1) = 1 holds, and the array becomes empty.
//  * [2, 1] is not a removal sequence: when you try to remove the 2-nd element, the condition
//    gcd(314, 2) = 1 is false.
//
// An array is if it has removal sequences. For example, the array [1, 2, 5] is ambiguous: it has
// removal sequences [3, 1, 1] and [1, 2, 1]. The array [42, 314] is not ambiguous: the only removal
// sequence it has is [1, 1].
//
// You are given two integers n and m. You have to calculate the number of arrays a such that the
// length of a is from 1 to n and each a_i is an integer from 1 to m.
//
// Input
//
// The only line of the input contains two integers n and m (2 <= n <= 3 * 10^5; 1 <= m <= 10^{12}).
//
// Output
//
// Print one integer -- the number of ambiguous arrays a such that the length of a is from 1 to n
// and each a_i is an integer from 1 to m. Since the answer can be very large, print it modulo
// 998244353.
//
// Example
/*
input:
2 3
output:
6

input:
4 2
output:
26

input:
4 6
output:
1494

input:
1337 424242424242
output:
119112628
*/
//

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.StringTokenizer;

public class C1749D {
  static final int MOD = 998244353;
  static final Random RAND = new Random();

  static int solve(int n, long m) {
    List<Integer>[] primes = getPrimeFactors(n);
    long[][] dp = new long[16][n];
    // exc[j] is number of v for j-th term such that v is multiple of (j+1) (should be excluded)
    long[][] exc = new long[16][n];

    // pre[j] is multiple of prefixes of exc[j]
    long[][] pre = new long[16][n];

    // qua[j] is count of arrays in [0,j] such that at least one of v_j is NOT multiple of (j+1)
    long[][] qua = new long[16][n];

    int e = 0;
    for (int i = 0; i < 16; i++) {
      long total = 1;
      for (int j = 0; j < n; j++) {
        long v = (i == 0 ? m : exc[i-1][j]) % MOD;
        total = total * v % MOD;
        exc[i][j] = getNonCoprimeCount(j + 1, i + 1, m, primes);
        pre[i][j] = exc[i][j] * (j == 0 ? 1 : pre[i][j-1]) % MOD;
        qua[i][j] = (total + MOD - pre[i][j]) % MOD;
      }
      if (test) {
        System.out.format("  i:%2d exc: %s\n", i, Arrays.toString(exc[i]));
        System.out.format("  i:%2d pre: %s\n", i, Arrays.toString(pre[i]));
        System.out.format("  i:%2d qua: %s\n", i, Arrays.toString(qua[i]));
      }
      if (pre[i][n-1] == 0 || i + 1 == n) {
        e = i;
        break;
      }
    }

    long x0 = 0;
    for (int i = e; i >= 0; i--) {
      for (int j = 1; j < n; j++) {
        dp[i][j] = (qua[i][j] + (i == 15 || j == 0 ? 0 : dp[i+1][j] % MOD)) % MOD;
      }
      if (test) {
        System.out.format("  i:%2d  dp: %s\n", i, Arrays.toString(dp[i]));
      }
    }
    long ans = 0;
    for (int i = 0; i < n; i++) {
      ans = (ans + dp[0][i]) % MOD;
    }
    return (int) ans;
  }

  static long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a % b);
  }

  // Get number of values w in [1,m] such that:
  //   gcd(w, v) != 1
  //   gcd(w, v-1) != 1
  //   ...
  //   gcd(w, v-k+1) != 1
  static long getNonCoprimeCount(int v, int k, long m, List<Integer>[] primes) {
    // System.out.format("  v:%d k:%d m:%d\n", v, k, m);
    if (v == 1) {
      return m % MOD;
    }
    k = Math.min(v - 1, k);
    List<List<Integer>> pa = new ArrayList<>();
    for (int w = v; w > v - k; w--) {
      pa.add(primes[w]);
    }
    // collect all combinations. An example of n = 100, k = 4
    //    v: 2 5
    //  v-1: 3 11
    //  v-2: 2 7
    //  v-3: 97
    // we have following 8 combinations:
    //  (2,3,97) (2,3,7,97) (2,11,97) (2,11,7,97) (5,3,2,97) (5,3,7,97) (5,11,2,97) (5,11,2,97)

    // System.out.format("  v:%d k:%d m:%d pa:%s\n", v, k, m, Utils.traceListListInt(pa));
    if (pa.isEmpty() || m == 0) {
      return m % MOD;
    }
    return getCountPms(m, pa);
  }

  static long getCountPms(long m, List<List<Integer>> pms) {
    List<Set<Integer>> arr = getCombinationSets(pms);
    int idx = 0;
    for (Set<Integer> x : arr) {
      idx++;
      // System.out.format("  %d : %s\n", idx, x.toString());
    }
    return getCountSets(m, arr);
  }

  static long getCountSets(long m, List<Set<Integer>> arr) {
    long ans = 0;
    if (m > 0) {
      int n = arr.size();
      long p = 1;
      for (int w : arr.get(0)) {
        p = p * w;
      }
      if (n == 1) {
        ans = (m / p) % MOD;
      } else {
        // Use PIE
        // case 1: only take the first set
        ans = (ans + m / p) % MOD;

        // case 2: take the first set and non-empty others
        List<Set<Integer>> brr = new ArrayList<>();
        Set<Integer> st0 = arr.get(0);
        for (int i = 1; i < n; i++) {
          Set<Integer> st = new HashSet<>(arr.get(i));
          st.removeAll(st0);
          if (!brr.contains(st)) {
            brr.add(st);
          }
        }

        ans = (ans + MOD - getCountSets(m / p, brr)) % MOD;
        // case 3: do not take the first set
        List<Set<Integer>> crr = new ArrayList<>();
        crr.addAll(arr.subList(1, n));
        ans = (ans + getCountSets(m, crr)) % MOD;
      }
    }
    // System.out.format("  %9d <- %s %d\n", ans, traceListSetInt(arr), m);
    return ans;
  }

  static String traceListSetInt(List<Set<Integer>> arr) {
    StringBuilder sb = new StringBuilder();
    for (Set<Integer> v : arr) {
      if (sb.length() > 0) {
        sb.append(',');
      }
      sb.append(v.toString().replace(" ", ""));
    }
    return sb.toString();
  }

  static List<Set<Integer>> getCombinationSets(List<List<Integer>> pa) {
    List<Set<Integer>> curr = new ArrayList<>();
    curr.add(new HashSet<>());
    for (List<Integer> v : pa) {
      List<Set<Integer>> next = new ArrayList<>();
      for (int w : v) {
        for (Set<Integer> x : curr) {
          Set<Integer> y = new HashSet<>(x);
          y.add(w);
          next.add(y);
        }
      }
      curr = next;
    }
    return curr;
  }

  static long getCountPie(long m, List<List<Integer>> pa) {
    List<List<Integer>> arr = getCombinations(pa);
    int idx = 0;
    for (List<Integer> x : arr) {
      idx++;
      System.out.format("  %d : %s\n", idx, x.toString());
    }

    // Use PIE to get the result
    int n = arr.size();
    long ans = 0;
    for (int i = 1; i < (1 << n); i++) {
      int h = Integer.bitCount(i);
      Set<Integer> s = new HashSet<>();
      for (int j = 0; j < n; j++) {
        if (((1 << j) & i) != 0) {
          s.addAll(arr.get(j));
        }
      }
      // System.out.format("  i:%d s:%s\n", i, s.toString());
      long p = 1;
      for (int w : s) {
        p = p * w;
      }
      long ct = m / p;
      if (h % 2 == 1) {
        // positive
        ans += ct;
      } else {
        // negative
        ans -= ct;
      }
    }
    // myAssert(ans == getCountNaive(m, pa));
    return ans;
  }

  static long getCountNaive(long m, List<List<Integer>> pa) {
    Set<Integer> s = new HashSet<>();
    for (List<Integer> p : pa) {
      s.addAll(p);
    }
    long prod = 1;
    for (int v : s) {
      prod *= v;
    }
    long k = m / prod;
    long r = m % prod;

    List<Long> curr = new ArrayList<>();
    for (long i = 1; i <= prod; i++) {
      curr.add(i);
    }
    for (List<Integer> p : pa) {
      List<Long> next = new ArrayList<>();
      for (long w : curr) {
        for (int x : p) {
          if (w % x == 0) {
            next.add(w);
            break;
          }
        }
      }
      curr = next;
    }

    long ans = curr.size() * k;
    if (r > 0) {
      int b = 0;
      while (curr.get(b) <= r) {
        b++;
      }
      ans += b;
    }
    return ans;
  }

  static List<List<Integer>> getCombinations(List<List<Integer>> pa) {
    List<List<Integer>> curr = new ArrayList<>();
    curr.add(new ArrayList<>());
    for (List<Integer> v : pa) {
      List<List<Integer>> next = new ArrayList<>();
      for (int w : v) {
        for (List<Integer> x : curr) {
          List<Integer> y = new ArrayList<>(x);
          y.add(w);
          dedup(y);
          next.add(y);
        }
      }
      curr = next;
    }
    return curr;
  }

  static void dedup(List<Integer> a) {
    Collections.sort(a);
    int i = 1;
    int j = 1;
    while (j < a.size()) {
      if (a.get(j) != a.get(i-1)) {
        if (j > i) {
          a.set(i, a.get(j));
        }
        i++;
      }
      j++;
    }
    while (a.size() > i) {
      a.remove(a.size() - 1);
    }
  }

  static List<Integer> merge(List<Integer> a, List<Integer> b) {
    List<Integer> c = new ArrayList<>();
    c.addAll(a);
    c.addAll(b);
    Collections.sort(c);
    dedup(c);
    return c;
  }

  static void incubate() {
    int n = 100;
    List<Integer>[] primes = getPrimeFactors(n);
    {
      long m = (long) 1e6;
      for (int k = 1; k < 10; k++) {
        for (int v = 2; v <= n; v++) {
          long ans = getNonCoprimeCount(v, k, m, primes);
          System.out.format("  v:%4d %d -> %d\n", v, k, ans);
          if (ans == 0) {
            System.exit(0);
          }
        }
      }
      System.exit(0);
    }

    List<Integer> a = new ArrayList<>(Arrays.asList(2,7,3,2));
    dedup(a);
    System.out.format("  a:%s\n", a.toString());

    List<Integer>[] arr = getPrimeFactors(n);
    for (int v = 2; v <= n; v++) {
      System.out.format("  v:%3d %s\n", v, arr[v].toString());
    }
  }

  static List<Integer>[] getPrimeFactors(int n) {
    List<Integer>[] arr = new ArrayList[n+1];
    for (int i = 0; i <= n; i++) {
      arr[i] = new ArrayList<>();
    }
    boolean[] isNotPrime = new boolean[n+1];
    int p = 2;
    while (p <= n) {
      if (!isNotPrime[p]) {
        int v = p;
        do {
          isNotPrime[v] = true;
          arr[v].add(p);
          v += p;
        } while (v <= n);
      }
      p++;
    }
    return arr;
  }

  static boolean isAmbiguous(List<Integer> nums) {
    int m = nums.size();
    if (m <= 1) {
      return false;
    }
    for (int i = 1; i < m; i++) {
      if (gcd(nums.get(i), i+1) == 1) {
        return true;
      }
    }
    return isAmbiguous(nums.subList(1, m));
  }

  static void test(int exp, int n, long m) {
    int ans = solve(n, m);
    System.out.format("%d %d => %d %s\n", n, m, ans, ans == exp ? "":"Expected " + exp);
    myAssert(ans == exp);
  }

  static boolean test = false;
  static void doTest() {
    if (!test) {
      return;
    }
    long t0 = System.currentTimeMillis();
    /*
    long m = 100000;
    List<List<Integer>> pms = new ArrayList<>();
    pms.add(Arrays.asList(2,5));
    pms.add(Arrays.asList(3,11));
    long ans1 = getCountNaive(m, pms);
    long ans2 = getCountPie(m, pms);
    long ans3 = getCountPms(m, pms);
    System.out.format("  ans1:%d ans2:%d ans3:%d\n", ans1, ans2, ans3);
    incubate();
    */
    test(1494, 4, 6);
    test(6, 2, 3);
    test(26, 4, 2);
    test(1494, 4, 6);
    test(851241741, 100, 1000000);

    test(119112628, 1337, 424242424242L);
    System.out.format("%d msec\n", System.currentTimeMillis() - t0);
    System.exit(0);
  }

  public static void main(String[] args) {
    doTest();
    MyScanner in = new MyScanner();
    int n = in.nextInt();
    long m = in.nextLong();
    int ans = solve(n, m);
    System.out.println(ans);
  }

  static void output(int[] a) {
    if (a == null) {
      System.out.println("-1");
      return;
    }
    StringBuilder sb = new StringBuilder();
    for (int v : a) {
      sb.append(v);
      sb.append(' ');
      if (sb.length() > 4000) {
        System.out.print(sb.toString());
        sb.setLength(0);
      }
    }
    System.out.println(sb.toString());
  }

  static void myAssert(boolean cond) {
    if (!cond) {
      throw new RuntimeException("Unexpected");
    }
  }

  static class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    public MyScanner() {
      try {
        final String USERDIR = System.getProperty("user.dir");
        String cname = MethodHandles.lookup().lookupClass().getCanonicalName().replace(".MyScanner", "");
        cname = cname.lastIndexOf('.') > 0 ? cname.substring(cname.lastIndexOf('.') + 1) : cname;
        final File fin = new File(USERDIR + "/io/c" + cname.substring(1,5) + "/" + cname + ".in");
        br = new BufferedReader(new InputStreamReader(fin.exists()
            ? new FileInputStream(fin) : System.in));
      } catch (Exception e) {
        br = new BufferedReader(new InputStreamReader(System.in));
      }
    }

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

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

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


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

public class Main {
    static final Reader READER = new Reader(System.in);
    static final PrintWriter PRINT_WRITER = new PrintWriter(System.out, true);

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

        int MOD = 998244353;

        int n = READER.nextInt();
        long m = READER.nextLong();

        // 求出 2-n之间所有素数
        List<Integer> list = primeNumbers(n);
        int index = 0;
        // dp[0][i] 表示不可行的 且数组长度为i的数组数量 , dp[1][i] 表示可行，且长度为i的数组数量
        // dp[1][i] = dp[1][i-1] * m + dp[0][i-1] * (m里面可行的数字)
        // dp[0][i] = dp[0][i-1] * (m里面不可行的数字)
        // m 里面可行的数字 + m不可行的数字 = m
        long[][] dp = new long[2][n + 1];
        dp[0][1] = m % MOD;
        long bas = 1;
        for (int i = 2; i <= n; i++) {
            // 前面位置可以选择的数字是base个
            if (index < list.size() && list.get(index) == i) {
                bas *= list.get(index++);
            }
            // 计算m里面可以不被这些因子整除的数字
            long divCount = m / bas;     // 能被整除的数字
            long noDivCount = m - divCount;
            dp[0][i] = (dp[0][i - 1] * (divCount % MOD)) % MOD;
            dp[1][i] = (dp[1][i - 1] * (m % MOD)) % MOD + (dp[0][i - 1] * (noDivCount % MOD)) % MOD;
            dp[1][i] %= MOD;
        }

        long res = 0;
        for (int i = 2; i <=n ; i++) {
            res += dp[1][i];
            res %= MOD;
        }

        PRINT_WRITER.println(res);

    }

    public static List<Integer> primeNumbers(int number) {
        List<Integer> res = new ArrayList<>();
        boolean[] map = new boolean[number + 1];
        for (int i = 2; i <= number; i++) {
            if (!map[i]) {
                res.add(i);
            }
            for (Integer re : res) {
                if (re <= number / i) {
                    map[re * i] = true;
                }
                if (i % re == 0) {
                    break;
                }
            }
        }
        return res;
    }

    static class Reader {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        public Reader(InputStream inputStream) {
            this.reader = new BufferedReader(new InputStreamReader(inputStream));
            this.tokenizer = new StringTokenizer("");
        }

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

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

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

    }
}


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

public class Main {
    static final Reader READER = new Reader(System.in);
    static final PrintWriter PRINT_WRITER = new PrintWriter(System.out, true);

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

        int MOD = 998244353;

        int n = READER.nextInt();
        long m = READER.nextLong();

        // 求出 2-n之间所有素数

        // dp[0][i] 表示不可行的 且数组长度为i的数组数量 , dp[1][i] 表示可行，且长度为i的数组数量
        // dp[1][i] = dp[1][i-1] * m + dp[0][i-1] * (m里面可行的数字)
        // dp[0][i] = dp[0][i-1] * (m里面不可行的数字)
        // m 里面可行的数字 + m不可行的数字 = m
        boolean[] map = new boolean[n + 1];
        List<Integer> facList = new ArrayList<>();

        long[][] dp = new long[2][n + 1];
        dp[0][1] = m % MOD;
        long bas = 1;
        for (int i = 2; i <= n; i++) {
            // 前面位置可以选择的数字是base个
            if (!map[i]){
                facList.add(i);
                bas *= i;
            }
            for (int re : facList) {
                if (re <= n / i) {
                    map[re * i] = true;
                }
                if (i % re == 0) {
                    break;
                }
            }

            // 计算m里面可以不被这些因子整除的数字
            long divCount = m / bas;     // 能被整除的数字
            long noDivCount = m - divCount;
            dp[0][i] = (dp[0][i - 1] * (divCount % MOD)) % MOD;
            dp[1][i] = (dp[1][i - 1] * (m % MOD)) % MOD + (dp[0][i - 1] * (noDivCount % MOD)) % MOD;
            dp[1][i] %= MOD;
        }

        long res = 0;
        for (int i = 2; i <=n ; i++) {
            res += dp[1][i];
            res %= MOD;
        }

        PRINT_WRITER.println(res);

    }

//    public static List<Integer> primeNumbers(int number) {
//        List<Integer> res = new ArrayList<>();
//        boolean[] map = new boolean[number + 1];
//        for (int i = 2; i <= number; i++) {
//            if (!map[i]) {
//                res.add(i);
//            }
//            for (Integer re : res) {
//                if (re <= number / i) {
//                    map[re * i] = true;
//                }
//                if (i % re == 0) {
//                    break;
//                }
//            }
//        }
//        return res;
//    }

    static class Reader {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        public Reader(InputStream inputStream) {
            this.reader = new BufferedReader(new InputStreamReader(inputStream));
            this.tokenizer = new StringTokenizer("");
        }

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

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

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

    }
}


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

public class D {

    static long MOD = 998244353l;

    public static void main(String[] args) {
        FastIO io = new FastIO();
        long n = io.nextLong();
        long m = io.nextLong();
        long sum = 0;
        for (long i = 1; long <= n; i++) sum = (sum + binpow(m, i, MOD)) % MOD;

        long[] primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37};

        int p = 0;
        long cur = 1;
        long seq = 1;
        long ans = 0;
        for (int i = 1; i <= 37; i++) {

            if (i == primes[p]) seq = 1l * seq * primes[p++];

            long local = (m / seq) % MOD;

            cur = (1l * local * cur) % MOD;
            ans = (ans + cur) % MOD;
        }

        io.println((sum - ans + MOD + MOD + MOD + MOD) % MOD);
        io.close();
    }

    public static long binpow(long x, long n, long m) {
        //inverse modulo= binpow(2, MOD - 2, MOD);
        assert (n >= 0);
        x %= m;  // note: m * m must be less than 2^63 to avoid ll overflow
        long res = 1;
        while (n > 0) {
            if (n % 2 == 1)  // if n is odd
                res = res * x % m;
            x = x * x % m;
            n /= 2;  // divide by two
        }
        return res;
    }

    private static class FastIO extends PrintWriter {
        private final InputStream stream;
        private final byte[] buf = new byte[1 << 16];
        private int curChar, numChars;

        // standard input
        public FastIO() {
            this(System.in, System.out);
        }

        public FastIO(InputStream i, OutputStream o) {
            super(o);
            stream = i;
        }

        // file input
        public FastIO(String i, String o) throws IOException {
            super(new FileWriter(o));
            stream = new FileInputStream(i);
        }

        // throws InputMismatchException() if previously detected end of file
        private int nextByte() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars == -1) return -1; // end of file
            }
            return buf[curChar++];
        }

        // to read in entire lines, replace c <= ' '
        // with a function that checks whether c is a line break
        public String next() {
            int c;
            do {
                c = nextByte();
            } while (c <= ' ');
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = nextByte();
            } while (c > ' ');
            return res.toString();
        }

        public int nextInt() { // nextLong() would be implemented similarly
            int c;
            do {
                c = nextByte();
            } while (c <= ' ');
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = nextByte();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') throw new InputMismatchException();
                res = 10 * res + c - '0';
                c = nextByte();
            } while (c > ' ');
            return res * sgn;
        }

        public long nextLong() { // nextLong() would be implemented similarly
            int c;
            do {
                c = nextByte();
            } while (c <= ' ');
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = nextByte();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') throw new InputMismatchException();
                res = 10 * res + c - '0';
                c = nextByte();
            } while (c > ' ');
            return res * sgn;
        }

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

}


import java.io.*;
import java.util.*;
public class D30 {
public static void main(String[] args) throws IOException {
	input.init(System.in);
	PrintWriter out = new PrintWriter(System.out);
	int n = input.nextInt(), k = input.nextInt() - 1;
	Point[] data = new Point[n+1];
	int[] xs = new int[n];
	for(int i = 0; i<n; i++) xs[i] = input.nextInt();
	int mark = -1;
	if(k < n)
	{
		mark = xs[k];
	}
	Arrays.sort(xs);
	if(mark != -1)
	{
		for(int i = 0; i<n; i++) if(xs[i] == mark) k = i;
	}
	for(int i = 0; i<n; i++) data[i] = new Point(xs[i], 0);
	data[n] = new Point(input.nextDouble(), input.nextDouble());
	if(k == n)
	{
		double res = Math.min(data[0].dist(data[k]), data[n-1].dist(data[k]));
		for(int i = 0; i<n-1; i++) res += data[i].dist(data[i+1]);
		out.println(res);
	}
	else
	{
		double res = 1e18;
		for(int i = k; i<n; i++)
		{
			double cur = data[i].dist(data[k]) + data[i].dist(data[0]);
			cur += data[0].dist(data[n]);
			if(i != n-1)
			{
				cur += data[n-1].dist(data[i+1]);
				cur += Math.min(data[n-1].dist(data[n]), data[i+1].dist(data[n]));
			}
			//out.println(i+" "+cur);
			if(cur<res) res = cur;
		}
		for(int i = 0; i<= k; i++)
		{
			double cur = data[i].dist(data[k]) + data[i].dist(data[n-1]);
			cur += data[n-1].dist(data[n]);
			if(i != 0)
			{
				cur += data[0].dist(data[i-1]);
				cur += Math.min(data[0].dist(data[n]), data[i-1].dist(data[n]));
			}
			if(cur < res) res = cur;
		}
		out.println(res);
	}

	out.close();
}
static class Point
{
	double x, y;
	public Point(double xx, double yy)
	{
		x = xx; y = yy;
	}
	double dist(Point p)
	{
		return Math.sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y));
	}
}
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.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.*;

public class Main implements Runnable {
	private boolean _READ_FROM_FILE = false; //System.getSecurityManager() == null; //System.getProperty("ONLINE_JUDGE") == null;
	private boolean _WRITE_TO_FILE = false;
	static final String _TASK_ID = "in";
	static final String _IN_FILE = _TASK_ID + ".in";
	static final String _OUT_FILE = _TASK_ID + ".out";
	BufferedReader reader;
	StringTokenizer tokenizer;

	private void core() throws Exception {
		int n = nextInt(), start = nextInt() - 1;
		long[] x = new long[n+1];
		long[] y = new long[n+1];
		for (int i = 0; i < x.length; i++) {
			x[i] = nextLong();
		}
		y[n] = nextLong();
		long xstart = x[start];
		Arrays.sort(x, 0, n);

		if (start == n) {
			System.out.println(solve(0, n-1, x, x[n], y[n]));
		}
		else {
			for (int i = 0; i < n; i++) {
				if (x[i] == xstart)
					start = i;
			}
			debug(x);
			debug(y);
			double res = Double.POSITIVE_INFINITY;
			for (int i = 0; i <= start; i++) {
				int min = i == 0 ? start + 1 : 0;
				int max = start == n - 1 ? i - 1 : n - 1;
				double cur = Math.abs(x[start] - x[i]) + dist(x, y, i, n) + solve(min, max, x, x[n], y[n]);
				debug(cur, start, i, min, max);
				res = Math.min(res, cur);
			}
			for (int i = start + 1; i < n; i++) {
				int min = start == 0 ? i + 1 : 0;
				int max = i == n - 1 ? start - 1 : n - 1;
				double cur = Math.abs(x[start] - x[i]) + dist(x, y, i, n) + solve(min, max, x, x[n], y[n]);
				debug(cur, start, i, min, max);
				res = Math.min(res, cur);
			}
			System.out.println(res);
		}
	}
	private double dist(long[] x, long[] y, int i, int j) {
		double dx = x[i] - x[j];
		double dy = y[i] - y[j];
		return Math.sqrt(dx * dx + dy * dy);
	}
	private double solve(int i, int j, long[] x, long xn, long yn) {
		if (i <= j) {
			double l1 = Math.sqrt(sqr(xn - x[i]) + sqr(yn));
			double l2 = Math.sqrt(sqr(xn - x[j]) + sqr(yn));
			return Math.min(l1, l2) + Math.abs(x[i]- x[j]);
		}
		return 0;
	}
	private long sqr(long l) {
		return l*l;
	}
	void debug(Object...os) {
//		System.out.println(Arrays.deepToString(os));
	}
	//--------------------- IO stuffs ---------------------
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new Main());
        thread.start();
        thread.join();
    }
	public void run() {
        try {
        	reader = new BufferedReader(_READ_FROM_FILE ? new FileReader(_IN_FILE) : new InputStreamReader(System.in));
        	System.setOut(new PrintStream(new BufferedOutputStream(_WRITE_TO_FILE ? new FileOutputStream(_OUT_FILE) : System.out)));
            tokenizer = new StringTokenizer("");
            core();
            reader.close();
            System.out.flush();
            System.out.close();
            System.exit(0);
        } catch (Exception e) {
        	System.out.flush();
            e.printStackTrace();
            System.exit(1);
        }
    }
    int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }
    long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }
    double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
    String nextToken() throws Exception {
        while (!tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(reader.readLine());
        return tokenizer.nextToken();
    }
    boolean nextIsAvailable() throws Exception {
    	while (!tokenizer.hasMoreElements()) {
    		String line = reader.readLine();
    		if (line == null) return false;
    		tokenizer = new StringTokenizer(line);
    	}
    	return true;
    }
}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;

/**
 * @author Egor Kulikov (egor@egork.net)
 *         Created on 14.03.2010
 */
public class TaskD implements Runnable {
	private InputReader in;
	private PrintWriter out;

	public static void main(String[] args) {
//		new Thread(new Template()).start();
		new TaskD().run();
	}

	public TaskD() {
//		String id = getClass().getName().toLowerCase();
//		try {
//			System.setIn(new FileInputStream(id + ".in"));
//			System.setOut(new PrintStream(new FileOutputStream(id + ".out")));
//			System.setIn(new FileInputStream("input.txt"));
//			System.setOut(new PrintStream(new FileOutputStream("output.txt")));
//		} catch (FileNotFoundException e) {
//			throw new RuntimeException();
//		}
		in = new InputReader(System.in);
		out = new PrintWriter(System.out);
	}

	public void run() {
//        int numTests = in.readInt();
//        for (int testNumber = 0; testNumber < numTests; testNumber++) {
		process();
//        }
		out.close();
	}

	private void process() {
		int n = in.readInt();
		int k = in.readInt();
		final int[] x = new int[n + 1];
		for (int i = 0; i <= n; i++)
			x[i] = in.readInt();
		int y = in.readInt();
		double ans;
		int minIndex = 0;
		int maxIndex = 0;
		int min = x[0];
		int max = x[0];
		for (int i = 1; i < n; i++) {
			if (x[i] < min) {
				min = x[i];
				minIndex = i;
			}
			if (x[i] > max) {
				max = x[i];
				maxIndex = i;
			}
		}
		Integer[] o = new Integer[n];
		for (int i = 0; i < n; i++)
			o[i] = i;
		Arrays.sort(o, new Comparator<Integer>() {
			public int compare(Integer o1, Integer o2) {
				return x[o1] - x[o2];
			}
		});
		int[] oo = new int[n];
		for (int i = 0; i < n; i++)
			oo[o[i]] = i;
		if (k == n + 1)
			ans = x[maxIndex] - x[minIndex] + Math.min(Math.hypot(x[n] - x[minIndex], y), Math.hypot(x[n] - x[maxIndex], y));
		else {
			int start = oo[k - 1];
			Arrays.sort(x, 0, n);
			ans = x[start] - x[0] + x[n - 1] - x[0] + Math.hypot(x[n - 1] - x[n], y);
			int cur = start;
			while (cur != n - 1) {
				int next;
				if (cur == 0)
					next = start + 1;
				else if (cur <= start)
					next = cur - 1;
				else
					next = cur + 1;
				double v1;
				if (cur <= start)
					v1 = x[start] - x[cur];
				else
					v1 = x[start] - x[0] + x[cur] - x[0];
				double v2;
				if (next <= start)
					v2 = x[next] - x[0] + x[n - 1] - x[0];
				else
					v2 = x[n - 1] - x[next];
				ans = Math.min(ans, v1 + v2 + Math.hypot(x[cur] - x[n], y) + Math.hypot(x[next] - x[n], y));
				cur = next;
			}
			cur = start;
			ans = Math.min(ans, x[n - 1] - x[start] + x[n - 1] - x[0] + Math.hypot(x[0] - x[n], y));
			ans = Math.min(ans, x[n - 1] - x[0] + Math.hypot(x[start] - x[n], y) + Math.min(Math.hypot(x[n] - x[0], y), Math.hypot(x[n] - x[n - 1], y)));
			while (cur != 0) {
				int next;
				if (cur == n - 1)
					next = start - 1;
				else if (cur >= start)
					next = cur + 1;
				else
					next = cur - 1;
				double v1;
				if (cur >= start)
					v1 = x[cur] - x[start];
				else
					v1 = x[n - 1] - x[start] + x[n - 1] - x[cur];
				double v2;
				if (next >= start)
					v2 = x[n - 1] - x[next] + x[n - 1] - x[0];
				else
					v2 = x[next] - x[0];
				ans = Math.min(ans, v1 + v2 + Math.hypot(x[cur] - x[n], y) + Math.hypot(x[next] - x[n], y));
				cur = next;
			}
		}
		out.printf("%.8f\n", ans);
	}

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

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

		private 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++];
		}

		public int readInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long readLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

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

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

		private String readLine0() {
			StringBuffer buf = new StringBuffer();
			int c = read();
			while (c != '\n' && c != -1) {
				buf.appendCodePoint(c);
				c = read();
			}
			return buf.toString();
		}

		public String readLine() {
			String s = readLine0();
			while (s.trim().length() == 0)
				s = readLine0();
			return s;
		}

		public String readLine(boolean ignoreEmptyLines) {
			if (ignoreEmptyLines)
				return readLine();
			else
				return readLine0();
		}

		public BigInteger readBigInteger() {
			try {
				return new BigInteger(readString());
			} catch (NumberFormatException e) {
				throw new InputMismatchException();
			}
		}

		public char readCharacter() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			return (char) c;
		}

		public double readDouble() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.') {
				if (c < '0' || c > '9') {
					if (c == 'e' || c == 'E') {
						int e = readInt();
						return res * Math.pow(10, e);
					}
					throw new InputMismatchException();
				}
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.') {
				c = read();
				double m = 1;
				while (!isSpaceChar(c)) {
					if (c == 'e' || c == 'E') {
						int e = readInt();
						return res * Math.pow(10, e);
					}
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}
	}
}


import java.util.*;

public class P030D {
    private long[] pos;
    private long cx;
    private long cy;
    private final int N;

    private double distToC(int i) {
        long dx = cx - pos[i];
        return Math.sqrt(dx*dx + cy*cy);
    }

    private double distBetween(int i, int j) {
        return (double)Math.abs(pos[i] - pos[j]);
    }

    private double solveC(int i, int j) {
        double d1 = distToC(i);
        double d2 = distToC(j);
        return Math.min(d1, d2) + distBetween(i, j);
    }

    private double solveMiddle(int i) {
        assert 0 < i && i < N-1;
        double d1 = distToC(i) + solveC(0, N-1);
        double d2 = distBetween(0, i) + distToC(0) + solveC(i+1, N-1);
        double d3 = distBetween(i, N-1) + distToC(N-1) + solveC(0, i-1);
        return min3(d1, d2, d3);
    }

    private double solveLeftEnd() {
        double result = Double.MAX_VALUE;
        for (int i = 0; i < N-1; i++) {
            double d = distBetween(0, i) + distToC(i) + solveC(i+1, N-1);
            result = Math.min(result, d);
        }
        // last one
        double d = distBetween(0, N-1) + distToC(N-1);
        result = Math.min(result, d);

        return result;
    }

    private double solveRightEnd() {
        double result = Double.MAX_VALUE;
        for (int i = N-1; i > 0; i--) {
            double d = distBetween(i, N-1) + distToC(i) + solveC(0, i-1);
            result = Math.min(result, d);
        }
        double d = distBetween(0, N-1) + distToC(0);
        result = Math.min(result, d);

        return result;
    }

    private double min3(double x1, double x2, double x3) {
        return Math.min(Math.min(x1, x2), x3);
    }

    private double solve(int k) {
        if (k == N) {
            Arrays.sort(pos);
            return solveC(0, N-1);
        }

        long xk = pos[k];
        int k2 = -1;
        Arrays.sort(pos);

        for (int i = 0; i < pos.length; i++) {
            if (pos[i] == xk) {
                k2 = i;
                break;
            }
        }

        if (k2 == 0) {
            return solveLeftEnd();
        }
        else if (k2 == N-1) {
            return solveRightEnd();
        }
        else {
            return solveMiddle(k2);
        }
    }

    public P030D() {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        int k = sc.nextInt() - 1;
        pos = new long[N];
        for (int i = 0; i < N; i++) {
            pos[i] = sc.nextInt();
        }
        cx = sc.nextInt();
        cy = sc.nextInt();

        double result = solve(k);
        System.out.printf("%.10f\n", result);
    }

    public static void main(String[] args) {
        P030D solution = new P030D();
    }
}