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

public class Main {
    static long derangement[];
    static void build(int k) {
        derangement[0] = 1;
        derangement[1] = 0;
        for (int i = 2; i <= k; i++) derangement[i] = (i - 1) * (derangement[i - 1] + derangement[i - 2]);
    }
    static long combination(int n, int k) {
        switch (k) {
            case 0 : return 1;
            case 1: return n;
            case 2: return (long) n * (n - 1) / 2;
            case 3: return (long) n * (n - 1) * (n - 2) / 6;
            case 4: return (long) n * (n - 1) * (n - 2) * (n - 3) / 24;
            default: return -1;
        }
    }
    static void solve() throws IOException {
        rl(); int n = ni2(); int k = ni2();
        derangement = new long[k + 1];
        long res = 0;
        build(k);
        for (int i = 0; i <= k; i++) res += derangement[i] * combination(n, i);
        ans.append(res).append('\n');
        output.write(ans.toString());
        output.flush();
        output.close();
    }

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

    static BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    static BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));
    static StringBuilder ans = new StringBuilder();
    static String line;
    static StringTokenizer stringTokenizer;

    static int ni1() throws IOException {
        return Integer.parseInt(input.readLine());
    }

    static int ni2() throws IOException {
        return Integer.parseInt(stringTokenizer.nextToken());
    }

    static long nl1() throws IOException {
        return Long.parseLong(input.readLine());
    }

    static long nl2() {
        return Long.parseLong(stringTokenizer.nextToken());
    }

    static void rl() throws IOException {
        stringTokenizer = new StringTokenizer(input.readLine());
    }
}


import java.io.*;
import java.util.*;
public class code {
	static printer pw;
	static boolean[] visit;
	static ArrayList<Pair>[] adj;
	static ArrayList<Integer> list;
	static long max=01;
	static void dfs(int i, long c) {
		visit[i]=true;
		max=Math.max(c, max);
		for(Pair p: adj[i]) {
			if(!visit[p.x-1]) {
				dfs(p.x-1, c+1l*p.y);
			}
		}
	}
	static long Pow(long a, int e, int mod)
	{
		a %= mod;
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res = (res * a) % mod;
			a = (a * a) % mod;
			e >>= 1;
		}
		return res;
	}
	public static double dist(Pair a, Pair b) {
		return Math.sqrt((a.x-b.x)*(a.x-b.x)+ (a.y-b.y)*(a.y-b.y));
	}
	public static boolean sign(int x) {
		return x>0;
	}
	static int test(int[] arr, int mid) {
		int ans=0;
		for(int i=1; i<arr.length; i++) {
			if(arr[i]==-1 && arr[i-1]!=-1) {
				if(Math.abs(mid-arr[i-1])>Math.abs(ans))
					ans=mid-arr[i-1];
			}
			if(arr[i]!=-1 && arr[i-1]==-1) {
				if(Math.abs(mid-arr[i])>Math.abs(ans))
					ans=mid-arr[i];
			}
		}
		return ans;
	}
	public static void main(String[] args) throws Exception {
		Scanner sc= new Scanner(System.in);
		pw = new printer();
		int w1=sc.nextInt(),h1=sc.nextInt(),w2=sc.nextInt(),h2=sc.nextInt();
		long ans=1l*(w1-w2!=0?1:0)*h2+1l*(h1+h2+2)+1l*(w1==w2?h1+h2+2:h1+2)+2*1l*(w1);
		pw.println(ans);
		pw.close();
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}

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

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public int[] nextArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < arr.length; i++)
				arr[i] = nextInt();
			return arr;
		}
		public Integer[] nextsort(int n) throws IOException{
			Integer[] arr=new Integer[n];
			for(int i=0; i<n; i++)
				arr[i]=nextInt();
			return arr;
		}
		public boolean ready() throws IOException {
			return br.ready();
		}
	}
	static class printer{
		PrintWriter pw;
		public printer() {
			pw=new PrintWriter(System.out);
		}
		public void print(String s) throws IOException{
			pw.print(s);
		}
		public void print(int s) throws IOException{
			pw.print(s);
		}
		public void print(long s) throws IOException{
			pw.print(s);
		}
		public void print(char s) throws IOException{
			pw.print(s);
		}
		public void print(Integer s) throws IOException{
			pw.print(s);
		}
		public void print(Long s) throws IOException{
			pw.print(s);
		}
		public void print(Character s) throws IOException{
			pw.print(s);
		}
		public void println(String s) throws IOException{
			pw.println(s);
		}
		public void println(int s) throws IOException{
			pw.println(s);
		}
		public void println(long s) throws IOException{
			pw.println(s);
		}
		public void println(char s) throws IOException{
			pw.println(s);
		}
		public void println(Integer s) throws IOException{
			pw.println(s);
		}
		public void println(Long s) throws IOException{
			pw.println(s);
		}
		public void println(Character s) throws IOException{
			pw.println(s);
		}
		public void println(int[] arr) throws IOException{
			for(int i=0; i<arr.length-1; i++)
				pw.print(arr[i]+" ");
			pw.println(arr[arr.length-1]);
		}
		public void println(Integer[] arr) throws IOException{
			for(int i=0; i<arr.length-1; i++)
				pw.print(arr[i]+" ");
			pw.println(arr[arr.length-1]);
		}
		public void println(long[] arr) throws IOException{
			for(int i=0; i<arr.length-1; i++)
				pw.print(arr[i]+" ");
			pw.println(arr[arr.length-1]);
		}
		public void println(Long[] arr) throws IOException{
			for(int i=0; i<arr.length-1; i++)
				pw.print(arr[i]+" ");
			pw.println(arr[arr.length-1]);
		}
		public void println(char[] arr) throws IOException{
			for(int i=0; i<arr.length-1; i++)
				pw.print(arr[i]+" ");
			pw.println(arr[arr.length-1]);
		}
		public void println(Character[] arr) throws IOException{
			for(int i=0; i<arr.length-1; i++)
				pw.print(arr[i]+" ");
			pw.println(arr[arr.length-1]);
		}
		public void println(ArrayList<Integer> arr) throws IOException{
			for(int i=0; i<arr.size()-1; i++)
				pw.print(arr.get(i)+" ");
			pw.println(arr.get(arr.size()-1));
		}
		public void println(TreeSet<Integer> arr) throws IOException{
			for(int x: arr) {
				pw.print(x+" ");
			}
		}
		public void close() throws IOException{
			pw.close();
		}
		public void flush() throws IOException{
			pw.flush();
		}
	}
	static class Pair implements Comparable<Pair>{
		int x;
		int y;
		public Pair(int a, int b) {
			this.x=a;
			this.y=b;
		}
		public int compareTo(Pair other) {
			return -1*(this.y-other.y);
		}
	}
	static class Triple implements Comparable<Triple>{
		int x;
		int y;
		boolean d;
		public Triple(int a, int b, boolean t) {
			this.x=a;
			this.y=b;
			this.d=t;
		}
		public int compareTo(Triple other) {
			if(this.d && !other.d) {
				return 1;
			}else if(!this.d && other.d) {
				return -1;
			}else {
				return this.y-other.y;
			}
		}
	}
}


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

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

class TaskA {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
        long n = in.nextLong(), p3 = 3;
        for(; n%p3 == 0; p3 *= 3);
        out.println(n/p3 + 1);
    }
}


/*package whatever //do not write package name here */

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

public class solution {
	public static void main (String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
	    int m = sc.nextInt();
	    int [] a = new int[m];
	   int diff = 1000;
	    for(int i=0;i<m;i++)
	    {
	       a[i] = sc.nextInt();
	    }
	       Arrays.sort(a);

	       for(int i=0;i<=(m-n);i++)
	       {
	          if(a[i+n-1]-a[i]<=diff)
	          {
	            diff = a[i+n-1]-a[i];
	          }
	       }

	    System.out.print(diff);
	   }
	}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * 4 4
 * 1 5 3 4
 * 1 2
 * 1 3
 * 2 3
 * 3 3
 *
 *
 * @author pttrung
 */
public class A {

    public static long Mod = (long) (1e9) + 7;
    static int time = 1;
    static long[] dp;

    public static void main(String[] args) throws FileNotFoundException {
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        long n = in.nextLong();
        long x = in.nextLong() - 1;
        long y = in.nextLong() - 1;
        long c = in.nextLong();
        long start = 0;
        long end = 2*n;
        long result = end;
        while (start <= end) {
            long mid = (start + end) / 2;
            long total = cal(x,y,mid,n);
            if (total < c) {
                start = mid + 1;
            } else if (total >= c) {
                result = Math.min(result, mid);
                end = mid - 1;
            }
        }
        out.println(result);
        out.close();
    }

  static long cal(long x, long y , long l, long n){
      long minX = min(x - l);
      long maxX = max(x + l, n);
      long minY = min(y - l);
      long maxY = max(y + l, n);
      long total = 0;
      if(maxX != x + l){
          long c = x + l - maxX;
          long left = l - (maxY - y);
          if(left + x > maxX){
              long a = x + left - maxX;
              total -= (a + c)*(maxY - y + 1)/2;
          }else{
              total -= c*(c + 1)/2;
          }
      }
      if(minX != x - l){
          long c = minX - (x - l);
          long left = l - (maxY - y);
          if(x - left < minX){
              long a = minX - (x - left);
              total -= (a + c)*(maxY - y + 1)/2;
          }else{
              total -= c*(c + 1)/2;
          }
      }
      if(maxY < y + l){
          long c = y + l - maxY;
          long last = 2*c - 1;
          total -= (last + 1)*c/2;
      }
      long last = l*2 + 1;
      total += (last + 1)*(l + 1)/2;
      if(maxX != x + l){
          long c = x + l - maxX;
          long left = l - (y - minY);
          if(left + x > maxX){
              long a = x + left - maxX;
              total -= (a + c)*(y - minY + 1)/2;
          }else{
              total -= c*(c + 1)/2;
          }
      }
      if(minX != x - l){
          long c = minX - (x - l);
          long left = l - (y - minY);
          if(x - left < minX){
              long a = minX - (x - left);
              total -= (a + c)*(y - minY + 1)/2;
          }else{
              total -= c*(c + 1)/2;
          }
      }
      if(minY > y - l){
          long c = minY - (y - l);
          last = 2*c - 1;
          total -= (last + 1)*c/2;
      }
      last = l*2 + 1;
      total += (last + 1)*(l + 1)/2;
      total -= (maxX - minX + 1);
      return total;
  }

  static long max(long v, long n){
      if(v < n){
          return v;
      }
      return n - 1;
  }
  static long min(long v){
      if(v > 0){
          return v;
      }
      return 0;
  }

    static long squareDist(int x, int y) {
        long X = x;
        long Y = y;
        return X * X + Y * Y;
    }

    static int find(int index, int[] u) {
        if (index != u[index]) {
            return u[index] = find(u[index], u);
        }
        return index;
    }

    public static long pow(int a, int b, long mod) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long v = pow(a, b / 2, mod);
        if (b % 2 == 0) {
            return (v * v) % mod;
        } else {
            return (((v * v) % mod) * a) % mod;
        }
    }

    public static int[][] powSquareMatrix(int[][] A, long p) {
        int[][] unit = new int[A.length][A.length];
        for (int i = 0; i < unit.length; i++) {
            unit[i][i] = 1;
        }
        if (p == 0) {
            return unit;
        }
        int[][] val = powSquareMatrix(A, p / 2);
        if (p % 2 == 0) {
            return mulMatrix(val, val);
        } else {
            return mulMatrix(A, mulMatrix(val, val));
        }

    }

    public static int[][] mulMatrix(int[][] A, int[][] B) {
        int[][] result = new int[A.length][B[0].length];
        for (int i = 0; i < result.length; i++) {
            for (int j = 0; j < result[0].length; j++) {
                long temp = 0;
                for (int k = 0; k < A[0].length; k++) {

                    temp += ((long) A[i][k] * B[k][j] % Mod);
                    temp %= Mod;
                }
                temp %= Mod;
                result[i][j] = (int) temp;
            }
        }

        return result;
    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;

    }

    static class FT {

        int[] data;

        FT(int n) {
            data = new int[n];
        }

        void update(int index, int val) {
            // System.out.println("UPDATE INDEX " + index);
            while (index < data.length) {
                data[index] += val;
                index += index & (-index);

                //    System.out.println("NEXT " +index);
            }
        }

        int get(int index) {
            //  System.out.println("GET INDEX " + index);
            int result = 0;
            while (index > 0) {
                result += data[index];
                index -= index & (-index);
                // System.out.println("BACK " + index);
            }
            return result;
        }
    }

    static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }

    static long pow(long a, int b) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2);
        if (b % 2 == 0) {

            return val * val % Mod;
        } else {
            return (val * val % Mod) * a % Mod;
        }
    }

//    static Point intersect(Point a, Point b, Point c) {
//        double D = cross(a, b);
//        if (D != 0) {
//            return new Point(cross(c, b) / D, cross(a, c) / D);
//        }
//        return null;
//    }
//
//    static Point convert(Point a, double angle) {
//        double x = a.x * cos(angle) - a.y * sin(angle);
//        double y = a.x * sin(angle) + a.y * cos(angle);
//        return new Point(x, y);
//    }
    static Point minus(Point a, Point b) {
        return new Point(a.x - b.x, a.y - b.y);
    }
//
//    static Point add(Point a, Point b) {
//        return new Point(a.x + b.x, a.y + b.y);
//    }
//

    /**
     * Cross product ab*ac
     *
     * @param a
     * @param b
     * @param c
     * @return
     */
    static double cross(Point a, Point b, Point c) {
        Point ab = new Point(b.x - a.x, b.y - a.y);
        Point ac = new Point(c.x - a.x, c.y - a.y);
        return cross(ab, ac);
    }

    static double cross(Point a, Point b) {
        return a.x * b.y - a.y * b.x;
    }

    /**
     * Dot product ab*ac;
     *
     * @param a
     * @param b
     * @param c
     * @return
     */
    static long dot(Point a, Point b, Point c) {
        Point ab = new Point(b.x - a.x, b.y - a.y);
        Point ac = new Point(c.x - a.x, c.y - a.y);
        return dot(ab, ac);
    }

    static long dot(Point a, Point b) {
        long total = a.x * b.x;
        total += a.y * b.y;
        return total;
    }

    static double dist(Point a, Point b) {
        long total = (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
        return Math.sqrt(total);
    }

    static long norm(Point a) {
        long result = a.x * a.x;
        result += a.y * a.y;
        return result;
    }

    static double dist(Point a, Point b, Point x, boolean isSegment) {
        double dist = cross(a, b, x) / dist(a, b);
        // System.out.println("DIST " + dist);

        if (isSegment) {
            Point ab = new Point(b.x - a.x, b.y - a.y);

            long dot1 = dot(a, b, x);
            long norm = norm(ab);
            double u = (double) dot1 / norm;
            if (u < 0) {
                return dist(a, x);
            }

            if (u > 1) {
                return dist(b, x);
            }
        }
        return Math.abs(dist);

    }

    static long squareDist(Point a, Point b) {
        long x = a.x - b.x;
        long y = a.y - b.y;
        return x * x + y * y;
    }

    static class Point {

        int x, y;

        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public String toString() {
            return "Point{" + "x=" + x + ", y=" + y + '}';
        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            //System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //br = new BufferedReader(new FileReader(new File("A-large (2).in")));
        }

        public String next() {

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

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

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

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

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

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


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
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);
        TaskF1 solver = new TaskF1();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskF1 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            int[] knights = new int[n + 1];
            int[] colors = new int[m + 1];

            for (int i = 0; i < n; i++) {
                knights[i] = in.nextInt();
            }

            int totalKnightsNeeded = 0;
            for (int i = 1; i <= m; i++) {
                colors[i] = in.nextInt();
                totalKnightsNeeded += colors[i];
            }

            for (int i = 0; i <= Math.min(n - 1, (n - totalKnightsNeeded)); i++) {
                int[] c1 = colors.clone();
                boolean canDo = true;
                for (int j = 0; j < totalKnightsNeeded; j++) {
                    c1[knights[i + j]]--;
                    if (c1[knights[i + j]] < 0) {
                        canDo = false;
                        break;
                    }
                }
                if (canDo) {
                    out.println("YES");
                    return;
                }
            }

            out.println("NO");
        }

    }

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

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

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

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

    }
}


import java.util.*;
public class ProbC {

   public static void main(String[] args) {
      int adj[][] = new int[7][7];
      Scanner sc = new Scanner (System.in);
      int n=sc.nextInt(), m=sc.nextInt();

      if (n == 7) {
         for (int i = 0; i < m; i++) {
            int u, v;
            u = sc.nextInt();
            v= sc.nextInt();
            u--;
            v--;
            adj[u][v] = adj[v][u] = 1;
         }
         int d = m;
         for (int u = 0; u < n; u++) {
            for (int v = u + 1; v < n; v++) {
               int c = 0;
               for (int w = 0; w < n; w++) {
                  if (adj[u][w] ==1 && adj[v][w]==1) {
                     c++;
                  }
               }
               d = Math.min(d, c);
            }
         }
         m -= d;
      }
      System.out.println(m);

   }
}


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

/**
 * Created by Timur on 15.12.2016.
 */
public class _630K {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        long n = in.nextLong();
        long first = n / 2 + n / 3 + n / 5 + n / 7;
        long second = n / (2 * 3) + n / (2 * 5) + n / (2 * 7) + n / (3 * 5) +n / (3 * 7) +n / (5 * 7);
        long third = n / (2 * 3 * 5) + n / (2 * 3 * 7) + n / (2 * 5 * 7) + n / (3 * 5 * 7);
        long forth = n / (2 * 3 * 5 * 7);

        out.print(n - first + second - third + forth);
        out.close();
    }
}


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

public class B {

	final int MOD = 1000000007;
	final double eps = 1e-12;

	public B () throws IOException {
		int B = sc.nextInt();
		int D = sc.nextInt();

		start();

		int T2 = t2(B,D);
		if (T2 > 0) {
			print("2-type");
			exit(T2);
		}

		if (t3(B,D))
			exit("3-type");

		if (t11(B,D))
			exit("11-type");

		for (int d1 = 2; d1 <= 50; ++d1)
			for (int d2 = 2; d2 <= 50; ++d2)
					if (d1*d2 == D && gcd(d1,d2) == 1) {
						if (t2(B,d1) > 0 && t3(B,d2)) exit("6-type");
						if (t2(B,d1) > 0 && t11(B,d2)) exit("6-type");
						if (t3(B,d1) && t11(B,d2)) exit("6-type");
					}

		for (int d1 = 2; d1 <= 25; ++d1)
			for (int d2 = 2; d2 <= 25; ++d2)
				for (int d3 = 2; d3 <= 25; ++d3)
					if (d1*d2*d3 == D && gcd(d1,d2) == 1 && gcd(d1*d2,d3) == 1 && t2(B,d1) > 0 && t3(B,d2) && t11(B,d3))
						exit("6-type");

		exit("7-type");
	}

	int t2(int B, int D) {
		long P = B;
		for (int i = 0; i < 6; ++i) {
			if (P % D == 0)
				return i+1;
			P = P * B;
		}
		return -1;
	}

	boolean t3(int B, int D) {
		return B%D == 1;
	}

	boolean t11(int B, int D) {
		return (B+1)%D == 0;
	}

	int gcd(int x, int y) {
		return BigInteger.valueOf(x).gcd(BigInteger.valueOf(y)).intValue();
	}
	////////////////////////////////////////////////////////////////////////////////////

	static MyScanner sc;

	static void print (Object... a) {
		StringBuffer b = new StringBuffer();
		for (Object o : a)
			b.append(" ").append(o);
		System.out.println(b.toString().trim());
	}

	static void exit (Object... a) {
		print(a);
		System.out.flush();
		exit();
	}

	static void exit () {
		System.err.println("------------------");
		System.err.println("Time: " + (millis() - t) / 1000.0);
		System.exit(0);
	}

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

		char [] nextChars() throws IOException {
			return next().toCharArray();
		}

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

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

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

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

		String [] nextStrings() throws IOException {
			line = null;
			return r.readLine().split(" ");
		}

		int [] nextInts() throws IOException {
			String [] L = nextStrings();
			int [] res = new int [L.length];
			for (int i = 0; i < L.length; ++i)
				res[i] = Integer.parseInt(L[i]);
			return res;
		}

		long [] nextLongs() throws IOException {
			String [] L = nextStrings();
			long [] res = new long [L.length];
			for (int i = 0; i < L.length; ++i)
				res[i] = Long.parseLong(L[i]);
			return res;
		}

		boolean eol() {
			return index == line.length;
		}

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

		private final BufferedReader r;

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

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

		private String [] line;
		private int index;

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

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

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

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

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

	static long t;

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


import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner (System.in);
        int t=sc.nextInt();
        while(t--!=0){
            int n=sc.nextInt();
            if(100%n==0){
                int ans=100/n;
                System.out.println(ans);
            }
            else{
              int x=n;
              int y=100-n;
              int gc=gcd(x,y);
              int ans=(x/gc)+(y/gc);
              System.out.println(ans);
            }
        }
    }
    public static int gcd(int a,int b){
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }
}


import java.util.HashMap;
import java.util.Scanner;

public class ProblemF {

	static String[] word;

	static HashMap<String, Pair> hash;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		word = new String[n];
		for (int i = 0; i < n; i++) {
			word[i] = sc.next();
		}
		boolean win = false;
		Pair winpts = null;
		Pair losepts = null;
		hash = new HashMap<String, Pair>();
		for (char c = 'a'; c <= 'z'; c++) {
			if (!ok("" + c)) {
				continue;
			}
			Pair res = play("" + c);
			long nmy = getScore("" + c) + res.other;
			if (!res.win) {
				win = true;
				if (winpts == null) {
					winpts = new Pair(0, 0, true);
					winpts.my = nmy;
					winpts.other = res.my;
				} else {
					if (winpts.my < nmy || (winpts.my == nmy && winpts.other > res.my)) {
						winpts.my = nmy;
						winpts.other = res.my;
					}
				}
			} else {
				if (losepts ==  null) {
					losepts = new Pair(0, 0, false);
					losepts.my = nmy;
					losepts.other = res.my;
				} else {
					if (losepts.my < nmy || (losepts.my == nmy && losepts.other > res.my)) {
						losepts.my = nmy;
						losepts.other = res.my;
					}
				}
			}
		}
		if (win) {
			System.out.println("First");
			System.out.println(winpts.my + " " + winpts.other);
		} else {
			System.out.println("Second");
			System.out.println(losepts.my + " " + losepts.other);
		}
	}

	static int count(String w) {
		int ret = 0;
		for (int i = 0; i < word.length; i++) {
			if (word[i].indexOf(w) >= 0) {
				ret++;
			}
		}
		return ret;
	}
	static boolean ok(String w) {
		return count(w) > 0;
	}

	private static Pair play(String current) {
		if (hash.containsKey(current)) {
			return hash.get(current);
		}
		Pair winpts = new Pair(0, 0, true);
		Pair losepts = new Pair(0, 0, false);
		boolean canwin = false;
		for (char c = 'a'; c <= 'z'; c++) {
			String nword1 = c + current;
			String nword2 = current + c;
			if (ok(nword1)) {
				Pair res = play(nword1);
				long nmy = getScore(nword1) + res.other;
				if (!res.win) {
					canwin = true;
					if (winpts == null) {
						winpts = new Pair(0, 0, true);
						winpts.my = nmy;
						winpts.other = res.my;
					} else {
						if (winpts.my < nmy || (winpts.my == nmy && winpts.other > res.my)) {
							winpts.my = nmy;
							winpts.other = res.my;
						}
					}
				} else {
					if (losepts ==  null) {
						losepts = new Pair(0, 0, false);
						losepts.my = nmy;
						losepts.other = res.my;
					} else {
						if (losepts.my < nmy || (losepts.my == nmy && losepts.other > res.my)) {
							losepts.my = nmy;
							losepts.other = res.my;
						}
					}
				}
			}
			if (ok(nword2)) {
				Pair res = play(nword2);
				long nmy = getScore(nword2) + res.other;
				if (!res.win) {
					canwin = true;
					if (winpts == null) {
						winpts = new Pair(0, 0, true);
						winpts.my = nmy;
						winpts.other = res.my;
					} else {
						if (winpts.my < nmy || (winpts.my == nmy && winpts.other > res.my)) {
							winpts.my = nmy;
							winpts.other = res.my;
						}
					}
				} else {
					if (losepts ==  null) {
						losepts = new Pair(0, 0, false);
						losepts.my = nmy;
						losepts.other = res.my;
					} else {
						if (losepts.my < nmy || (losepts.my == nmy && losepts.other > res.my)) {
							losepts.my = nmy;
							losepts.other = res.my;
						}
					}
				}
			}
		}
		if (canwin) {
			hash.put(current, winpts);
			return winpts;
		} else {
			hash.put(current, losepts);
			return losepts;
		}
	}

	private static int getScore(String word) {
		int sum = 0;
		int max = 0;
		for (char c : word.toCharArray()) {
			sum += (int)(c - 'a' + 1);
			max = Math.max(max, (int)(c - 'a' + 1));
		}
		return sum * max + count(word);
	}
}

class Pair {
	long my, other;
	boolean win;

	public Pair(long my, long other, boolean win) {
		super();
		this.my = my;
		this.other = other;
		this.win = win;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (my ^ (my >>> 32));
		result = prime * result + (int) (other ^ (other >>> 32));
		result = prime * result + (win ? 1231 : 1237);
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Pair other = (Pair) obj;
		if (my != other.my)
			return false;
		if (this.other != other.other)
			return false;
		if (win != other.win)
			return false;
		return true;
	}

}


import java.util.*;

public class E {

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

		int a = sc.nextInt(), b = sc.nextInt(), p = sc.nextInt();
		long x = sc.nextLong();

		long arr[] = new long[p];
		arr[p-1] = 1;
		for(int i=p-2;i>=0;i--){
			arr[i] = arr[i+1] * a % p;
		}

		long ans = 0;
		long T = (long)p*(p-1);

		for(int i = 1;i<=p-1;i++){
			long j = (i- b * arr[i]) % p;
			while(j < 0){
				j+=p;
			}

			long n = j * (p-1) + i;

			ans += x/T;
			if(x % T >= n)
				ans++;
		}

		System.out.println(ans);

	}

}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long a = scanner.nextLong();
        long b = scanner.nextLong();
        long c = scanner.nextLong();
        scanner.close();

        long result = c * 2;
        long t = Math.min(a, b);
        result += t * 2;
        if (b > t) {
            result++;
        }
        if (a > t) {
            result++;
        }
        System.out.println(result);
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 29);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastInput in = new FastInput(inputStream);
            PrintWriter out = new PrintWriter(outputStream);
            DGraphAndQueries solver = new DGraphAndQueries();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class DGraphAndQueries {
        Debug debug = new Debug(true);

        public void solve(int testNumber, FastInput in, PrintWriter out) {
            int n = in.readInt();
            int m = in.readInt();
            int q = in.readInt();
            int[] p = new int[n];
            in.populate(p);

            Edge[] edges = new Edge[m];
            for (int i = 0; i < m; i++) {
                edges[i] = new Edge();
                edges[i].a = in.readInt() - 1;
                edges[i].b = in.readInt() - 1;
            }

            int[][] qs = new int[4][q];
            for (int i = 0; i < q; i++) {
                for (int j = 0; j < 2; j++) {
                    qs[j][i] = in.readInt();
                }
                if (qs[0][i] == 2) {
                    edges[qs[1][i] - 1].delete = true;
                }
            }

            DSUExt dsu = new DSUExt(n);
            dsu.reset();
            for (Edge e : edges) {
                if (e.delete) {
                    continue;
                }
                dsu.merge(e.a, e.b);
            }

            for (int i = q - 1; i >= 0; i--) {
                if (qs[0][i] == 2) {
                    Edge e = edges[qs[1][i] - 1];
                    dsu.merge(e.a, e.b);
                } else {
                    int v = qs[1][i] - 1;
                    int pa = dsu.find(v);
                    qs[2][i] = dsu.begin[pa];
                    qs[3][i] = dsu.end[pa];
                }
            }

            int[] id = new int[n];
            int[] inv = new int[n];
            int idAlloc = 0;
            for (int i = 0; i < n; i++) {
                if (dsu.find(i) != i) {
                    continue;
                }
                for (int trace = dsu.begin[i]; trace != -1; trace = dsu.next[trace]) {
                    id[trace] = idAlloc++;
                    inv[id[trace]] = trace;
                }
            }

            Segment seg = new Segment(0, n - 1, i -> p[inv[i]]);
            debug.debug("seg", seg);
            for (int i = 0; i < q; i++) {
                if (qs[0][i] != 1) {
                    continue;
                }
                int l = id[qs[2][i]];
                int r = id[qs[3][i]];
                if (l > r) {
                    int tmp = l;
                    l = r;
                    r = tmp;
                }
                int ans = seg.query(l, r, 0, n - 1);
                seg.pop(l, r, 0, n - 1, ans);
                out.println(ans);

                debug.debug("debug", seg);
            }
        }

    }

    static class Segment implements Cloneable {
        private Segment left;
        private Segment right;
        private int max;

        private void modify(int x) {
            max = x;
        }

        public void pushUp() {
            max = Math.max(left.max, right.max);
        }

        public void pushDown() {
        }

        public Segment(int l, int r, IntToIntegerFunction func) {
            if (l < r) {
                int m = DigitUtils.floorAverage(l, r);
                left = new Segment(l, m, func);
                right = new Segment(m + 1, r, func);
                pushUp();
            } else {
                max = func.apply(l);
            }
        }

        private boolean covered(int ll, int rr, int l, int r) {
            return ll <= l && rr >= r;
        }

        private boolean noIntersection(int ll, int rr, int l, int r) {
            return ll > r || rr < l;
        }

        public boolean pop(int ll, int rr, int l, int r, int maxVal) {
            if (noIntersection(ll, rr, l, r)) {
                return false;
            }
            if (covered(ll, rr, l, r)) {
                if (max != maxVal) {
                    return false;
                }
                if (l == r) {
                    modify(0);
                    return true;
                }
            }
            pushDown();
            int m = DigitUtils.floorAverage(l, r);
            boolean ans = left.pop(ll, rr, l, m, maxVal);
            if (!ans) {
                ans = right.pop(ll, rr, m + 1, r, maxVal);
            }
            pushUp();
            return ans;
        }

        public int query(int ll, int rr, int l, int r) {
            if (noIntersection(ll, rr, l, r)) {
                return 0;
            }
            if (covered(ll, rr, l, r)) {
                return max;
            }
            pushDown();
            int m = DigitUtils.floorAverage(l, r);
            return Math.max(left.query(ll, rr, l, m),
                    right.query(ll, rr, m + 1, r));
        }

        private Segment deepClone() {
            Segment seg = clone();
            if (seg.left != null) {
                seg.left = seg.left.deepClone();
            }
            if (seg.right != null) {
                seg.right = seg.right.deepClone();
            }
            return seg;
        }

        protected Segment clone() {
            try {
                return (Segment) super.clone();
            } catch (CloneNotSupportedException e) {
                throw new RuntimeException(e);
            }
        }

        private void toString(StringBuilder builder) {
            if (left == null && right == null) {
                builder.append(max).append(",");
                return;
            }
            pushDown();
            left.toString(builder);
            right.toString(builder);
        }

        public String toString() {
            StringBuilder builder = new StringBuilder();
            deepClone().toString(builder);
            if (builder.length() > 0) {
                builder.setLength(builder.length() - 1);
            }
            return builder.toString();
        }

    }

    static class Debug {
        private boolean offline;
        private PrintStream out = System.err;
        static int[] empty = new int[0];

        public Debug(boolean enable) {
            offline = enable && System.getSecurityManager() == null;
        }

        public Debug debug(String name, Object x) {
            return debug(name, x, empty);
        }

        public Debug debug(String name, Object x, int... indexes) {
            if (offline) {
                if (x == null || !x.getClass().isArray()) {
                    out.append(name);
                    for (int i : indexes) {
                        out.printf("[%d]", i);
                    }
                    out.append("=").append("" + x);
                    out.println();
                } else {
                    indexes = Arrays.copyOf(indexes, indexes.length + 1);
                    if (x instanceof byte[]) {
                        byte[] arr = (byte[]) x;
                        for (int i = 0; i < arr.length; i++) {
                            indexes[indexes.length - 1] = i;
                            debug(name, arr[i], indexes);
                        }
                    } else if (x instanceof short[]) {
                        short[] arr = (short[]) x;
                        for (int i = 0; i < arr.length; i++) {
                            indexes[indexes.length - 1] = i;
                            debug(name, arr[i], indexes);
                        }
                    } else if (x instanceof boolean[]) {
                        boolean[] arr = (boolean[]) x;
                        for (int i = 0; i < arr.length; i++) {
                            indexes[indexes.length - 1] = i;
                            debug(name, arr[i], indexes);
                        }
                    } else if (x instanceof char[]) {
                        char[] arr = (char[]) x;
                        for (int i = 0; i < arr.length; i++) {
                            indexes[indexes.length - 1] = i;
                            debug(name, arr[i], indexes);
                        }
                    } else if (x instanceof int[]) {
                        int[] arr = (int[]) x;
                        for (int i = 0; i < arr.length; i++) {
                            indexes[indexes.length - 1] = i;
                            debug(name, arr[i], indexes);
                        }
                    } else if (x instanceof float[]) {
                        float[] arr = (float[]) x;
                        for (int i = 0; i < arr.length; i++) {
                            indexes[indexes.length - 1] = i;
                            debug(name, arr[i], indexes);
                        }
                    } else if (x instanceof double[]) {
                        double[] arr = (double[]) x;
                        for (int i = 0; i < arr.length; i++) {
                            indexes[indexes.length - 1] = i;
                            debug(name, arr[i], indexes);
                        }
                    } else if (x instanceof long[]) {
                        long[] arr = (long[]) x;
                        for (int i = 0; i < arr.length; i++) {
                            indexes[indexes.length - 1] = i;
                            debug(name, arr[i], indexes);
                        }
                    } else {
                        Object[] arr = (Object[]) x;
                        for (int i = 0; i < arr.length; i++) {
                            indexes[indexes.length - 1] = i;
                            debug(name, arr[i], indexes);
                        }
                    }
                }
            }
            return this;
        }

    }

    static class DSUExt extends DSU {
        int[] begin;
        int[] end;
        int[] next;

        public DSUExt(int n) {
            super(n);
            begin = new int[n];
            end = new int[n];
            next = new int[n];
        }

        public void reset() {
            super.reset();
            for (int i = 0; i < begin.length; i++) {
                begin[i] = end[i] = i;
                next[i] = -1;
            }
        }

        protected void preMerge(int a, int b) {
            next[end[a]] = begin[b];
            end[a] = end[b];
        }

    }

    static interface IntToIntegerFunction {
        int apply(int x);

    }

    static class DigitUtils {
        private DigitUtils() {
        }

        public static int floorAverage(int x, int y) {
            return (x & y) + ((x ^ y) >> 1);
        }

    }

    static class FastInput {
        private final InputStream is;
        private byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastInput(InputStream is) {
            this.is = is;
        }

        public void populate(int[] data) {
            for (int i = 0; i < data.length; i++) {
                data[i] = readInt();
            }
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    bufLen = -1;
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

    }

    static class DSU {
        protected int[] p;
        protected int[] rank;

        public DSU(int n) {
            p = new int[n];
            rank = new int[n];
        }

        public void reset() {
            for (int i = 0; i < p.length; i++) {
                p[i] = i;
                rank[i] = 0;
            }
        }

        public final int find(int a) {
            if (p[a] == p[p[a]]) {
                return p[a];
            }
            preAccess(a);
            return p[a] = find(p[a]);
        }

        protected void preAccess(int a) {

        }

        protected void preMerge(int a, int b) {

        }

        public final void merge(int a, int b) {
            a = find(a);
            b = find(b);
            if (a == b) {
                return;
            }
            if (rank[a] == rank[b]) {
                rank[a]++;
            }

            if (rank[a] < rank[b]) {
                int tmp = a;
                a = b;
                b = tmp;
            }

            preMerge(a, b);
            p[b] = a;
        }

    }

    static class Edge {
        int a;
        int b;
        boolean delete;

    }
}


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

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {
    static long n;
    static long log;
    static long calc(long a) {
        long fa = a;
        long rt = 0;
        long lgt = getLength(a);
        for (long i = lgt + 1; i < log; i++) {
            rt += (1L << (i - lgt));
        }
        a <<= (log - lgt);
        int eql = 0;
        for (long i = log - 1; i >= log - lgt; i--) {
            if (getBit(a, i) != getBit(n, i)) {
                eql = getBit(a, i) > getBit(n, i) ? 1 : -1;
                break;
            }
        }
        if (eql == 1) return rt;
        if (eql == -1) return rt + (log == lgt ? 0 : (1L << (log - lgt)));
        long zrs = log - lgt;
        for (long i = log - lgt - 1; i >= 0; i--) {
            if (getBit(n, i) == 1) rt += ((1L << (zrs - 1L)));
            zrs--;
        }
        return rt + (fa == n ? 0L : 1L);
    }

    static long getBit(long a, long bit) {
        return (a >> bit) & 1L;
    }

    static long extraCalc(long a) {
            if ((a & 1) == 0) return calc(a) + ((a + 1L) <= n ? (calc(a + 1L) + 1L) : 0) + 1L;
             else return calc(a) + 1;
    }

    static long  getLength(long a) {
        for (long i = 63; i >= 0; i--) {
            if (getBit(a, i) == 1L) return i + 1L;
        }
        return 1L;
    }

    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        n = in.nextLong();
        log = getLength(n);
        long k = in.nextLong();
        long t = 0;
        while ((1L << t) <= n) ++t;
        long l = 0;
        while (t > 0) {
            while (t > 0 && ((l + (1L << t)) > n || extraCalc(l + (1L << t)) < k)) {
                t--;
            }
            if (t == 0) {
                if (extraCalc(l + 1) >= k && l + 1 <= n) l++;
            } else l = (l + (1L << t));
        }
        if (extraCalc(l + 1) >= k && l + 1 <= n) l++;
        if (extraCalc(l) < k || l > n) l--;
        out.println(l);
        out.close();
    }
}

class FastScanner {
    BufferedReader br;
    StringTokenizer st;

    FastScanner(File f) throws FileNotFoundException {
        br = new BufferedReader(new FileReader(f));
    }

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

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

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

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