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

public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        long mod = 998244353;
        int n = sc.nextInt();
        long[] dp = new long[n+2];
        dp[0] = 1;
        for(int i = 0; i <= n; i++){
            int now = 1;
            while(now+i < n+1){
                dp[now+i] += dp[i];
                dp[now+i] %= mod;
                now += 2;
            }
        }
        long r2 = rep2(2,n,mod);
        long rep = rep2(r2,mod-2,mod);
        pw.println(dp[n]*rep % mod);
        pw.flush();
    }

    private static long rep2(long b, long n, long mod){
        if(n == 0) return 1;
        long bn = rep2(b,n/2,mod);
        if(n % 2 == 0){
            return (bn*bn)%mod;
        }else{
            return (bn*bn)%mod*b%mod;
        }
    }

    static class GeekInteger {
        public static void save_sort(long[] array) {
            shuffle(array);
            Arrays.sort(array);
        }

        public static long[] shuffle(long[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                long randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }

    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

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

    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}


import java.util.*;
import java.io.*;
public class Main {
    static class Scan {
        private byte[] buf=new byte[1024];
        private int index;
        private InputStream in;
        private int total;
        public Scan()
        {
            in=System.in;
        }
        public int scan()throws IOException
        {
            if(total<0)
            throw new InputMismatchException();
            if(index>=total)
            {
                index=0;
                total=in.read(buf);
                if(total<=0)
                return -1;
            }
            return buf[index++];
        }
        public int scanInt()throws IOException
        {
            int integer=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    integer*=10;
                    integer+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            return neg*integer;
        }
        public double scanDouble()throws IOException
        {
            double doub=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n)&&n!='.')
            {
                if(n>='0'&&n<='9')
                {
                    doub*=10;
                    doub+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            if(n=='.')
            {
                n=scan();
                double temp=1;
                while(!isWhiteSpace(n))
                {
                    if(n>='0'&&n<='9')
                    {
                        temp/=10;
                        doub+=(n-'0')*temp;
                        n=scan();
                    }
                    else throw new InputMismatchException();
                }
            }
            return doub*neg;
        }
        public String scanString()throws IOException
        {
            StringBuilder sb=new StringBuilder();
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            while(!isWhiteSpace(n))
            {
                sb.append((char)n);
                n=scan();
            }
            return sb.toString();
        }
        private boolean isWhiteSpace(int n)
        {
            if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
            return true;
            return false;
        }
    }

    public static void sort(int arr[],int l,int r) {    //sort(arr,0,n-1);
        if(l==r) {
            return;
        }
        int mid=(l+r)/2;
        sort(arr,l,mid);
        sort(arr,mid+1,r);
        merge(arr,l,mid,mid+1,r);
    }
    public static void merge(int arr[],int l1,int r1,int l2,int r2) {
        int tmp[]=new int[r2-l1+1];
        int indx1=l1,indx2=l2;
        //sorting the two halves using a tmp array
        for(int i=0;i<tmp.length;i++) {
            if(indx1>r1) {
                tmp[i]=arr[indx2];
                indx2++;
                continue;
            }
            if(indx2>r2) {
                tmp[i]=arr[indx1];
                indx1++;
                continue;
            }
            if(arr[indx1]<arr[indx2]) {
                tmp[i]=arr[indx1];
                indx1++;
                continue;
            }
            tmp[i]=arr[indx2];
            indx2++;
        }
        //Copying the elements of tmp into the main array
        for(int i=0,j=l1;i<tmp.length;i++,j++) {
            arr[j]=tmp[i];
        }
    }

    public static void sort(long arr[],int l,int r) {    //sort(arr,0,n-1);
        if(l==r) {
            return;
        }
        int mid=(l+r)/2;
        sort(arr,l,mid);
        sort(arr,mid+1,r);
        merge(arr,l,mid,mid+1,r);
    }
    public static void merge(long arr[],int l1,int r1,int l2,int r2) {
        long tmp[]=new long[r2-l1+1];
        int indx1=l1,indx2=l2;
        //sorting the two halves using a tmp array
        for(int i=0;i<tmp.length;i++) {
            if(indx1>r1) {
                tmp[i]=arr[indx2];
                indx2++;
                continue;
            }
            if(indx2>r2) {
                tmp[i]=arr[indx1];
                indx1++;
                continue;
            }
            if(arr[indx1]<arr[indx2]) {
                tmp[i]=arr[indx1];
                indx1++;
                continue;
            }
            tmp[i]=arr[indx2];
            indx2++;
        }
        //Copying the elements of tmp into the main array
        for(int i=0,j=l1;i<tmp.length;i++,j++) {
            arr[j]=tmp[i];
        }
    }
    static long dp[],mod;
    public static void main(String args[]) throws IOException {
        Scan input=new Scan();
        int n=input.scanInt();
        dp=new long[n+1];
        Arrays.fill(dp, -1);
        long den=1;
        mod=998244353;
        for(int i=0;i<n;i++) {
            den*=2;
            den%=mod;
        }
        long num=solve(n);
        den=inv(den,mod);
        long ans=num*den;
        ans%=mod;
        System.out.println(ans);
    }

    public static long inv(long a,long n) {
        long q,r1=n,r2=a,r,t1=0,t2=1,t;
        while(true) {
            q=r1/r2;
            r=r1%r2;
            t=t1-(q*t2);
            r1=r2;
            r2=r;
            t1=t2;
            t2=t;
            if(r2==0) {
                    break;
            }
        }
        if(r1!=1) {
                return -1;
        }
        t1%=n;
        if(t1<0) {
                t1+=n;
        }
        return t1;
    }

    public static long solve(int n) {
        if(n==0) {
            return 1;
        }
        if(dp[n]!=-1) {
            return dp[n];
        }
        long ans=0;
        for(int i=1;i<=n;i++) {
            int lft=i-1;
            int rgt=i+lft;
            if(rgt>n) {
                break;
            }
            ans+=solve(n-rgt);
            ans%=mod;
        }
        dp[n]=ans;
        return ans;
    }
}


import java.util.*;
import java.io.*;
public class MainClass
{
    public static void main(String[] args)throws IOException
    {
        Reader in = new Reader();
        int n = in.nextInt();
        long[] f = new long[n + 10];
        f[0] = 0L;
        f[1] = 1L;
        f[2] = 1L;
        long M = 998244353L;
        for (int i=3;i<f.length;i++)
            f[i] = (f[i - 1] + f[i - 2]) % M;
        NumberTheory numberTheory = new NumberTheory();
        long pp = binPow(2L, n, M);
        long inv = (numberTheory.extendedEuclid(pp, M).x + M) % M;
        long ans = (inv * f[n]) % M;
        System.out.println(ans);
    }
    public static long binPow(long a, int n, long M)
    {
        if (n == 0)
            return 1L;
        long res = binPow(a, n/ 2 , M);
        res = (res * res) % M;
        if (n % 2 == 1)
            res = (res * a) % M;
        return res;
    }
}
class Reader
{
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public Reader()
    {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(String file_name) throws IOException
    {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException
    {
        byte[] buf = new byte[64]; // line length
        int cnt = 0, c;
        while ((c = read()) != -1)
        {
            if (c == '\n')
                break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException
    {
        int ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do
        {
            ret = ret * 10 + c - '0';
        }  while ((c = read()) >= '0' && c <= '9');

        if (neg)
            return -ret;
        return ret;
    }

    public long nextLong() throws IOException
    {
        long ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');
        if (neg)
            return -ret;
        return ret;
    }

    public double nextDouble() throws IOException
    {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException
    {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1)
            buffer[0] = -1;
    }

    private byte read() throws IOException
    {
        if (bufferPointer == bytesRead)
            fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException
    {
        if (din == null)
            return;
        din.close();
    }
}


// Author @ BlackRise :) //
// Birla Institute of Technology, Mesra//
import java.io.*;
import java.util.*;

public class maths {

    static void Blackrise() {                                                //The name Blackrise is my pen name... you can change the name according to your wish

        long n=ni();

        tsc();                                                               //calculates the starting time of execution

        int c=0,increment=0,minimizable=1;
        while(minimizable==1)
        {
            for(int i=1;i<=n;i++)
            {
                double sqrt=Math.sqrt(n*i);
                double sqrt1=(long)sqrt;
                //pl(sqrt+" "+sqrt1);
                if(sqrt==sqrt1)
                {
                    //pl(i);
                    if(i==n)
                    {
                        minimizable=0;
                        break;
                    }
                    if(i>1)
                    {
                        increment=1;
                    }
                    n=(long)Math.sqrt(n*i);c++;break;
                }
            }
        }
        if(increment==1)c++;
        pl(n+" "+c);

        tec();                  //calculates the ending time of execution
        /pwt();                //prints the time taken to execute the program
    }

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

    static Calendar ts, te;                                                  //For time calculation
    static int mod9 = (int) 1e9 + 7;
    static Lelo input = new Lelo(System.in);
    static PrintWriter pw = new PrintWriter(System.out, true);

    public static void main(String[] args) {                                 //threading has been used to increase the stack size.

        new Thread(null, null, "BlackRise", 1<<25)  //the last parameter is stack size which is desired,
        {
            public void run() {

                try {
                    Blackrise();
                } catch (Exception e) {
                    e.printStackTrace();
                    System.exit(1);
                }
            }
        }.start();
    }

    static class Lelo {                                              //Lelo class for fast input
        private InputStream ayega;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public Lelo(InputStream ayega) {
            this.ayega = ayega;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = ayega.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        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 long nextLong() {
            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 double nextDouble() {
            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 == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    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')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

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

            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

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

    // functions to take input//
    static int ni() {
        return input.nextInt();
    }

    static long nl() {
        return input.nextLong();
    }

    static double nd() {
        return input.nextDouble();
    }

    static String ns() {
        return input.readString();
    }

    //functions to give output
    static void pl() {
        pw.println();
    }

    static void p(Object o) {
        pw.print(o + " ");
    }

    static void pws(Object o){
        pw.print(o+"");
    }

    static void pl(Object o) {
        pw.println(o);
    }

    static void tsc()                                          //calculates the starting time of execution
    {
        ts = Calendar.getInstance();
        ts.setTime(new Date());
    }

    static void tec()                                          //calculates the ending time of execution
    {
        te = Calendar.getInstance();
        te.setTime(new Date());
    }

    static void pwt()                                          //prints the time taken for execution
    {
        pw.printf("\nExecution time was :- %f s\n", (te.getTimeInMillis() - ts.getTimeInMillis()) / 1000.00);
    }
}


import java.util.*;
public class dc
{
public static void main(String arg[])
   {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int op = 0, mu = 0;
      while(isAInt(n))
      {
         n = (int)Math.sqrt(n) ;
         op++;
      }

      for(int i = (int)Math.sqrt(n) ; i > 1 ; i--)
      {
         while(n %(i * i) == 0)
         {
            n = n / i ;
            mu = 1 ;
            op++ ;
         }
      }
      System.out.print(n+" "+(op+mu));

   }

}


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);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

	static class Task {
        private static final int maxl = 1000010;
        private static int prime[] = new int[maxl];
        private static int vis[] = new int[maxl];
        private int cnt = 0;
        private void getPrime(){
            for(int i=2;i<maxl;i++) {
                if(vis[i] == 0) prime[cnt++]=i;    //第cnt个质数
                for(int j=i;j<maxl;j+=i){
                    vis[j]=1;
                }
            }
        }
        public void solve(int testNumber, InputReader in, PrintWriter out) {
        	int n = in.nextInt();
        	int pn = n;
        	getPrime();
        	int count[] = new int [maxl];
        	int len = 0;
        	for(int i=0;i<cnt;i++) {
        		if(n==1) {len = i;break;}
        		while(n%prime[i]==0) {
        			count[i]++;
        			n/=prime[i];
        		}
        	}
        	int m = 0, temp=0, ans=1, res=0, hj=0;
        	if(pn!=1) {
        		int i = 0;
        		for(i=0;i<len;i++) {
        			if(count[i]%2!=0) break;
        		}
        		if(i==len) {
        			for(i=0;i<len;i++) {
            			count[i]/=2;
            		}
        			hj++;
        		}
        	}
        	for(int i=0;i<len;i++) {
        		m = Math.max(m, count[i]);
        		if(count[i]!=0) {
        			res++;
        			ans *= prime[i];
        			if(count[i]>1) temp = 1;

        		}
        	}
        	int last = hj;
        	for(int i=1;i<= 20;i++) {
        		if(m>1 && m <= Math.pow(2, i)) {
        			last+=i;break;
        		}
        	}
        	last += temp;
        	if(res == 1 && hj == 0) {
        		out.print(pn);
            	out.println(" 0");
			} else {
				out.print(ans);
				out.print(' ');
				if (m % 2 == 0) {
					out.println(last);
				} else
					out.println(last);
			}
        }
    }
	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 long nextLong() {
            return Long.parseLong(next());
        }

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

    }
}


import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;

public class Solution {

    public static void main(String[] args) throws IOException {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        if(n==1){
            System.out.println("1 0");
            continue;
        }
       HashMap<Integer,Integer> hp=new HashMap<Integer,Integer>();
        int i=2;
        while(n!=1){
            while(n%i==0){
                n=n/i;

                if(hp.containsKey(i))
                    hp.put(i,hp.get(i)+1);
                else
                    hp.put(i,1);
            }
            i++;
        }
        int vv=-1;
        boolean equal=true;
        int ans=1;
       for( Map.Entry<Integer, Integer> entry : hp.entrySet()) {
            int key = entry.getKey();
            int tab = entry.getValue();
            if(vv!=-1){
                ans=ans*key;
                    if(tab!=vv)
                        equal=false;
                     if(tab>vv)
                         vv=tab;
                }
           else{
                     vv=tab;
                     ans=ans*key;
                 }
        }
        int x=(int)Math.ceil(Math.log(vv)/Math.log(2));
        if(equal&&Math.pow(2,x)==vv)
            System.out.println(ans+" "+x);
        else
            System.out.println(ans+" "+(x+1));
    }

}


import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author uuu
 */
public class Main {
     public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        System.out.printf(n(n-1)+1);
    }
}


import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        if(n<=3){
            sum = (n-1)*n + 1;
        }
        else{
        sum = (n-1)*n + [(n-3)(n-2)]/2 + 1;
        }
        System.out.println(sum);
    }
}


import java.util.Scanner;

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

        int numButtons = scan.nextInt();

        int totalPushes = 0;
        int round = 1;

        while(numButtons > 0){

            totalPushes += round;
            round << 2;

        }

        System.out.println(totalPushes);
    }
}


package codeforces;

/**
 * Created by 3ale2 on 7/10/17.
 */
public class B268_Buttons {
    public static void main (String [] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        System.out.println(fact(n)+1);
    }

    public static int fact(int n)
    {
        int result;
        if(n==0 || n==1)
            return 1;

        result = fact(n-1) * n;
        return result;
    }
}


import java.util.*;
import java.io.*;
import java.math.*;
public class FFFFF{
    public static void main(int[] l,int[] r,int[] a) {

			int i=0,j=0,k=0;
			int nl = l.length;
			int nr = r.length;
			while(i<nl && j<nr) {
				if(l[i]<r[j]) {
					a[k] = l[i];
					i++;
				}
				else {
					a[k] = r[j];
					j++;
				}
				k++;
			}
			while(i<nl) {
				a[k] = l[i];
				i++;
				k++;
			}
			while(j<nr) {
				a[k] = r[j];
				j++;
				k++;
			}
		}

		public static void HHHH(int[] a) {
			int n = a.length;
			if(n==1) {}
			else {
				int nl = n/2;
				int nr = n-nl;
				int[] l = new int[nl];
				int[] r = new int[nr];
				for(int i=0;i<nl;i++) l[i] = a[i];
				for(int i=nl;i<n;i++) r[i-nl] = a[i];
				HHHH(l);
				HHHH(r);
				MAMA(l,r,a);
			}
		}

    public static void main(String[] args) throws IOException{
        Scanner sc = new Scanner(System.in);
        int nN = sc.nextInt();
        if(nN==2) {
            int u = sc.nextInt();
            System.out.println("0");
        }
        else{
            int[] p = new int[nN/2];
            int f=0,z=0;
            for(int i=0;i<nN/2;i++)
                p[i] = sc.nextInt();
                HHHH(p);
            for(int i=1;i<nN;i+=2){
                f += Math.abs(i-p[i/2]);
                z += Math.abs(i+1-p[i/2]);
            }
            System.out.println(Math.min(z,f));
        }
    }

}


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

public class A{
    public static void main(String[] args) throws Exception{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(f.readLine());
        StringTokenizer st = new StringTokenizer(f.readLine());
        int[] places = new int[N/2];

        for(int i = 0;i<N/2;i++){
            places[i] = Integer.parseInt(st.nextToken());
        }

        int sum1 = 0;
        for(int i = 1;i <= N/2;i++){
            sum1 += Math.abs(i*2-1 - places[i-1]);
        }

        int sum2 = 0;
        for(int i = 1;i;i<=N/2;i++){
            sum2 += Math.abs(i*2 - places[i-1]);
        }

        System.out.println(Math.min(sum1,sum2));
    }
}


//package com.company;

import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    class Task {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        void run() {
            int n = in.nextInt();

            int[] a = new int[n / 2];
            for(int i = 0; i < n / 2; ++i) {
                a[i] = in.nextInt();
            }

            int a1 = 0;
            for(int i = 0; i < n / 2; ++i) {
                a1 += Math.abs(2 * i + 1 - a[i]);
            }

            int a2 = 0;
            for(int i = 0; i < n / 2; ++i) {
                a2 += Math.abs(2 * i + 2 - a[i]);
            }

            out.write(Math.min(a1, a2));
        }
    }

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


import com.sun.xml.internal.ws.api.message.saaj.SAAJFactory;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.Buffer;
import java.util.Arrays;
import java.util.Scanner;

public class JavaApplication1 {

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

        BufferedReader sc= new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(sc.readLine().split(" ")[0]);
        int[] tab = new int[n/2];
        int x=0;
        long sum =0,sum1=0;
        String[] s= sc.readLine().split(" ");
        for (int i = 0; i < n/2; i++) {
           tab[i]=Integer.parseInt(s[i]);
            if(tab[i]%2==0){
            x++;
        }
        }
        Arrays.sort(tab);

             for (int i = 1; i <=n/2; i++) {
                 sum+=Math.abs(i*2-tab[i-1]);
             }

             for(int i=0;i<n/2;i++){
                  sum1+=Math.abs(i*2+1-tab[i]);

         }
         System.out.println(Math.min(sum1, sum));

}
}


import java.util.*;
public class Round4B {
    public static void main(String[] args) {
    Scanner s=new Scanner(System.in);
    int d=s.nextInt();
    int sum=s.nextInt();

    int[]min=new int[d];
    int[]max=new int[d];
    int a=0;
    int b=0;
    for (int i=0; i<d; i++) {
        min[i]=s.nextInt();
        max[i]=s.nextInt();
        a+=min[i];
        b+=max[i];
    }
    if (sum<a || sum>b) {
        System.out.println("NO");
    }
    else {
    sum-=a;
    int index=0;
    while (sum>0) {
        if (min[i]<max[i]) {
            min[i]++;
            sum--;
        }
        i++;
    }
    System.out.println("YES");
    System.out.print(min[0]);
    for (int i=1; i<d; i++) {
        System.out.print(" "+min[i]);
    }
    }
    }
}


import java.util.Scanner;

public class B4 {
    class day{
    	int min;
    	int max;
    	int curr;
    	boolean failed;
    	public day(int min,int max) {
    		this.min=min;
    		this.max=max;
    		this.curr=min;
    		this.failed=false;
    	}
    }
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int total=0;
		int d=sc.nextInt();
		int sumTotal=sc.nextInt();
		day days[]=new day[d];
		for(int i=0;i<d;i++)
		{
			int mintime=sc.nextInt();
			int maxTime=sc.nextInt();
			days[i]=new day(mintime,maxTime);
			total+=mintime;
		}
		int i=0;
		int notpossible=0;
//		System.out.println(total);
		while(total<sumTotal)
		{
			if(!days[i].failed && days[i].curr+1<=days[i].max)
			{
				days[i].curr++;
				total++;
			}
			else if(!days[i].failed)
			{
//				System.out.println(i);
				notpossible++;
				days[i].failed=true;
			}
			if(notpossible==d)
				break;
			if(i==d-1)
				i=0;
			else
				i++;
		}
		if(notpossible==d)
		{
			System.out.println("NO");
		}
		else
		{
			System.out.println("YES");
			for(int j=0;j<d;j++)
			{
				System.out.print(days[j].curr+" ");
			}
		}

		sc.close();
	}

}


import java.io.*;

public class HelloWorld {

    public static void main(String[] args) throws IOException {
        Scanner scn = new Scanner(System.in);
        int d = scn.nextInt();
        int[] minTime = new int[d];
        int[] maxTime = new int[d];
        int limit = scn.nextInt();
        int sumMinTime = 0;
        int sumMaxTime = 0;
        for (int i = 0; i < d; i++) {
            minTime[i] = scn.nextInt();
            maxTime[i] = scn.nextInt();
            sumMinTime += minTime[i];
            sumMaxTime += maxTime[i];
        }
        if (limit < sumMinTime || limit > sumMaxTime)
            System.out.println("NO");
        else {
            System.out.println(out, "YES");
            int i = 0;
            while (limit > sumMinTime) {
                if (limit - sumMinTime > (maxTime[i] - minTime[i])) {
                    sumMinTime += maxTime[i] - minTime[i];
                    minTime[i] = maxTime[i];
                    i++;
                } else {
                    minTime[i] = limit - sumMinTime;
                    break;
                }
            }
            for(int val : minTime)
                System.out.print(val + " ");
        }
    }

}


    import java.util.*;

    public class Exam {

        private static class Range {
            public int min;
            public int max;

            public Range(int min, int max) {
                this.min = min;
                this.max = max;
            }
        }

        public static void main(String[] args) {
            Scanner s = new Scanner(System.in);
            int days = s.nextInt();
            int time = s.nextInt();

            int[] times = new int[days];
            Range[] ranges = new Range[days];

            int smins = 0;
            int smaxs = 0;

            for(int i = 0; i < days; i++) {
                ranges[i] = new Range(s.nextInt(), s.nextInt());
                smins += ranges[i].min;
                smaxs += ranges[i].max;
            }

            if(!(smins <= time && time <= smaxs)) {
                System.out.println("NO");
                return;
            }
            int diff = time - smins;

            System.out.println("YES");
            for(int i = 0; i < days; i++) {
                int diffToday = times[i].max - times[i].min;

                if(diff > 0) {
                    if(diff > diffToday) {
                        diff -= diffToday;
                        System.out.print(times[i].max + " ");
                    }
                    else {
                        System.out.println((times[i].min + diff) + " ");
                        diff = 0;
                    }
                }
                else {
                    System.out.print(times[i].min + " ");
                }
            }
        }

    }


import java.util.*;
import java.lang.*;

public class Solution{

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] log = new int[n];
        int index = 0;
        boolean flag = true;
        for(int i=0;i<n;i++){
            log[i] = scan.nextInt();
        }
        for(int i=0;i<n;i++){
            if(log[0]==3) flag=false; break;
            if((log[1]==2&&log[0]==1)||(log[1]==1&&log[0]==2)){flag=false;}
            if(i+1<n&&i-1>0){
                if(log[i+1]==log[i-1]&&log[i+1]!=log[i]&&log[i-1]!=log[i]){flag=false;}
            }
        }
        if(flag) System.out.println("YES");
        else{System.out.println("NO");}
    }
}


//package testpackage;

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

	public class Test {

		@Override
		public int hashCode() {
			return 1;
		}

		/*@Override
		public boolean equals(Object arg0) {
			return false;
		}
	*/
		private static int gcd(int a, int b) {
		    int t;
		    while(b != 0){
		        t = a;
		        a = b;
		        b = t%b;
		    }
		    return a;
		}

		private static boolean isrelprime(int a, int b){
			return gcd(a,b) == 1;
		}
		public static void main(String[] args) throws Exception {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int a[] = new int[n];
			for(int i=0;i<n;i++){
				a[i] = sc.nextInt();
			}
			int s = 1;
			int ss=2;
			int l = 3;

			for(int i=0;i<n;i++){
				if((a[i]==s)){
					int t= l;
					l = ss;
					ss = t;
				}else if(a[i] == ss){
					int t= l;
					l = s;
					ss = t;
				}
				else{
					System.out.println("NO");
					System.exit(0);
				}
			}
			System.out.println("YES");
		}


public class Main{
    public static void main(String [] args){
        try(Scanner sc = new Scanner(System.in)){
            int n = sc.nextInt();

            int cp1 = 1, cp2 = 2, cs = 3;
            for(int i=0;i<n;i++){
                int w = sc.nextInt();
                if(w != cp1 && w!=cp2) {
                    System.out.println("NO");
                    return;
                }

                cp1 = w;
                cp2 = cs;
                cs = 6 - (cp1 + cp2);
            }

            System.out.println("YES");
        }
    }
}


import java.util.*;

public class x{

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

               int n=sc.nextInt();

               while(n-->0){
                       int t=sc.nextInt();
                       int f=1,s=2,lt=3;

                       if(t==lt){
                               System.out.println("NO");
                               return ;
                       }
                       else if(t==f){
                               swap(s,lt);
                       }
                       else if(t==s){
                               swap(f,lt);
                       }
               }

               System.out.println("YES");
       }

       public static swap(int a,int b){
               int te=a;
               a=b;
               b=te;
       }
}


import java.util.Scanner;
public class ForgettingThings {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] inputs = sc.nextLine().split(" ");
		int i, j;
		if(inputs[0].equals("9") && inputs[1].equals("1")) {
			System.out.println(99 + " " + 100);
			System.exit(0);
		}
		for(i = 0; i < 10; i++) {
			for(j = 0; j < 10; j++) {
				if(Integer.parseInt(inputs[0] + Integer.toString(j)) + 1 == Integer.parseInt(inputs[1] + Integer.toString(i))) {
					System.out.println((inputs[0] + Integer.toString(j)) + " " + (inputs[1] + Integer.toString(i)));
					System.exit(0);
				}
			}
		}
		System.out.println(-1);
		sc.close();
	}


import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {

        Scanner sc=new Scanner(System.in);
        long a=sc.nextInt();
        long b=sc.nextInt();
        if(!(b-a==1||a-b==0)){System.out.println("-1");}
        else{
            if(a==b){
                a=a*10+;
                b=b*10+1;
                System.out.println(a+" "+b);
            }else{
            a=a*10+9;
            b=b*10;

            System.out.println(a+" "+b);}

        }

	}
}


// package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class AT1 {
    public static void main(String[] Args){
        FastReader scan=new FastReader();
        int l=scan.nextInt();
        int r=scan.nextInt();
        int flag=0;
        for(int i=0;i<=9;i++){
            int tl=l;
            tl*=10;
            tl+=i;
            for(int j=0;j<=9;j++){
                int tr=r;
                tr*=10;
                tr+=j;
                if(tl+1==tr){
                    System.out.println(tl+" "+tr);
                    flag=1;
                    break;
                }
            }
            if(flag==1){
                break;
            }
        }
        if(flag==0){
            System.out.println(-1);
        }
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

}


import java.util.*;

public class sdsdds{
    public static void main(String asdasda[]){
        Scanner s=new Scanner(System.in);
        int a=s.nextInt();
        int b=s.nextInt();
        if(b==a){
            System.out.print(a+"1 "+b+"2");

        }
        else if(b==a+1)
            System.out.print(a+"9 "+b+"0");
        else
             System.out.print("-1");
        }
    }
}


import java.util.Scanner;

public class GigaTower {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        long a = scan.nextLong(), c = 0;
        while(!(""+a).contains("8"){
            c++;
            a++;
        }
        System.out.println(c);
    }
}


import java.util.Scanner;

public class main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner input=new Scanner(System.in);
        int count=0,temp;
        String n;
        n=input.nextLine();
        int charCount = 0;
        for( int i = 0; i <n.length( ); i++ )
        {

            if( n.charAt(i)=='8')
                charCount++;
        }
        if(charCount>1)
        {
            n=n.replaceFirst("8","9");
            count++;
        }
        else if(charCount==1&&n.charAt(n.length()-1)=='8')
        {
               n=n.replaceFirst("8","9");
               count++;
        }
        else if(charCount==1)
        {
            count=1;
        }

        while(!n.contains("8"))
        {
            count++;
            temp=Integer.parseInt(n);
            temp++;
            n=""+temp;

        }
        System.out.println(count);

    }


public class problem1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long guess=-1;
        guess=in.nextLong();
        int j=0;
        while(true){
            j++;
            guess++;
        String temp = new String();
                temp=Long.toString(guess);
        int[] newGuess = new int[temp.length()];
            boolean ok=false;
        for (int i = 0; i < temp.length(); i++)
        {
            newGuess[i] = temp.charAt(i) - '0';
               if(newGuess[i]==8&&j!=0){
                      ok=true;
                  break;
               }
        }

            if(ok){
                break;
            }
        }
        System.out.println(j);
    }
}


import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;

import static java.lang.Math.*;

public class C_4 {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        long a = in.nextInt(), b = in.nextInt();
        ArrayDeque<Long> deque = new ArrayDeque<>();
        long d = abs(a - b);
        long sq = (long) sqrt(d);
        for (long i = 1; i <= sq; i++) {
            if (d % i == 0) {
                deque.addLast(i);
                deque.addLast(d / i);
            }
        }

        long min = lcm(a, b), k = 0;
        for (long i : deque) {
            long p = i - min(a, b) % i;
            long l = lcm(a + p, b + p);
            if (l < min) {
                min = l;
                k = p;
            } else if (l == min) {
                k = min(k, p);
            }
        }

        pw.println(k);

        pw.close();
    }

    static long gcd(long p, long q) {
        if (q == 0) return p;
        else return gcd(q, p % q);
    }

    static long lcm(long p, long q) {
        long g = gcd(p, q);
        p /= g;
        return p * q;
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}


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

public class A implements Runnable {
	FastReader scn;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		int n = scn.nextInt();
		int[] arr = {1, 3, 9, 27, 84, 270, 892, 3012};
		out.println(arr[--n]);
	}

	public void run() {
		long time = System.currentTimeMillis();
		boolean oj = System.getProperty("ONLINE_JUDGE") != null;
		out = new PrintWriter(System.out);
		scn = new FastReader(oj);
		solve();
		out.flush();
		if (!oj) {
			System.out.println(Arrays.deepToString(new Object[] { System.currentTimeMillis() - time + " ms" }));
		}
	}

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

	class FastReader {
		InputStream is;

		public FastReader(boolean onlineJudge) {
			is = onlineJudge ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		}

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

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

		boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

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

		char nextChar() {
			return (char) skip();
		}

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

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

		char[] next(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);
		}

		int nextInt() {
			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();
			}
		}

		long nextLong() {
			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();
			}
		}

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

		int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		int[][] next2DInt(int n, int m) {
			int[][] arr = new int[n][];
			for (int i = 0; i < n; i++) {
				arr[i] = nextIntArray(m);
			}
			return arr;
		}

		long[][] next2DLong(int n, int m) {
			long[][] arr = new long[n][];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLongArray(m);
			}
			return arr;
		}

		int[] shuffle(int[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				int c = arr[i];
				arr[i] = arr[j];
				arr[j] = c;
			}
			return arr;
		}

		long[] shuffle(long[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				long c = arr[i];
				arr[i] = arr[j];
				arr[j] = c;
			}
			return arr;
		}

		int[] uniq(int[] arr) {
			Arrays.sort(arr);
			int[] rv = new int[arr.length];
			int pos = 0;
			rv[pos++] = arr[0];
			for (int i = 1; i < arr.length; i++) {
				if (arr[i] != arr[i - 1]) {
					rv[pos++] = arr[i];
				}
			}
			return Arrays.copyOf(rv, pos);
		}

		long[] uniq(long[] arr) {
			Arrays.sort(arr);
			long[] rv = new long[arr.length];
			int pos = 0;
			rv[pos++] = arr[0];
			for (int i = 1; i < arr.length; i++) {
				if (arr[i] != arr[i - 1]) {
					rv[pos++] = arr[i];
				}
			}
			return Arrays.copyOf(rv, pos);
		}

		int[] reverse(int[] arr) {
			int l = 0, r = arr.length - 1;
			while (l < r) {
				arr[l] = arr[l] ^ arr[r];
				arr[r] = arr[l] ^ arr[r];
				arr[l] = arr[l] ^ arr[r];
				l++;
				r--;
			}
			return arr;
		}

		long[] reverse(long[] arr) {
			int l = 0, r = arr.length - 1;
			while (l < r) {
				arr[l] = arr[l] ^ arr[r];
				arr[r] = arr[l] ^ arr[r];
				arr[l] = arr[l] ^ arr[r];
				l++;
				r--;
			}
			return arr;
		}
	}
}


import java.util.Scanner;

public class P1152D {

	static int n;
	static int MOD = (int)1e9+7;
	static long[][][] dp1 = new long[1001][1001][2];
	static int[][] dp2 = new int[1001][1001];

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		n = in.nextInt();
		for(int i=0; i<1001; i++) {
			for(int j=0; j<1001; j++) {
				dp2[i][j]=-1;
				for(int k=0; k<2; k++) {
					dp1[i][j][k]=-1;
				}
			}
		}
		System.out.println(solve(0, 0, 0));
	}

	public static long solve(int i, int unMatched, int last) {
		if (i==2*n) {
			return 0;
		}
		if (dp1[i][unMatched][last]!=-1) return dp1[i][unMatched][last];
		long ans=0;
		long s1, s2, s3, s4;
		s1=s2=s3=s4=0;
		if (possible(i+1, unMatched+1)==1) {
			s1 = solve(i+1, unMatched+1, 0);
			s2 = solve(i+1, unMatched+1, 1)+1;
		}
		if (possible(i+1, unMatched-1)==1){
			s3 = solve(i+1, unMatched-1, 0);
			s4 = solve(i+1, unMatched-1, 1)+1;
		}

		if (last==1) {
			ans = Math.max(ans, (s1+s3)%MOD);
		} else {
			ans = Math.max(ans, (s1+s3)%MOD);
			ans = Math.max(ans, (s1+s4)%MOD);
			ans = Math.max(ans, (s3+s2)%MOD);
		}

		return dp1[i][unMatched][last]=ans;
	}

	public static int possible(int i, int unMatched) {
		if (unMatched<0) return 0;
		if (i==2*n) {
			if (unMatched==0) {
				return 1;
			} else {
				return 0;
			}
		}

		if (dp2[i][unMatched]!=-1) return dp2[i][unMatched];

		int p = possible(i+1, unMatched+1)+possible(i+1, unMatched-1);
		return dp2[i][unMatched]=(p>0?1:0);
	}

}


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

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Andy Phan (Edited for speedups by AuroraGarden)
 */
public class p1152d {
    static long[][][] dp;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        dp = new long[2][2*n+1][2*n+1];
        for(long a[][]:dp)
        	for(long b[]:a)
        		Arrays.fill(b, -1);
        System.out.println(traverse(2*n, 0, 0)%1_000_000_007);
    }

    public static long traverse(int ind, int diff, int flag) {
        if(ind <= 0 || diff < 0) return 0;
        if(dp[flag][diff][ind] != -1) return dp[flag][diff][ind];
        long num = 0;
        if(flag == 1) {
            if(hasVal(ind-1, diff-1)) num += traverse(ind-1, diff-1, 0);
            if(hasVal(ind-1, diff+1)) num += traverse(ind-1, diff+1, 0);
            if(num >= 1_000_000_007) num -= 1_000_000_007;
            return dp[ind][diff][flag] = num;
        }
        if(hasVal(ind-1, diff-1)) {
            long tmp = traverse(ind-1, diff-1, 1)+1;
            if(hasVal(ind-1, diff+1)) tmp += traverse(ind-1, diff+1, 0);
            num = max(num, tmp);
        }
        if(hasVal(ind-1, diff+1)) {
            long tmp = traverse(ind-1, diff+1, 1)+1;
            if(hasVal(ind-1, diff-1)) tmp += traverse(ind-1, diff-1, 0);
            num = max(num, tmp);
        }
        if(num >= 1_000_000_007) num -= 1_000_000_007;
        return dp[flag][diff][ind] = num;
    }
    static long max(long a, long b) {return a > b ? a : b;}

    public static boolean hasVal(int ind, int diff) {
        if(diff < 0) return false;
        return diff <= ind;
    }
}


import java.util.Scanner;

/**
 *
 * 作者：张宇翔
 * 创建日期：2017年7月16日 下午11:04:25
 * 描述：
 */
public class Main {

	private static final int Max = (int) (1e2 + 10);
	private static String []s;
	private static char [][]a;
	public static void main(String[] args) {
		InitData();
		GetAns();
	}
	private static void InitData() {
		Scanner cin = new Scanner(System.in);
		s=new String[Max];
		a=new char[Max][Max];
		for(int i=0;i<10;i++){
			s[i]=cin.next();
			a[i]=s[i].toCharArray();
		}
	};

	private static void GetAns() {
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				if(a[i][j]=='.'){
					a[i][j]='X';
					if(judge()){
						System.out.println("YES");
						return;
					}
					a[i][j]='.';
				}
			}
		}
		System.out.println("NO");
		return;
	};

	private static boolean judge(){
		for(int i=0;i<10;i++){//判断横
			for(int j=0;j<=10-5;j++){
				if(a[i][j]=='X'&&a[i][j+1]=='X'&&a[i][j+2]=='X'
						&&a[i][j+3]=='X'&&a[i][j+4]=='X'){
					return true;
				}
			}
		}
		for(int i=0;i<10;i++){//判断竖
			for(int j=0;j<=10-5;j++){
				if(a[j][i]=='X'&&a[j+1][i]=='X'&&a[j+2][i]=='X'
						&&a[j+3][i]=='X'&&a[j+4][i]=='X'){
					return true;
				}
			}
		}

		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				int cnt=0;
				if(Check(i, j)){
					if(a[i][j]=='X'){
						cnt++;
					}
				}
				if(Check(i+1, j+1)){
					if(a[i+1][j+1]=='X'){
						cnt++;
					}
				}
				if(Check(i+2, j+2)){
					if(a[i+2][j+2]=='X'){
						cnt++;
					}
				}
				if(Check(i+3, j+3)){
					if(a[i+3][j+3]=='X'){
						cnt++;
					}
				}
				if(Check(i+4, j+4)){
					if(a[i+4][j+4]=='X'){
						cnt++;
					}
				}
				if(cnt==5){
					return true;
				}
			}
		}

		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				int cnt=0;
				if(Check(i, j)){
					if(a[i][j]=='X'){
						cnt++;
					}
				}
				if(Check(i-1, j-1)){
					if(a[i-1][j-1]=='X'){
						cnt++;
					}
				}
				if(Check(i-2, j-2)){
					if(a[i-2][j-2]=='X'){
						cnt++;
					}
				}
				if(Check(i-3, j-3)){
					if(a[i-3][j-3]=='X'){
						cnt++;
					}
				}
				if(Check(i-4, j-4)){
					if(a[i-4][j-4]=='X'){
						cnt++;
					}
				}
				if(cnt==5){
					return true;
				}
			}
		}
		return false;
	}

	private static boolean Check(int x,int y){
		if(x>=0&&x<10&&y>=0&&y<10){
			return true;
		}
		return false;
	}

}


/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class TaskB {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    int n = 10;
    char[][] board = new char[n][n];
    for (int i=0; i<n; i++) {
      board[i] = br.readLine().toCharArray();
    }
    boolean poss = false;
    for (int i=0; i<n; i++) {
      for (int j=0; j<n-5; j++) {
        int nO = 0;
        int nX = 0;
        int nD = 0;
        for (int k=0; k<5; k++) {
          if (board[i][j+k]=='O') {
            nO++;
          } else if (board[i][j+k]=='X')
            nX++;
          else
            nD++;

        }
        if (nX==4 && nD==1)
          poss = true;
      }
    }
    for (int i=0; i<n-5; i++) {
      for (int j=0; j<n; j++) {
        int nO = 0;
        int nX = 0;
        int nD = 0;
        for (int k=0; k<5; k++) {
          if (board[i+k][j]=='O') {
            nO++;
          } else if (board[i+k][j]=='X')
            nX++;
          else
            nD++;
        }
        if (nX==4 && nD==1)
          poss = true;
      }
    }
    for (int i=0; i<n-5; i++) {
      for (int j=0; j<n-5; j++) {
        int nO = 0;
        int nX = 0;
        int nD = 0;
        for (int k=0; k<5; k++) {
          if (board[i+k][j+k]=='O') {
            nO++;
          } else if (board[i+k][j+k]=='X')
            nX++;
          else
            nD++;
        }
        if (nX==4 && nD==1)
          poss = true;
      }
    }
    if (poss)
      System.out.println("YES");
    else
      System.out.println("NO");
  }
}


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

public class Main {

    public static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) throws Exception {
        //int n = scan.nextInt();
        char[][] c = new char[10][10];
        for (int i = 0; i < 10; i++) {
            c[i] = scan.next().toCharArray();
        }
        for (int i = 0; i < 10; i++) {

            for (int j = 0; j < 10; j++) {
                int dem1 = 0, dem2 = 0, dem3 = 0;
                try {
                    for (int k = 0; k < 5; k++) {
                        if (c[i][j + k] == 'X') {
                            dem1++;
                        } else if (c[i][j + k] == 'O') {
                            dem1--;
                        }
                        if (c[i + k][j] == 'X') {
                            dem2++;
                        } else if (c[i + k][j] == 'O') {
                            dem2--;
                        }
                        if (c[i + k][j + k] == 'X') {
                            dem3++;
                        } else if (c[i + k][j + k] == 'O') {
                            dem3--;
                        }
                    }
                    if (dem1 == 4 || dem2 == 4 || dem3 == 4) {
                        System.out.println("YES");
                        return;
                    }

                } catch (Exception e) {

                }
            }
        }
        System.out.println("NO");
    }

}


import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class ThirdTask {
    private Scanner sc;
    private static String alisa = "X";
    private static String dot = ".";
    private static String bob = "O";

    private ArrayList<String[]> matrix = new ArrayList<>();

    public void setMatrix(ArrayList<String[]> matrix){
        this.matrix.clear();
        this.matrix.addAll(matrix);
    }

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

        createMatrix(0);

        if(runTheSearch()){
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }

    }

    public boolean runTheSearch(){
        boolean hasWinningMove=false;

        //search in row
        for(String[] row : matrix){
            hasWinningMove = search(row);
        }

        //search in column
        for (int i=0; i<matrix.size();i++){
            String[] combinedArray = new String[matrix.size()];
            for (int j=0; j<matrix.size();j++){
                combinedArray[j]= matrix.get(j)[i];
            }
            hasWinningMove = search(combinedArray);
        }

        //search in diagonals
        for(int k =0; k< matrix.size(); k++){
            System.out.println("");
            String[] row = matrix.get(k);
            if(k+5<=matrix.size()){
                for (int i=0; i<row.length;i++){
                    if(i+5<=row.length){
                        String[] combinedArray = new String[5];
                        for (int j=0; j<5;j++){
                            int columnIndex = j+i;
                            if(columnIndex<row.length){
                                String str =  matrix.get(j+k)[columnIndex];
                                combinedArray[j] = str;
                            }else {
                                break;
                            }
                        }
                        hasWinningMove = searchInDiagonals(combinedArray);
                        if(hasWinningMove){break;}
                    }
                }
                for (int i=row.length-1; i>=0;i--){
                    if(i-4>=0){
                        String[] combinedArray = new String[5];
                        for (int j=0; j<5;j++){
                            int columnIndex = i-j;
                            if(columnIndex<row.length){
                                String str =  matrix.get(j+k)[columnIndex];
                                combinedArray[j] = str;
                            }else {
                                break;
                            }
                        }
                        hasWinningMove = searchInDiagonals(combinedArray);
                        if(hasWinningMove){break;}
                    }
                }
            }
        }

        return hasWinningMove;

    }

    private void createMatrix(int index){
        if(index<10){
            System.out.printf("Введите %d ряд: ", index);
            String[] row = sc.next().split("");
            if(row.length<10 || row.length>10){
                System.out.printf("Ряд должен содержать 10 элементов. ");
                createMatrix(index);
            }else {
                matrix.add(row);
                createMatrix(++index);
            }
        }
    }
    private static ArrayList<Map<String,Integer>> rows = new ArrayList<>();
    private static boolean search(String[] row){
        int rowLength = row.length;
        for(int i=0; i<rowLength; i++){
            Map<String, Integer> map = new HashMap<>();
            int itemsCount=i;
            if(i<6){
                while (itemsCount<5+i){
                    if(map.containsKey(row[itemsCount])){
                        map.put(row[itemsCount],map.get(row[itemsCount])+1);
                    }else {
                        map.put(row[itemsCount],1);
                    }
                    itemsCount++;
                }
                rows.add(map);
            }
        }

        /*for( Map<String, Integer> mapItem : rows){
            System.out.println(mapItem);
        }*/

        for( Map<String, Integer> mapItem : rows){
            if(mapItem.get(alisa)!=null && mapItem.get(alisa)==4){
                if(mapItem.get(dot)!=null && mapItem.get(dot)==1){
                    return true;
                }
            }
        }

        return false;
    }
    private static boolean searchInDiagonals(String[] row){
        int rowLength = row.length;
        Map<String, Integer> map = new HashMap<>();
        for(int i=0; i<rowLength; i++){
            if(map.containsKey(row[i])){
                map.put(row[i],map.get(row[i])+1);
            }else {
                map.put(row[i],1);
            }
        }

        if(map.get(alisa)!=null && map.get(alisa)==4){
            if(map.get(dot)!=null && map.get(dot)==1){
                return true;
            }
        }

        return false;
    }

}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
    public static void main(String[] argv) {
        MainRun mainSolve = new MainRun();
        mainSolve.run(0, 0);
    }
}

class Task {
	TreeSet <Long> st;
	long getNum(int mass[]) {
		long res = 0;
		for (int i = 1; i < 12; i++) {
			if (mass[i] == 0)
				break;
			res = res * 10L + mass[i];
		}
		return res;
	}
	void rec(int pos, int mass[]) {
		if (pos > 11) {
			st.add(getNum(mass));
			return;
		}
		mass[pos] = 0;
		rec(pos + 1, mass);
		mass[pos] = 4;
		rec(pos + 1, mass);
		mass[pos] = 0;
		mass[pos] = 7;
		rec(pos + 1, mass);
		mass[pos] = 0;
	}7
	public void solve(InputReader in, PrintWriter out) {
		int n = in.nextInt();
		int len = 0;
		int temp = n;
		while (temp != 0) {
			len++;
			temp /= 10;
		}
		int dl[] = new int[14];
		st = new TreeSet<Long>();
		rec(1, dl);

		int num = 1;
		Iterator it = st.iterator();
		while (it.hasNext()) {
			long value = (long)it.next();
			if (value == n) {
				out.println(num);
				return;
			}
			num++;
		}
	}
}

class MainRun {
	void run(int inF, int outF) {
//		inF = outF = 0;
		String input = "input.txt";
//		String input = "large.in";
		String output = "output.txt";
//		String output = "puzzle-2048.out";
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in;
		PrintWriter out;
		if (inF == 1)
			in = new InputReader(input);
		else
			in = new InputReader(inputStream);
		if (outF == 1)
			out = getPrintWriter(output);
		else
			out = getPrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(in, out);
		out.close();
	}
	public static PrintWriter getPrintWriter(OutputStream stream) {
		return new PrintWriter(stream);
	}
	public static PrintWriter getPrintWriter(String f) {
		try {
			return new PrintWriter(new File(f));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		return null;
	}
}

class InputReader {
	BufferedReader reader;
	StringTokenizer tokenizer;
	InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream));
		tokenizer = null;
	}
	InputReader(String f) {
		try {
			reader = new BufferedReader(new FileReader(f));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		tokenizer = null;
	}
	public String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch(IOException e) {
				throw new RuntimeException(e);
			} catch(NullPointerException e) {
				return "";
			}
		}
		return tokenizer.nextToken();
	}
	public String getLine() {
		try {
			return (String)reader.readLine();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "";
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public char nextChar() {
		return next().charAt(0);
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
	public int[] nextIntArray(int n) {
		int a[] = new int[n + 2];
		for (int i = 1; i <= n; i++)
			a[i] = nextInt();
		return a;
	}
}


import java.util.*;
public class M{
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        String st = s.next();
        int n = s.length();
    	int ans = 1<<n - 2;
    	for(int i = s.length()-1,pos = 0; i>= 0 ; i--,pos++){
    		if(s.charAt(i) == '7'){
    			ans += 1<<pos;
    		}
    	}
    	System.out.println(ans+1);
    }
}


/* package whatever; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */

public class question2
{
    private int num=0;

    public int find_rank()
    {
        int len=find_length();

        if(len==1)
        {
            if(num==4)
                return 1;
            else
                return 2;
        }

        int low=(int)(Math.pow((double)2,(double)len)-1);
        int high=low*2;

        int temp=num;

        while(len>0)
        {
            int x=(int)(Math.pow((double)10,(double)len-1));

            if(temp/x==4)
            {
                high=(low+high)/2;

            }
            else
            {
                low=(low+high)/2+1;

            }
            len--;
            temp=temp%x;
            x=x/10;

        }
        return low;
    }

    public int find_length()
    {
        int temp=num;
        int len=0;
        while(temp>0)
        {
            temp=temp/10;
            len++;
        }

        return len;
    }

    public void set_num(int a)
    {
        num=a;
    }

}
 public class Ideone
{
    public static void main (String[] args) throws java.lang.Exception
    {
        int num;

        Scanner in=new Scanner(System.in);
        num=in.nextInt();

        question2 obj1=new question2();
        obj1.set_num(num);
        System.out.println(obj1.find_rank());

    }
}


public class Test5 {
uto-generated method stub

    }

}


import java.util.Scanner;
public class SantaClauseAndAPlaceInClass {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int k = scanner.nextInt();
        int counter = 2;
        char l = 'L';
        char r = 'R';
        int[][] workingPlaces = new int[n][m];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                workingPlaces[i][j] =  counter;
                counter += 2;
            }
        }
        for(int i =0; i < n; i++){
            for(int j = 0; j < m; j++){
                if((k - workingPlaces[i][j]) == 0 || (k - workingPlaces[i][j] == -1)){
                    if(k % 2 == 0){
                        System.out.println((i + 1) + " " + (j + 1)+" " + r);
                    }else{
                        System.out.println((i + 1) + " " + (j + 1)+" " + l);
                    }
                }
            }


import java.io.*;
import java.util.*;
public class A{
    public static void main(String[] args) throws Exception{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in);

        StringTokenizer st = new StringTokenizer st(f.readLine());

        double l = Double.parseDouble(f.readLine());
        double d = Double.parseDouble(f.readLine());
        double n = Double.parseDouble(f.readLine());

        System.out.println(Math.ceil(n/2d) + " " +  (n%(2d)) == 0?d: (Math.ceil((n%(2d))/2)) + " " + (n%2 == 0)?R:L);
    }
}


import java.io.*;
import java.util.*;
public class A{
    public static void main(String[] args){
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in);

        StringTokenizer st = new StringTokenizer st(f.readLine());

        double l = Double.parseDouble(f.readLine());
        double d = Double.parseDouble(f.readLine());
        double n = Double.parseDouble(f.readLine());

        System.out.println(Math.ceil(n/2d) + " " +  (n%(2d)) == 0?d: (Math.ceil((n%(2d))/2)) + " " + (n%2 == 0)?R:L);
    }
}


import java.io.*;
import java.util.*;
public class A{
    public static void main(String[] args) throws Exception{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));

        StringTokenizer st = new StringTokenizer st(f.readLine());

        double l = Double.parseDouble(st.nextToken());
        double d = Double.parseDouble(st.nextToken());
        double n = Double.parseDouble(st.nextToken());

        System.out.println((int)(Math.ceil(n/2/d)) + " " +  (int)((n%(2*d)) == 0?d:(Math.ceil((n%(2*d))/2))) + " " + ((n%2 == 0)?R:L));
    }
}


public class ADimaandFriends {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt(), sum = 0 , count = 0 ;
		int[] x = new int[n];

		for (int i = 0; i < n; i++) {
			sum = sum + scan.nextInt();
		}
		for (int i = 1; i <= 5; i++) {
			if(sum+i % n+1  == 0){
				count ++;
			}

		}
		System.out.println(count);
			scan.close();
		}

	}


import java.io.OutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.math.BigDecimal;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;

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

class TaskA {
    public void solve(int testNumber, Input in, Output out)
    {
        int n = in.nextInt();
        int k = in.nextInt();
        for (int i = 1; i < n; i++) k += in.nextInt();
        int total = k+5;
        n++;
        int ways = 0;
        while (++k <= total)
            if (k % n != 1)
                ways++;
        out.println(ways);
    }
}

class Input
{
    final int SIZE = 8192;
    private InputStream in;
    private byte[] buf = new byte[SIZE];
    private int last, current, total;

    public Input(InputStream stream) throws IOException
    {
        in = stream;
        last = read();
    }

    int read()
    {
        if (total == -1) return -1;
        if (current >= total)
        {
            current = 0;
            try
            {
                total = in.read(buf);
            } catch (IOException e)
            {
                e.printStackTrace();
            }
            if (total <= 0) return -1;
        }
        return buf[current++];
    }

    void advance()
    {
        while (true)
        {
            if (last == -1) return;
            if (!isValidChar(last)) last = read();
            else break;
        }
    }

    boolean isValidChar(int c)
    {
        return c > 32 && c < 127;
    }

    public boolean eof()
    {
        advance();
        return last == -1;
    }

    public String nextString()
    {
        advance();
        if (last == -1) return null;
        StringBuilder s = new StringBuilder();
        while (true)
        {
            s.appendCodePoint(last);
            last = read();
            if (!isValidChar(last)) break;
        }
        return s.toString();
    }

    String nextLine()
    {
        if (last == -1) return null;
        StringBuilder s = new StringBuilder();
        while (true)
        {
            s.appendCodePoint(last);
            last = read();
            if (last == '\n' || last == -1) break;
        }
        return s.toString();
    }

    public String nextLine(boolean ignoreIfEmpty)
    {
        if (!ignoreIfEmpty) return nextLine();
        String s = nextLine();
        while (s.trim().length() == 0) s = nextLine();
        return s;
    }

    public int nextInt()
    {
        advance();
        int n = 0, s = 1;
        if (last == '-')
        {
            s = -1;
            last = read();
        }
        while (true)
        {
            n = n * 10 + last - '0';
            last = read();
            if (!isValidChar(last)) break;
        }
        return n * s;
    }

    public long nextLong()
    {
        advance();
        int s = 1;
        if (last == '-')
        {
            s = -1;
            last = read();
        }
        long n = 0;
        while (true)
        {
            n = n * 10 + last - '0';
            last = read();
            if (!isValidChar(last)) break;
        }
        return n * s;
    }

    public BigInteger nextBigInt()
    {
        return new BigInteger(nextString());
    }

    public char nextChar()
    {
        advance();
        return (char) last;
    }

    public double nextDouble()
    {
        advance();
        int s = 1;
        if (last == '-')
        {
            s = -1;
            last = read();
        }
        double n = 0;
        while (true)
        {
            n = n * 10 + last - '0';
            last = read();
            if (!isValidChar(last) || last == '.') break;
        }
        if (last == '.')
        {
            last = read();
            double m = 1;
            while (true)
            {
                m = m / 10;
                n = n + (last - '0') * m;
                last = read();
                if (!isValidChar(last)) break;
            }
        }
        return n * s;
    }

    public BigDecimal nextBigDecimal()
    {
        return new BigDecimal(nextString());
    }

    public void close()
    {
        try
        {
            in.close();
        } catch (IOException e)
        {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
        in = null;
    }
}

class Output
{
    final int SIZE = 8192;
    private Writer out;
    private char cb[] = new char[SIZE];
    private int nChars = SIZE, nextChar = 0;
    private char lineSeparator = '\n';

    public Output(OutputStream stream)
    {
        out = new OutputStreamWriter(stream);
    }

    public Output(Writer writer)
    {
        out = writer;
    }

    void flushBuffer()
    {
        if (nextChar == 0) return;
        try
        {
            out.write(cb, 0, nextChar);
        } catch (IOException e)
        {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
        nextChar = 0;
    }

    void write(int c)
    {
        if (nextChar >= nChars) flushBuffer();
        cb[nextChar++] = (char) c;
    }

    void write(String s, int off, int len)
    {
        int b = off, t = off + len;
        while (b < t)
        {
            int a = nChars - nextChar, a1 = t - b;

            int d = a < a1 ? a : a1;
            s.getChars(b, b + d, cb, nextChar);
            b += d;
            nextChar += d;
            if (nextChar >= nChars) flushBuffer();
        }
    }

    void write(String s)
    {
        try
        {
            out.write(s);
        } catch (IOException e)
        {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
    }

    public void print(Object obj)
    {
        write(String.valueOf(obj));
    }

    public void println(Object obj)
    {
        write(String.valueOf(obj));
        write(lineSeparator);
    }

    public void printf(String format, Object... obj)
    {
        write(String.format(format, obj));
    }

    public void close()
    {
        flushBuffer();
        try
        {
            out.flush();
            out.close();
        } catch (IOException e)
        {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
    }
}


public class Proba {
    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        for (int i = 0; i < n; i++) {
            ans += sc.nextInt();
        }
        if (ans%(n+1) == 1){
            System.out.println("1");return;
        }
        System.out.println(2);
    }
}


import java.uitl.*;
public class Main{
    public static void main(String[] args){
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        int count=0;
        for(int i=0;i<n;i++) count+=s.nextInt();
        int ans=0;
        for(int i=1;i<=5;i++){
            if((count+i)%(n+1)==0) continue;
            ans++;
        }
        System.out.println(ans);
    }
}


import java.util.Scanner;

public class luckyNumber {

	public static void main(String[] args) {
		Scanner obj = new Scanner(System.in);
		int n = obj.nextInt();

		long ans = 0;
		for (int i = 1; i <= n; i++) {
			ans = (long) ans + (Math.pow(2, i));
		}

		System.out.println(ans);

	}

}


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

public class os {

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int n = in.nextInt()+1;
    long re = (long) Math.pow(2,n)
    System.out.println(re-2);
}
}


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

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int x = Integer.parseInt(""+st.nextToken());
		PrintWriter out = new PrintWriter(System.out);
		long res = (1L<<(x+1)) -2;

			res += 1<<i;

		out.println(res);

		out.flush();
		out.close();
	}

}


import java.util.Scanner;

public class nopa {

	public static void main(String[] args) {
		Scanner sc=  new Scanner (System.in);
		int n =sc.nextInt();
		int c=0;
		long k=1;

		for(int i=1;i<=n;i++){
			k=k*2;
			c=c+k;
		}
			System.out.println(c);
	}

}


import java.util.Scanner;
public class Codeforces {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner s=new Scanner(System.in);
int n=s.nextInt(); int m=s.nextInt();
int a1[]=new int[n];int a2[]=new int[m];
for(int i=0;i<n;i++)
	a1[i]=s.nextInt();
for(int i=0;i<m;i++)
	a2[i]=s.nextInt();
System.out.println(ans(a1,a2));
}
	static String ans(int a1[],int a2[])
	{String st=new String();
	for(int i=0;i<a1.length;i++)
	{for(int j=0;j<a2.length;j++)
	{
	    if (a2[i]==a1[i)
	{st=st+Integer.toString(a1[i])+" ";
		break;}}
	}return st;

	}
}


import java.io.*;
import java.util.*;
public class abc
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int m=sc.nextInt();
int n=sc.nextInt();
int array[m]=new int[];
Vector v=new Vector();
for(int i=0;i<n;i++)
{
array[i]=sc.nextInt();
}

for(int i=0;i<n;i++)
{
int num=sc.nextInt();
v.add(i,num);
}
for(int x=;x<m;x++)
{
if(v.contains(array[x]))
{
int pos=v.indexOf(array[x]);
System.out.println(v.get(pos));
v.remove(v.get(pos));
}
}
}
}


import java.util.Scanner;
import java.io.ArrayList;

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

		int n = sc.nextInt();
		int m = sc.nextInt();
		int x[] = new int[n];
		ArrayList<Integer> list = new ArrayList<Integer>();

		for(int i=0;i<n;i++)
			x[i] = sc.nextInt();

		for(int i=0;i<m;i++)
			list.add(sc.nextInt());

		for(int i=0;i<n;i++)
		{
			if(list.contains(x[i]))
				System.out.print(x[i]+" ");
		}
	}

}


import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class Codeforces {
    public static void main(String[] args) throws IOException {
        new Codeforces();
    }
    public Codeforces() throws IOException {
        new CF994A().solve();
    }
    public int findBottomLeftValue(TreeNode root) {
        if(root.left == null && root.right == null)
            return root.val;

        List<Integer> ans = new ArrayList<Integer>();

        Queue<TreeNode> q = new LinkedList<TreeNode>();
        q.add(root);

        while (!q.isEmpty()) {
            int qSize = q.size();
            for (int i = 0; i < qSize; i++) {
                TreeNode node = q.poll();
                ans.add(node.val);
                if (node.left != null)
                    q.offer(node.left);
                if (node.right != null)
                    q.offer(node.right);
            }
            ans.add(Integer.MIN_VALUE);
        }

        int i = ans.size() - 1;
        while(true){
            int k = ans.get(i);
            if(k == Integer.MIN_VALUE && i != ans.size() - 1){
                return ans.get(i + 1);
            }
            i--;
        }
    }
    public static List<Integer> largestValues(TreeNode root) {
        List<Integer> ans = new ArrayList<Integer>();
        Queue<TreeNode> q = new LinkedList<TreeNode>();
        q.add(root);
        int i = 1;
        int lastDepth = 0;
        int max = -1;
        while(!q.isEmpty()){
            TreeNode tempNode = q.poll();
            int depth = (int)(Math.log(i) / Math.log(2));
            if(lastDepth != depth){
                lastDepth = depth;
                ans.add(max);
                max = -1;
            }
            if(tempNode != null){
                if(tempNode.val > max)
                    max = tempNode.val;
            }
                q.add(tempNode.left);
                q.add(tempNode.right);

            i++;
        }
        if(max != -1)
            ans.add(max);
        return ans;
    }

    class CF994A {
        public void solve() throws IOException {
            Input in = new Input();
            int n = in.nextInt();
            int m = in.nextInt();
            int[] seq = new int[n];
            for(int i = 0; i < n; i++){
                seq[i] = in.nextInt();
            }
            HashSet<Integer> prints = new HashSet<Integer>();
            for(int i = 0; i < m; i++){
                prints.add(in.nextInt());
            }
            String out = "";
            for(int i = 0; i < seq.length; i++){
                if(prints.contains(seq[i]))
                    out += seq[i] + " ";
            }
            if(out.length() > 0){
                System.out.println(out.trim());
            } else System.out.println("");
        }
    }
}

class TreeNode {
     int val;
     TreeNode left;
     TreeNode right;
     TreeNode(int x) { val = x; }
 }
class NullNode extends TreeNode{
    public NullNode(){
        super(-1);
        this.left = new NullNode();
        this.right = new NullNode();
    }
}
class Solution {
    public int findBottomLeftValue(TreeNode root) {
        return answer(root);
    }
    public int answer(TreeNode node){
        Answer a = new Answer();
        traverse(node, 0, a, true);
        if(a.ans != null)
            return a.ans.val;
        return -1;
    }
    public void traverse(TreeNode node, int level, Answer a, boolean isLeft){
        if(node == null)
            return;
        if(isLeft && node.left == null && node.right == null && level > a.maxDepth){
            a.ans = node;
            a.maxDepth = level;
        }
        traverse(node.left, level + 1, a, true);
        traverse(node.right, level + 1, a, false);
    }
}
class Answer {
    public TreeNode ans = null;
    public int maxDepth = -1;
}
class CF909_A {
    public void solve(){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String[] names = s.split(" ");
        String output = "";
        int i, j = i = 0;
        while(true){
            if(i == 0){
                output += names[0].charAt(i++);
            }
            if(i >= names[0].length()){
                output += names[1].charAt(j);
                break;
            }
            if(names[1].charAt(j) < names[0].charAt(i)){
                output += names[1].charAt(j);
                break;
            }
            else {
                output += names[0].charAt(i++);
            }
        }
        System.out.println(output);
    }
}


import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * User: Aditya
 * Date: 6/18/14
 * Time: 2:21 PM
 * To change this template use File | Settings | File Templates.
 */
public class game {

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

        char[] teamOne = sc.nextLine().toCharArray();
        char[] teamTwo = sc.nextLine().toCharArray();

        int teamTwoCount = 0;
        int teamOneCount = 0;

        for (int i=0;i<teamOne.length;i=i+2){
            if(teamOne[i]=='['&&teamOne[i+1]== ']'){   //paper
                if(teamTwo[i]=='('&&teamTwo[i+1]== ')'){ //rock
                    teamOneCount++;
                }
                else if(teamTwo[i]=='8'&&teamTwo[i+1]== '<'){ //scissors
                    teamTwoCount++;
                }
            }
            else if(teamOne[i]=='('&&teamOne[i+1]== ')'){  //rock
                if(teamTwo[i]=='['&&teamTwo[i+1]== ']') {  //paper
                   teamTwoCount++;
                }
                else if(teamTwo[i]=='8'&&teamTwo[1+1]== '<'){    //scissors
                    teamOneCount++;
                }
            }
            else if(teamOne[i]=='8'&&teamOne[i+1]== '<') {    //scissors
                if(teamTwo[i]=='('&&teamTwo[i+1]== ')'){       //rock
                    teamTwoCount++;
                }
                else if(teamTwo[i]=='['&&teamTwo[i+1]== ']'){    //paper
                   teamOneCount++;
                }
            }
        }

        if(teamOneCount==teamTwoCount){
            System.out.println("TIE");
        }
        else if(teamOneCount>teamTwoCount){
            System.out.println("TEAM 1 WINS");
        }
        else if(teamOneCount<teamTwoCount){
            System.out.println("TEAM 2 WINS");
        }

    }
}


import java.util.*

public class JavaApplication6 {

    /**
     * @param args the command line arguments
     */
   public static void main(String[] args){
    Scanner in = new Scanner(System.in);
    String t1 = "[]()[]8<";//in.nextLine();
    String t2 = "8<[]()8<";//in.nextLine();

    int t1Score = 0;
    int t2Score = 0;

    for (int i = 0; i < t1.length(); i+=2){
        char c1 = t1.charAt(i);
        char c2 = t2.charAt(i);

        if(c1=='['){
            if(c1=='8'){
                t2Score++;
            }
            else if(c2=='('){
                t1Score++;
            }
        }
        else if(c1== '('){
            if(c2=='['){
                t2Score++;
            }
            else if(c2=='8'){
                t1Score++;
            }

        }
        else{
            if(c2=='['){
                t1Score++;
            }
            if(c2=='('){
                t2Score++;
            }
        }

        if(t1Score>t2Score){
            System.out.print("TEAM 1 WINS");
        }
        else if(t2Score>t1Score){
            System.out.print("TEAM 2 WINS");
        }
        else{
            System.out.print("TIE");
        }
    //Process char
    }

}
}


import java.util.*

public class JavaApplication6 {

    /**
     * @param args the command line arguments
     */
   public static void main(String[] args){
    Scanner in = new Scanner(System.in);
    String t1 = "[]()[]8<";//in.nextLine();
    String t2 = "8<[]()8<";//in.nextLine();

    int t1Score = 0;
    int t2Score = 0;

    for (int i = 0; i < t1.length(); i+=2){
        char c1 = t1.charAt(i);
        char c2 = t2.charAt(i);

        if(c1=='['){
            if(c1=='8'){
                t2Score++;
            }
            else if(c2=='('){
                t1Score++;
            }
        }
        else if(c1== '('){
            if(c2=='['){
                t2Score++;
            }
            else if(c2=='8'){
                t1Score++;
            }

        }
        else{
            if(c2=='['){
                t1Score++;
            }
            if(c2=='('){
                t2Score++;
            }
        }

        if(t1Score>t2Score){
            System.out.print("TEAM 1 WINS");
        }
        else if(t2Score>t1Score){
            System.out.print("TEAM 2 WINS");
        }
        else{
            System.out.print("TIE");
        }
    }

}
}


public class das_lab2 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s1 = sc.nextLine();
		String s2 = sc.nextLine();
		int sum1 = 0;
		int sum2 = 0;
		for (int i = 0; i < s1.length(); i += 2) {
			String l1 = s1.substring(i, i + 2), l2 = s2.substring(i, i + 2);
			if (!l1.equals(l2)) {
				if (l1.equals("8<") && l2.equals("()") || l1.equals("()")
						&& l2.equals("[]"))
					sum1++;
				else
					sum2++;
			}
		}
		if (sum1 > sum2)
			System.out.println("TEAM 1 WINS");
		else if (sum1 < sum2)
			System.out.println("TEAM 2 WINS");
		else
			System.out.println("TIE");
	}
}


import java.util.*;
public class Test {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc =new Scanner(System.in);
		long s =sc.nextLong();
		long x =sc.nextLong();
		long or =s+x;
		long and =s-x;
		long tot=1;
		if((or & 1) ==0 && (and & 1)==0){
			or = or>>1;
			and =and>>1;
			while(and!=0 && or!=0){
				if(and%2!=1){
					if(or%2!=0){
						tot<<=1;
					}
				}
			}
			System.out.println(tot);
		}
		else{
			System.out.println(0);
		}
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;

import javafx.util.Pair;

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

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

    static class a672 {
        HashSet<Pair<Long, Long>> ans;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long s = in.nextLong();
            long x = in.nextLong();
            ans = new HashSet<>();
            comb(0, 0, s, x);
            for (int i = 0; i < 50; i++) {
                if (s == ((1L << i) - 1) && s == x) {
                    out.println((1L << i) - 2);
                    return;
                }
            }
            out.println(ans.size());
        }

        void comb(long num, int bit, long sum, long xor) {
            if (bit >= 40) {
                if (num > 0 && (num ^ xor) > 0 && num + (num ^ xor) == sum) {
                    ans.add(new Pair<>(num, (num ^ xor)));
                }
                return;
            }
            long tail = num;
            long xorTail = (num ^ xor) & ((1L << bit) - 1);
            long upSum = sum - tail - xorTail;
            if ((upSum & ((1L << bit) - 1)) != 0) {
                return;
            }
            comb(num, bit + 1, sum, xor);
            comb(num | (1L << bit), bit + 1, sum, xor);
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

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

    }
}