import java.util.*;
import java.io.*;
public class EdE {

	public static void main(String[] args) throws Exception{
		long num = 1000000007;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int n = Integer.parseInt(bf.readLine());
 		long[] dp = new long[n+1];
 		int[] isPrime = new int[n+1];
		Arrays.fill(isPrime, 1);
		int[] mu = new int[n+1];
		Arrays.fill(mu,  1);
		for(int i = 2;i<=n;i++){
			if (isPrime[i] == 1){
				for(int j = i;j<=n;j+=i){
					if (j > i)
						isPrime[j] = 0;
					if (j%(i*i) == 0)
						mu[j] = 0;
					mu[j] = -mu[j];
				}
			}
		}
		long sum = 0;
		for(int i = 2;i<=n;i++){
			sum+=(((long)(0-mu[i])*((((long)(n/i))*power(n-n/i, num-2, num))%num))%num+num)%num;
			sum%=num;

		}
		sum+=1;
		sum%=num;
 		out.println(sum);

 		out.close();

 	}
	public static long power(long x, long y, long mod){
		long ans = 1;
		while(y>0){
			if (y%2==1)
				ans = (ans*x)%mod;
			x = (x*x)%mod;
			y/=2;
		}
		return ans;
	}
}

//StringJoiner sj = new StringJoiner(" ");
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is


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

public class tr0 {
	static PrintWriter out;
	static StringBuilder sb;
	static final double EPS = 1e-9;
	static long mod = (int) 1e9 + 7;
	static int inf = (int) 1e9 + 2;
	static long[] fac;
	static int[] si;
	static ArrayList<Integer> primes;
	static TreeSet<Integer>[] ad;
	static ArrayList<pair>[] d;
	static edge[] ed;
	static boolean f;
	static int n,p;
	static int[]l,ch;
	static Boolean [][]memo;
	static Queue<Integer>[] can;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
	    String s=sc.next();
	    boolean is=false;
	    int t=s.length();
	    for(int i=1;i<s.length();i++)
	    	if(s.charAt(i)=='1')
	    		is=true;
	    if(is) {
	    	out.print(t/2+t%2);
	    }
	    else {
	    	t--;
	    	out.print(t/2+t%2);
	    }
		out.close();
	}
   	// 1-based DS, OOP
	static class SegmentTree {
		int N; // the number of elements in the array as a power of 2 (i.e. after padding)
		int[] array, sTree, lazy;
		boolean[] isLeaf;

		SegmentTree(int[] in) {
			array = in;
			N = in.length - 1;
			sTree = new int[N << 1]; // no. of nodes = 2*N - 1, we add one to cross out index zero
			lazy = new int[N << 1];
			isLeaf = new boolean[N << 1];
			Arrays.fill(lazy, -1);
			build(1, 1, N);
		}

		void build(int node, int b, int e) // O(n)
		{
			if (b == e) {
				sTree[node] = array[b];
				isLeaf[node] = true;
			} else {
				int mid = b + e >> 1;
				build(node << 1, b, mid);
				build(node << 1 | 1, mid + 1, e);
				sTree[node] = (sTree[node << 1] + sTree[node << 1 | 1]) % 2010;
			}
		}

		void update_point(int index, int val) // O(log n)
		{
			index += N - 1;
			sTree[index] += val;
			while (index > 1) {
				index >>= 1;
				sTree[index] = sTree[index << 1] + sTree[index << 1 | 1];
			}
		}

		void update_range(int i, int j, int val) // O(log n)
		{
			update_range(1, 1, N, i, j, val);
		}

		void update_range(int node, int b, int e, int i, int j, int val) {
			if (i > e || j < b)
				return;
			if (b >= i && e <= j) {
				if (b == e) {
					sTree[node] = (sTree[node] * sTree[node]) % 2010;
				} else {
					sTree[node] = ((sTree[node] * sTree[node]) % 2010
							- (sTree[node << 1] * sTree[node << 1 | 1] * 2) % 2010 + 2010) % 2010;
					lazy[node] = 1;
				}
			} else {
				int mid = b + e >> 1;
				propagate(node, b, mid, e);
				update_range(node << 1, b, mid, i, j, val);
				update_range(node << 1 | 1, mid + 1, e, i, j, val);
				sTree[node] = (sTree[node << 1] + sTree[node << 1 | 1]) % 2010;
			}
		}

		void propagate(int node, int b, int mid, int e) {
			if (lazy[node] == 1) {
				lazy[node << 1] = lazy[node];
				lazy[node << 1 | 1] = lazy[node];
				if (isLeaf[node << 1])
					sTree[node << 1] = sTree[node << 1] * sTree[node << 1] % 2010;
				else
					sTree[node << 1] = ((sTree[node << 1] * sTree[node << 1]) % 2010
							- (sTree[(node << 1) << 1] * sTree[(node << 1) << 1 | 1] * 2) % 2010 + 2010) % 2010;
				if (isLeaf[node << 1 | 1])
					sTree[node << 1 | 1] = sTree[node << 1 | 1] * sTree[node << 1 | 1] % 2010;
				else
					sTree[node << 1 | 1] = ((sTree[node << 1 | 1] * sTree[node << 1 | 1]) % 2010
							- (sTree[(node << 1 | 1) << 1] * sTree[(node << 1 | 1) << 1 | 1] * 2) % 2010 + 2010) % 2010;
				lazy[node] = -1;
			}
		}

		int query(int i, int j) {
			return query(1, 1, N, i, j);
		}

		int query(int node, int b, int e, int i, int j) // O(log n)
		{
			if (i > e || j < b)
				return 0;
			if (b >= i && e <= j)
				return sTree[node];
			int mid = b + e >> 1;
			propagate(node, b, mid, e);
			int q1 = query(node << 1, b, mid, i, j);
			int q2 = query(node << 1 | 1, mid + 1, e, i, j);
			return (q1 + q2) % 2010;

		}

	}

	static Queue<Integer> k, k1;
	static boolean hg = false;

	static class Edge implements Comparable<Edge> {
		int node, cost;

		Edge(int a, int b) {
			node = a;
			cost = b;
		}

		public int compareTo(Edge e) {
			return cost - e.cost;
		}
	}

	static void ifCan(int i) {
		if (i == 6) {
			hg = true;
			for (int j : k)
				k1.add(j);
			return;
		} else if (k.contains(i))
			ifCan(i + 1);
		else {
			if (!hg) {
				for (int p : can[i]) {
					if (!k.contains(p)) {
						k.add(i);
						k.add(p);
						ifCan(i + 1);
						k.remove(i);
						k.remove(p);
					}
				}
			}
		}
	}

	static class qu implements Comparable<qu> {
		int a;
		int b;

		qu(int a, int b) {
			this.a = a;
			this.b = b;
		}

		public String toString() {
			return a + " " + b;
		}

		@Override
		public int compareTo(qu o) {
			return b - o.b;
		}
	}

	static class pair {
		int to;
		int number;

		pair(int t, int n) {
			number = n;
			to = t;
		}

		public String toString() {
			return to + " " + number;
		}
	}

	static boolean[] in;

	/*
	 * static void mst() { Arrays.sort(ed); UnionFind uf=new UnionFind(n); for(int
	 * i=0;i<m;i++) { edge w=ed[i]; if(!uf.union(w.from, w.to)) continue;
	 * in[i]=true; } }
	 */
	static class edge implements Comparable<edge> {
		int from;
		int to;
		int number;

		edge(int f, int t, int n) {
			from = f;
			to = t;
			number = n;
		}

		public String toString() {
			return from + " " + to + " " + number;
		}

		public int compareTo(edge f) {
			return number - f.number;
		}
	}

	static class seg implements Comparable<seg> {
		int a;
		int b;

		seg(int s, int e) {
			a = s;
			b = e;
		}

		public String toString() {
			return a + " " + b;
		}

		public int compareTo(seg o) {
			// if(a==o.a)
			return o.b - b;
			// return
		}
	}

	static long power(int i) {
		// if(i==0)
		// return 1;
		long a = 1;
		for (int k = 0; k < i; k++)
			a *= i;
		return a;
	}

	static void seive() {
		si = new int[1000001];
		primes = new ArrayList<>();
		int N = 1000001;
		si[1] = 1;
		for (int i = 2; i < N; i++) {
			if (si[i] == 0) {
				si[i] = i;
				primes.add(i);
			}
			for (int j = 0; j < primes.size() && primes.get(j) <= si[i] && (i * primes.get(j)) < N; j++)
				si[primes.get(j) * i] = primes.get(j);

		}
	}

	static long inver(long x) {
		int a = (int) x;
		long e = (mod - 2);
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1) {
				// System.out.println(res*a);
				res = (int) ((1l * res * a) % mod);
			}
			a = (int) ((1l * a * a) % mod);
			e >>= 1;
		}
		// out.println(res+" "+x);
		return res % mod;
	}

	static long fac(int n) {
		if (n == 0)
			return fac[n] = 1;
		if (n == 1)
			return fac[n] = 1;
		long ans = 1;
		for (int i = 1; i <= n; i++)
			fac[i] = ans = (i % mod * ans % mod) % mod;
		return ans % mod;
	}

	static long gcd(long a, long b) {

		if (b == 0)
			return a;
		return gcd(b, a % b);
	}

	static class unionfind {
		int[] p;
		int[] size;

		unionfind(int n) {
			p = new int[n];
			size = new int[n];

			for (int i = 0; i < n; i++) {
				p[i] = i;
			}
			Arrays.fill(size, 1);
		}

		int findSet(int v) {
			if (v == p[v])
				return v;
			return p[v] = findSet(p[v]);
		}

		boolean sameSet(int a, int b) {
			a = findSet(a);
			b = findSet(b);
			if (a == b)
				return true;
			return false;
		}

		int max() {
			int max = 0;
			for (int i = 0; i < size.length; i++)
				if (size[i] > max)
					max = size[i];
			return max;
		}

		boolean combine(int a, int b) {
			a = findSet(a);
			b = findSet(b);
			if (a == b)
				return true;
			if (size[a] > size[b]) {
				p[b] = a;
				size[a] += size[b];

			} else {
				p[a] = b;
				size[b] += size[a];
			}
			return false;
		}
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

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

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

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

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

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

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

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
public class main {

    public static int [] mem;
    public static int a,b,c;

    public static void main(String[] args) {

        Scanner s= new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        //BufferedReader n = new BufferedReader(new InputStreamReader(System.in));

        int valor=s.nextInt();
         a=s.nextInt();
         b=s.nextInt();
         c=s.nextInt();

        mem=new int [4001];
        for(int i=0;i<mem.length;i++){
            mem[i]=-10000;
        }
        mem[0]=0;
        for(int i = 1;i<mem.length;i++){
            if(i>=a && i>=b && i>=c){
                mem[i]= Math.max(1+mem[i-a], Math.max(1+mem[i-b],1+mem[i-c]));
            }
            else
                if(i>=a && i>=b)
                    mem[i]= Math.max(1+mem[i-a],1+mem[i-b]);
                else
                    if(i>=c && i>=b)
                        mem[i]= Math.max(1+mem[i-c],1+mem[i-b]);
                    else
                        if(i>=a && i>=c)
                            mem[i]= Math.max(1+mem[i-a],1+mem[i-c]);
                        else
                            if(i>=a)
                                mem[i]= 1+mem[i-a];
                            else
                                if(i>=b)
                                    mem[i]= 1+mem[i-b];
                                else
                                    if(i>=c)
                                        mem[i]= 1+mem[i-c];
        }
        System.out.println(mem[valor]);

    }

}


	import java.io.IOException;
	import java.io.InputStream;
	import java.io.PrintWriter;
	import java.util.Arrays;
	import java.util.InputMismatchException;

	public class CF {
		static int mod, N;
		static int[] array;
		static long[][] memo;
		static int[] powpow;
		static int[][][] magic;
		public static void main(String[] args) {
			FasterScanner sc = new FasterScanner();
			PrintWriter out = new PrintWriter(System.out);
			char[] str = sc.next().toCharArray();
			int pow = 1;
			mod = sc.nextInt();
			magic = new int[20][10][mod];
			for(int a=0;a<20;a++){
				for(int b=0;b<10;b++)
					for(int c=0;c<mod;c++)
						magic[a][b][c]=(pow*b+c)%mod;
				pow*=10;
				pow%=mod;
			}
			N = str.length;
			array = new int[N];
			int[] freq = new int[10];
			for(int a=0;a<N;a++)
				freq[array[a]=str[a]-'0']++;
			Arrays.sort(array);
			memo = new long[mod][1<<N];
			for(int a=0;a<mod;a++)Arrays.fill(memo[a],-1);
			long ways = DP(0,0);
			long[] factorial = new long[20];
			factorial[0]=1;
			long bad = 1;
			for(int a=1;a<20;a++)
				factorial[a]=factorial[a-1]*a;
		//	for(int a=0;a<10;a++)
		//		bad*=factorial[freq[a]];
			out.println(ways/bad);
			out.close();
		}

		private static long DP(int mask, int remain) {
			if(memo[remain][mask]!=-1)return memo[remain][mask];
			if(mask==(1<<N)-1)
				return memo[remain][mask]=(remain==0?1L:0L);
			long ans = 0;
			for(int a=0;a<N;a++){
				if(((mask>>a)&1)==0){
					if(Integer.bitCount(mask)==0){
						if(array[a]==0)continue;
					}
					if(a>0&&(mask>>(a-1)&1)==0&&array[a]==array[a-1])continue;
					ans+=DP(mask+(1<<a),(magic[N-Integer.bitCount(mask)-1][array[a]][remain]));
				//	ans+=DP(mask+(1<<a),(powpow[N-Integer.bitCount(mask)-1]*array[a]+remain)%mod);
				}
			}
			return memo[remain][mask]=ans;
		}

		static boolean nextperm(int[] vals) {
			int N = vals.length;
			int K = -1;
			for(int a=N-2;a>=0;a--){
				if(vals[a]<vals[a+1]){
					K=a;
					break;
				}
			}
			if(K==-1)return false;
			for(int a=N-1;a>K;a--){
				if(vals[K]<vals[a]){
					swap(K,a,vals);
					break;
				}
			}
			int L = K+1;
			int R = N-1;
			while(L<R){
				swap(L,R,vals);
				L++;
				R--;
			}
			return true;
		}

		public static void swap(int i, int j, int[] v) {
			int t = v[i];
			v[i] = v[j];
			v[j] = t;
		}

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

			public FasterScanner() {
				stream = System.in;
				// stream = new FileInputStream(new File("dec.in"));

			}

			int read() {
				if (numChars == -1)
					throw new InputMismatchException();
				if (curChar >= numChars) {
					curChar = 0;
					try {
						numChars = stream.read(buf);
					} catch (IOException e) {
						throw new InputMismatchException();
					}
					if (numChars <= 0)
						return -1;
				}
				return buf[curChar++];
			}

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

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

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

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

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

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

			String nextLine() {
				int c = read();
				while (isEndline(c))
					c = read();
				StringBuilder res = new StringBuilder();
				do {
					res.appendCodePoint(c);
					c = read();
				} while (!isEndline(c));
				return res.toString();
			}

		}

	}


import java.util.*;

public class A {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int N = s.length();
		int max = -1;
		int LIM = 1000000;
		for(int i=1; i<N-1; i++) {
			for(int j=i+1; j<N; j++) {
				String a = s.substring(0, i);
				String b = s.substring(i, j);
				String c = s.substring(j);
//				System.out.println(a +" " + b +" " + c);
				if(a.length() > 1 && a.charAt(0) == '0')
					continue;
				if(b.length() > 1 && b.charAt(0) == '0')
					continue;
				if(c.length() > 1 && c.charAt(0) == '0')
					continue;
				if(a.length() > 8 || b.length() > 8 || c.length() > 8)
					continue;
				int x = Integer.parseInt(a);
				int y = Integer.parseInt(b);
				int z = Integer.parseInt(c);
				if(x > LIM || y > LIM || z > LIM)
					continue;
				max = Math.max(max, x+y+z);
			}
		}
		System.out.println(max);
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Comparator;
import java.util.List;

public class CyclicPermutations { // Template for CF
    public static class ListComparator implements Comparator<List<Integer>> {

        @Override
        public int compare(List<Integer> l1, List<Integer> l2) {
            for (int i = 0; i < l1.size(); ++i) {
                if (l1.get(i).compareTo(l2.get(i)) != 0) {
                    return l1.get(i).compareTo(l2.get(i));
                }
            }
            return 0;
        }
    }

    public static class Pair {
        int first;
        int second;

        public Pair(int first, int second) {
            this.first = first;
            this.second = second;
        }

        public int getFirst() {
            return first;
        }

        public int getSecond() {
            return second;
        }

        @Override
        public String toString() {
            return first + " " + second;
        }
    }

    public static void main(String[] args) throws IOException {
        // Check for int overflow!!!!
        // Should you use a long to store the sum or smthn?
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        long n = Integer.parseInt(f.readLine());
        long bad = 1;
        long mod = 1000000007;
        for (int j = 0; j < n - 1; j++) {
            bad *= 2;
            bad %= mod;
        }
        long prod = 1;
        for (long j = n; j > 0; j--) {
            prod *= j;
            prod %= mod;
        }
        if (prod - bad >= 0) {
            out.println(prod - bad);
        } else {
            out.println(mod + prod - bad);
        }
        out.close();
    }

}


import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Solution {

	private static int res;
	private static int[] numberOfPrimeDivisor;

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

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int[] plainNumber = new int [n];
		for(int i=0;i<plainNumber.length;i++){
			plainNumber[i] = i+1;
		}
		plainNumber[0] = -1;
		getNumbers(plainNumber);
		numberOfPrimeDivisor = new int [ n ];
		int count = 0;
		for(int i=0;i<n;i++){
			int a = getNumberOfPrimeDivisors(i+1);
			if(a==2){
				count++;
			}
		}

		System.out.println(count);

	}

	private static int getNumberOfPrimeDivisors(int i) {

			List<Integer> factors = primeFactors(i);
			int count = 1;
			for(int j=1;j<factors.size();j++){
				if(factors.get(j)!=factors.get(j-1)){
					count++;
				}
			}

			return count;

	}

	  public static List<Integer> primeFactors(int number) {
		    int n = number;
		    List<Integer> factors = new ArrayList<Integer>();
		    for (int i = 2; i <= n; i++) {
		      while (n % i == 0) {
		        factors.add(i);
		        n /= i;
		      }
		    }
		    return factors;
		  }

	private static void getNumbers(int[] plainNumber) {
		for(int i =2;i<plainNumber.length+1;i++){
			int a =2;
			while(a*i<plainNumber.length){
				plainNumber[a*i-1] = -1;
				a++;
			}
		}

	}

}


import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Contest {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner scanner = new Scanner(System.in)) {
			int k = scanner.nextInt();
			scanner.nextLine();
			int MAX = 311;
			//Queue

	//		int[][][] hash = new int[MAX][MAX][8];
			int[][] mask = new int[MAX][MAX];

			int[] dx = {1, 1, 0, -1, -1, -1, 0, 1};
			int[] dy = {0, -1, -1, -1, 0, 1, 1, 1};

			Set<Integer> curQueue = new HashSet<Integer>();
		//	hash[MAX/2][MAX/2][0] = 0;
			curQueue.add(getStatus(MAX/2, MAX/2, 0));
			//curQueue.add();
			for (int i = 1; i <= k; i++) {
				int next = scanner.nextInt();
				Set<Integer> newQueue = new HashSet<Integer>();
				for (int cur : curQueue) {
					int curDirection = cur & 0x7;
					int curY = (cur >> 3) & 0x1FF;
					int curX = (cur >> 12) & 0x1FF;
				//	if (hash[curX][curY][curDirection] < next) {
			//			hash[curX][curY][curDirection] = next;
						int j = 1;
						while(true) {
							curX += dx[curDirection];
							curY += dy[curDirection];
						//	System.out.println(curX);
							mask[curX][curY] = 1;
							if (j == next) {
								newQueue.add(getStatus(curX, curY, (curDirection + 1) % 8));
								int newDir = (curDirection - 1) % 8;
								if (newDir < 0) newDir = 8 + newDir;
								newQueue.add(getStatus(curX, curY, (newDir) % 8));
								break;
							}
				//			if (hash[curX][curY][curDirection] < next - j) {
				//				hash[curX][curY][curDirection] = next - j;
				//			} else break;
							j++;
						}
				//	}
				}
//				while (!curQueue.isEmpty()) {
//					//int cur = curQueue.();
//					int curDirection = cur & 0x7;
//					int curY = (cur >> 3) & 0x1FF;
//					int curX = (cur >> 12) & 0x1FF;
//					if (hash[curX][curY][curDirection] < next) {
//						hash[curX][curY][curDirection] = next;
//						int j = 1;
//						while(true) {
//							curX += dx[curDirection];
//							curY += dy[curDirection];
//						//	System.out.println(curX);
//							mask[curX][curY] = 1;
//							if (j == next) {
//								newQueue.add(getStatus(curX, curY, (curDirection + 1) % 8));
//								int newDir = (curDirection - 1) % 8;
//								if (newDir < 0) newDir = 8 + newDir;
//								newQueue.add(getStatus(curX, curY, (newDir) % 8));
//								break;
//							}
//							if (hash[curX][curY][curDirection] < next - j) {
//								hash[curX][curY][curDirection] = next - j;
//							} else break;
//							j++;
//						}
//					}
//				}
				curQueue = newQueue;
			}

			int res = 0;
			for (int i = 0; i < MAX; i++) {
				for (int j = 0; j < MAX; j++) {
					if (mask[i][j] == 1) res++;
				}
			}
			System.out.println(res);
//			System.out.println(mask[299][299]);
		}
	}

	public static int getStatus(int x, int y, int direction) {
		int result = 0;
		result = x;
		result = (result << 9) | y;
		result = (result << 3) | direction;
		//result = (result << 3) | value;
		return result;
	}

}


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

public class Main {
    static void solve(InputReader reader, OutputWriter writer)
            throws IOException {
        // Scanner scan = new Scanner(System.in);
        String a = reader.readLine();
        char c = a.charAt(0);
        String s = reader.readLine();
        char[] cc = { 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'a',
                's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', 'z', 'x', 'c',
                'v', 'b', 'n', 'm', ',', '.', '/' };
        if(c == 'R'){
            for (int i = 0; i < s.length(); ++i){
                int index = 0;
                for (int k = 0; k < cc.length; ++k){
                    if(s.charAt(i) == cc[k]){
                        index = --k;
                    //  writer.println(index);
                        break;
                    }
                }
                if(i < s.length() - 1)
                    writer.print(cc[index]);
                else
                    writer.println(cc[index]);
            }
        }else{
            for (int i = 0; i < s.length(); ++i){
                int index = 0;
                for (int k = 0; k < cc.length; ++k){
                    if(s.charAt(i) == cc[k]){
                        index = ++k;
                        break;
                    }
                }
                if(i < s.length() - 1)
                    writer.print(cc[index]);
                else
                    writer.println(cc[index]);
            }
        }

    }

    public static void main(String[] args) throws Exception {
        InputReader reader = new InputReader(System.in);
        OutputWriter writer = new OutputWriter(System.out);
        try {
            solve(reader, writer);
        } catch (Exception e) {
            e.printStackTrace(System.out);
        } finally {
            writer.close();
        }
    }

}

class InputReader extends BufferedReader {
    public InputReader(InputStream in) {
        super(new InputStreamReader(in));
    }
}

class OutputWriter extends PrintWriter {
    public OutputWriter(PrintStream out) {
        super(new BufferedWriter(new OutputStreamWriter(out)));
    }
}


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

public class TheMonster {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] p = in.readLine().split(" ");
		int a = Integer.parseInt(p[0]);
		long b = Long.parseLong(p[1]);

		boolean aa = a % 2 == 0;
		boolean bb = b % 2 == 0;

		String[] q = in.readLine().split(" ");
		int c = Integer.parseInt(q[0]);
		long d = Long.parseLong(q[1]);

		boolean cc = c % 2 == 0;
		boolean dd = d % 2 == 0;

		if(!((!bb && aa && dd && cc)||(!dd&&cc&&bb&&aa))) {
			while(b != d) {
				if(b < d) {
					b+=a;
				} else {
					d+=c;
				}
				if(d > 10000000) {
					b = -1;
					d = -1;
				}
			}
			System.out.println(b);
		} else {
			System.out.println(-1);
		}
	}
}


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

public class A {

    int n, k;
    int[][] memo;

    private int dp(int index, int sum) {
        if (index == n && sum == k)
            return 0;
        if (sum > k)
            return 1 << 29;
        if (index == n)
            return 1 << 29;
        if (memo[index][sum] != -1)
            return memo[index][sum];
        int res = 1 << 28;
        for (int i = 2; i <= 5; i++) {
            res = Math.min(res, ((i == 2) ? 1 : 0) + dp(index + 1, sum + i));
        }
        return memo[index][sum] = res;
    }

    private void solve() throws IOException {
        memo = new int[55][255];
        for (int[] a : memo) Arrays.fill(a, -1);
        n = nextInt();
        k = nextInt();
        pl(dp(0, 0));
    }

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

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

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

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

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

    BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

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

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

    void pl(Object... objects) {
        p(objects);
        writer.flush();
        writer.println();
        writer.flush();
    }

    int cc;

    void pf() {
        writer.printf("Case #%d: ", ++cc);
        writer.flush();
    }

}


import java.util.Scanner;

public class JavaApplication1 {

    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[1001];
        for (int i=0; i<n; i++) {
            a[sc.nextInt()]=1;
        }
        sc.close();

        for (int i=1; i<=998; i++) {
            if (a[i]+a[i+1]+a[i+2]==3) {
                System.out.println("YES");
                return;
            }
        }

        System.out.println("NO");

    }

}


import java.util.Scanner;

public class C {

    public static void main(String arg[]) {

        Scanner reader = new Scanner(System.in);

        long a = reader.nextLong();
        long b = reader.nextLong();

        System.out.println(f(a, b));

    }

    static long f(long a, long b) {

        if (a == 1)
            return b;
        if (b == 1)
            return a;

        if (a < b) {
            long t = a;
            a = b;
            b = t;
        }
        return a / b + f(b, a % b);
    }

}


import java.util.*;

public class main {
	public static void main(String[] all) {
		Scanner input = new Scanner(System.in);
		int t = input.nextInt();
		while (t-- > 0) {
			int n = input.nextInt();
			String num = ""+n;
			n = n % 10;
			int sum = 0;
			for (int i = 1; i < n; i++) sum += 10;
			for (int i = 1; i < num.length()+1; i++) sum += i;
			System.out.println(sum);
		}
		input.close();
	}
}


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

public class EE {
    private static BufferedReader in;
    private static StringTokenizer st;
    private static PrintWriter out;
    private static int mod;

    public static void main(String[] args) throws NumberFormatException, IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        st = new StringTokenizer("");
        out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int a = nextInt();
        int b = nextInt();
        int n = nextInt();
        long s1 = System.currentTimeMillis();
        mod = (int) (1e9+7);
        long fact = 1;
        for (long i = 1; i <= n; i++) {
            fact = (fact * i) % mod;
        }
        long factinverse[] = new long[n+1];
        factinverse[0] = 1;
        for (int i = 1; i <=n; i++) {
            long x = ModPow(i, mod - 2);
            factinverse[i] = (factinverse[i-1] * x) % mod;
        }
        long ans = 0;
        for (int i = 0; i <=n; i++) {
            int x = i*a +(n-i)*b;
            if(good(x, a, b)){
                long f2 = (factinverse[i] * factinverse[n-i]) % mod;
                ans = (ans + f2) % mod;
            }
        }
        ans = (ans * fact) % mod;
        long s2 = System.currentTimeMillis();
//        System.out.println((s2-s1)/1000.0);
        System.out.println(ans);
    }
    private static long ModPow(long a, int n) {
        long res = 1;
        while(n > 0){
            if((n & 1)== 1)
                res = (res * a) % mod;
            a = (a * a) % mod;
            n >>= 1;
        }
        return res;
    }
    private static boolean good(int x, int a, int b) {
        while(x > 0){
            int qol = x % 10;
            if(qol != a && qol!=b){
                return false;
            }
            x /= 10;
        }
        return true;
    }

    static String next() throws IOException{
        while(!st.hasMoreTokens()){
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
    static int nextInt() throws NumberFormatException, IOException{
        return Integer.parseInt(next());
    }
    static long nextLong() throws NumberFormatException, IOException{
        return Long.parseLong(next());
    }

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

}


import java.io.*;
import java.util.LinkedHashMap;
import java.util.Map;

public class Main {
	private static Object unexpected = null;
	private static final int mod = (int) 1E9 + 7;
	private static final int ibufsize = (1 << 15), obufsize = (1 << 14);
	private static int iNextByte, iNextIndex, iReadByteCount, oNextIndex;
	private static final byte ibuf[] = new byte[ibufsize], obuf[] = new byte[obufsize];
	private static InputStream is = System.in;
	private static OutputStream os = System.out;

	private Main() throws Exception {
		if (inFromFile) is = new FileInputStream(new File("").getAbsolutePath() + "/src/testdata/in.txt");
		if (outToFile) os = new FileOutputStream(new File("").getAbsolutePath() + "/src/testdata/out.txt");
		nextByte();
		solve();
		is.close();
		flushOutBuf();
	}

	public static void main(String[] args) {
		try {
			new Main();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private boolean isDigit(int cp) {
		return '0' <= cp && cp <= '9';
	}

	private boolean isLowercase(int cp) {
		return 'a' <= cp && cp <= 'z';
	}

	private boolean isUppercase(int cp) {
		return 'A' <= cp && cp <= 'Z';
	}

	private boolean isAlphabet(int cp) {
		return ('a' <= cp && cp <= 'z') || ('A' <= cp && cp <= 'Z');
	}

	private boolean isAlphanumberic(char ch) {
		return (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z') || (ch >= 'A' || ch <= 'Z');
	}

	private boolean isWhitespace(int cp) {
		return cp == ' ' || cp == '\r' || cp == '\n' || cp == '\t';
	}

	private boolean isWordSeparator(int cp) {
		return cp == ' ' || cp == '\r' || cp == '\n' || cp == '\t';
	}

	private boolean isLineSeparator(int cp) {
		return cp == '\n' || cp == '\r';
	}

	private boolean isUnexpected() {
		return unexpected != null;
	}

	private Object setUnexpected(Object value) {
		return (unexpected = value);
	}

	private boolean isNegative() throws IOException {
		boolean minus = false;
		while (iNextByte == '+' || iNextByte == '-') {
			if (iNextByte == '-') minus = !minus;
			nextByte();
		}
		return minus;
	}

	private int nextByte() throws IOException {
		if (iNextIndex >= iReadByteCount) {
			iReadByteCount = is.read(ibuf, 0, ibufsize);
			if (iReadByteCount == -1) return (iNextByte = -1);
			iNextIndex = 0;
		}
		return (iNextByte = ibuf[iNextIndex++]);
	}

	private char nc() throws IOException {
		return (char) nextByte();
	}

	private char[] nc(int n) throws IOException {
		char a[] = new char[n];
		for (int i = 0; i < n; ++i) a[i] = nc();
		return a;
	}

	private char[][] nc(int r, int c) throws IOException {
		char a[][] = new char[r][c];
		for (int i = 0; i < r; ++i) a[i] = nc(c);
		return a;
	}

	private int ni() throws IOException {
		while (isWhitespace(iNextByte)) nextByte();
		int res = 0;
		boolean minus = isNegative();
		if (!isDigit(iNextByte)) return (int) setUnexpected(-1);
		do {res = (res << 1) + (res << 3) + iNextByte - '0';} while (isDigit(nextByte()));
		return minus ? -res : res;
	}

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

	private int[][] ni(int r, int c) throws IOException {
		int a[][] = new int[r][c];
		for (int i = 0; i < r; ++i) a[i] = ni(c);
		return a;
	}

	private long nl() throws IOException {
		while (isWhitespace(iNextByte)) nextByte();
		long res = 0;
		boolean minus = isNegative();
		if (!isDigit(iNextByte)) return (long) setUnexpected(-1);
		do {res = (res << 1) + (res << 3) + iNextByte - '0';} while (isDigit(nextByte()));
		return minus ? -res : res;
	}

	private long[] nl(int n) throws IOException {
		long a[] = new long[n];
		for (int i = 0; i < n; ++i) a[i] = nl();
		return a;
	}

	private long[][] nl(int r, int c) throws IOException {
		long a[][] = new long[r][c];
		for (int i = 0; i < r; ++i) a[i] = nl(c);
		return a;
	}

	private double nd() throws IOException {
		while (isWhitespace(iNextByte)) nextByte();
		boolean minus = isNegative();
		if (!isDigit(iNextByte)) return (double) setUnexpected(-1.0);
		double decimal = 0, floating = 0, div = 1;
		do {decimal = 10 * decimal + (iNextByte - '0');} while (isDigit(nextByte()));
		if (iNextByte == '.') while (isDigit(nextByte())) floating += (iNextByte - '0') / (div *= 10);
		double res = decimal + floating;
		return minus ? -res : res;
	}

	private double[] nd(int n) throws IOException {
		double a[] = new double[n];
		for (int i = 0; i < n; ++i) a[i] = nd();
		return a;
	}

	private double[][] nd(int r, int c) throws IOException {
		double a[][] = new double[r][c];
		for (int i = 0; i < r; ++i) a[i] = nd(c);
		return a;
	}

	private String line() throws IOException {
		while (isWhitespace(iNextByte)) nextByte();
		StringBuilder sb = new StringBuilder();
		while (iNextByte != -1 && !isLineSeparator(iNextByte)) {
			sb.append((char) iNextByte);
			nextByte();
		}
		return sb.toString();
	}

	private String ns() throws IOException {
		while (isWordSeparator(iNextByte)) nextByte();
		StringBuilder sb = new StringBuilder();
		while (iNextByte != -1 && !isWordSeparator(iNextByte)) {
			sb.append((char) iNextByte);
			nextByte();
		}
		return sb.toString();
	}

	private String[] ns(int n) throws IOException {
		String a[] = new String[n];
		for (int i = 0; i < n; ++i) a[i] = ns();
		return a;
	}

	private String[][] ns(int r, int c) throws IOException {
		String a[][] = new String[r][c];
		for (int i = 0; i < r; ++i) a[i] = ns(c);
		return a;
	}

	private void flushOutBuf() {
		if (oNextIndex == 0) return;
		try {
			os.write(obuf, 0, oNextIndex);
			os.flush();
			oNextIndex = 0;
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private void puts(String format, Object... args) {
		if (args != null) format = String.format(format, args);
		for (int i = 0, n = format.length(); i < n; ++i) {
			obuf[oNextIndex++] = (byte) format.charAt(i);
			if (oNextIndex >= obufsize) flushOutBuf();
		}
	}

	private <T> void print(T ob) {
		puts(ob + "");
	}

	private void print(String format, Object... args) {
		puts(format, args);
	}

	private <T> void println(T ob) {
		puts(ob + "\n");
	}

	private void println(String format, Object... args) {
		puts(format + "\n", args);
	}

	private <T> void debug(T ob) {
		puts("\u001B[31m" + ob + "\u001B[0m");
	}

	private <T> void debug(String format, Object... args) {
		puts("\u001B[31m" + format + "\u001B[0m", args);
	}

	private <T> void debugln(T ob) {
		puts("\u001B[31m" + ob + "\u001B[0m\n");
	}

	private void debugln(String format, Object... args) {
		puts("\u001B[31m" + format + "\u001B[0m\n", args);
	}

	private void solve() throws Exception {
		char a[] = ns().toCharArray();
		int hasOneBefore = 0, ans = 0;
		for(int i = 0; i < a.length; ++i) {
			char ch = a[i];
			if(a[i] == '1') {
				hasOneBefore = 1;
			} else {
				ans += hasOneBefore;
			}
		}
		println(ans >= 6? "yes":"no");
	}

	private static final boolean inFromFile = false, outToFile = false;
}


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

public class button {
	public static void main(String args[]) throws Exception {
		Scanner in;
		try {
			in = new Scanner(new File("input23.txt"));
		}
		catch (Exception e) {
			in = new Scanner(System.in);
		}
		int n = in.nextInt(), m = in.nextInt(), count = 0;
		while (m > n) {
			count++;
			if (m % 2 == 1) {
				m++;
			}
			else {
				m /= 2;
			}
		}
		count += n - m;
		System.out.println(count);
	}
}


import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        long part = 1 + (n-3)*3 + (n-4)*(n-3);
        p(part);
    }

    static void p(Object str){
        System.out.println(str);
    }
}


import java.util.*;
public class DashaandStairs {

    public static void main(String[]args){
       Scanner sc=new Scanner(System.in);
       int a=sc.nextInt();int b=sc.nextInt();
       if(a==0 && b==0)
           System.out.print("NO");
       else
           if(a==b || a-b==1 || a-b==-1)
                   System.out.print("YES");
            else
            System.out.print("NO");
    }
}


import java.util.Scanner;
public class newYearAndHurry
{
    /*
    public static void main(String[] args)
    {
        Scanner s1=new Scanner(System.in);
        int n=s1.nextInt();
        int k=s1.nextInt();
        int ans=0;
        int sum=5;
        int i=2;
        while(240-k>=sum)
        {
            sum+=5*i;
            i++;
            ans++;
            if(ans> n)
                ans=n;
        }
        System.out.println(ans);
    }*/
    public static void main(String[] args)
    {
        Scanner s1=new Scanner(System.in);
        int n=s1.nextInt();
        int k=s1.nextInt();
        int time=240-k;
        int ans=0;
        int start=1;
        int end=240;
        while(start<=end)
        {
            int middle=(start+end)/2;
            int sum= 5 * (middle) *(middle+1) / 2;
            if (time>=sum)
            {
                //System.out.println(sum);
                start=middle+1;
                ans=start;
            }
            else
            {
                end=middle-1;
            }
        }
        if (ans>n)
            ans=n+1;
        if (ans<=0)
            ans=1;
        System.out.println(ans-1);
    }

}


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

public class B {
	private Scanner in;
	private PrintWriter out;
//	private String INPUT = "31.12.18\n01.01.01";
//	private String INPUT = "01.01.98\n01.01.80";
//	private String INPUT = "29.02.96\n29.02.04";
//	private String INPUT = "20.10.20\n09.02.30";
//	private String INPUT = "01.03.74\n29.02.56";
	private String INPUT = "";

	public void solve()
	{
		String[] ds = in.next().split("\\.");
		String[] db = in.next().split("\\.");

		int dd = Integer.parseInt(ds[0]);
		int mm = Integer.parseInt(ds[1]);
		int yy = Integer.parseInt(ds[2]);
		int[] t = new int[3];
		for(int i = 0;i < 3;i++)t[i] = Integer.parseInt(db[i]);

		/*
		if(yy < t[2] ||
				(yy == t[2] && mm < t[1]) ||
				(yy == t[2] && mm == t[1] && dd < t[0])){
			out.println("NO");
			return;
		}
		*/

		if(	test(dd, mm, yy, t[0], t[1], t[2]) ||
				test(dd, mm, yy, t[0], t[2], t[1]) ||
				test(dd, mm, yy, t[1], t[0], t[2]) ||
		test(dd, mm, yy, t[1], t[2], t[0]) ||
		test(dd, mm, yy, t[2], t[1], t[0]) ||
		test(dd, mm, yy, t[2], t[0], t[1])){
			out.println("YES");
		}else{
			out.println("NO");
		}
	}

	public boolean test(int dd, int mm, int yy, int bd, int bm, int by)
	{
		if(yy < by + 18)return false;
		if(bm > 12)return false;
		if(bd > 31)return false;

		int[] md = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
		if(by % 4 == 0)md[2]++;
		/*
		if(by % 4 != 0 && bm == 2 && bd == 29){
			bm = 3; bd = 1;
		}
		*/
//		if(yy % 4 != 0 && mm == 2 && dd == 29){
//			mm = 3; dd = 1;
//		}
		if(bd > md[bm])return false;

		if(yy > by + 18)return true;
		if(bm != mm)return mm > bm;
		return dd >= bd;
	}

	public void run() throws Exception
	{
		in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);

		solve();
		out.flush();
	}

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

	private int ni() { return Integer.parseInt(in.next()); }
	private void tr(Object... o) { if(INPUT.length() != 0)System.out.println(o.length > 1 || o[0].getClass().isArray() ? Arrays.deepToString(o) : o[0]); }
}


import java.io.*;

import java.util.*;

/**
 *
 * @author eslam
 */
public class IceCave {

    static class Kattio extends PrintWriter {

        private BufferedReader r;
        private StringTokenizer st;
        // standard input

        public Kattio() {
            this(System.in, System.out);
        }

        public Kattio(InputStream i, OutputStream o) {
            super(o);
            r = new BufferedReader(new InputStreamReader(i));
        }
        // USACO-style file input

        public Kattio(String problemName) throws IOException {
            super(problemName + ".out");
            r = new BufferedReader(new FileReader(problemName + ".in"));
        }
        // returns null if no more input

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

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

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

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

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

    // Beginning of the solution
    static Kattio input = new Kattio();
    static BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
    static ArrayList<ArrayList<Long>> powerSet = new ArrayList<>();
    static long mod = (long) (Math.pow(10, 9) + 7);
    static int dp[][];

    public static void main(String[] args) throws IOException {
        int n = input.nextInt();
        long w = input.nextLong();
        log.write(bfs(w, n) + "\n");
        log.flush();
    }

    public static int bfs(long w, int n) {
        Queue<Long> q = new ArrayDeque<>();
        q.add(w);
        HashMap<Long, Integer> h = new HashMap<>();
        h.put(w, 0);
        int min = Integer.MAX_VALUE;
        while (!q.isEmpty()) {
            long s = q.poll();
            if (n == String.valueOf(s).length()) {
                return h.get(s);
            }
            TreeSet<Integer> t = new TreeSet<>();
            String e = s + "";
            for (int i = 0; i < e.length(); i++) {
                t.add(e.charAt(i) - '0');
            }
            for (Integer x : t) {
                long v = (long) x * s;
                if (String.valueOf(v).length() > n) {
                    continue;
                }
                if (h.get(v) == null) {
                    h.put(v, h.get(s) + 1);
                    q.add(v);
                }
            }
        }
        return min == Integer.MAX_VALUE ? -1 : min;
    }

    public static int log2(long n) {
        int cnt = 0;
        while (n > 1) {
            n /= 2;
            cnt++;
        }
        return cnt;
    }

    public static int[] bfs(int node, ArrayList<Integer> a[]) {
        Queue<Integer> q = new LinkedList<>();
        q.add(node);
        int distances[] = new int[a.length];
        Arrays.fill(distances, -1);
        distances[node] = 0;
        while (!q.isEmpty()) {
            int parent = q.poll();
            ArrayList<Integer> nodes = a[parent];

            int cost = distances[parent];
            for (Integer node1 : nodes) {
                if (distances[node1] == -1) {

                    q.add(node1);
                    distances[node1] = cost + 1;
                }
            }
        }
        return distances;
    }

    public static int get(int n) {
        int sum = 0;
        while (n > 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    public static long primeFactors(int n) {
        long sum = 1;
        while (n % 2 == 0) {
            sum *= 2l;
            n /= 2;
        }
        for (int i = 3; i <= Math.sqrt(n); i += 2) {
            while (n % i == 0) {
                sum *= (long) i;
                n /= i;
            }
            if (n < i) {
                break;
            }
        }
        if (n > 2) {
            sum *= n;
        }
        return sum;
    }

    public static ArrayList<Integer> printPrimeFactoriztion(int n) {
        ArrayList<Integer> a = new ArrayList<>();
        for (int i = 1; i < Math.sqrt(n) + 1; i++) {
            if (n % i == 0) {
                if (isPrime(i)) {
                    a.add(i);
                    n /= i;
                    i = 0;
                } else if (isPrime(n / i)) {
                    a.add(n / i);
                    n = i;
                    i = 0;
                }
            }
        }
        return a;
    }

// end of solution
    public static void genrate(int ind, long[] a, ArrayList<Long> sub) {
        if (ind == a.length) {
            powerSet.add(sub);
            return;
        }
        ArrayList<Long> have = new ArrayList<>();
        ArrayList<Long> less = new ArrayList<>();
        for (int i = 0; i < sub.size(); i++) {
            have.add(sub.get(i));
            less.add(sub.get(i));
        }
        have.add(a[ind]);
        genrate(ind + 1, a, have);
        genrate(ind + 1, a, less);
    }

    public static long factorial(long n) {
        if (n <= 1) {
            return 1;
        }
        long t = n - 1;
        while (t > 1) {
            n *= t;
            t--;
        }
        return n;
    }

    public static boolean isPalindrome(int n) {
        int t = n;
        int ans = 0;
        while (t > 0) {
            ans = ans * 10 + t % 10;
            t /= 10;
        }
        return ans == n;

    }

    static class tri {

        int x, y, z;

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

    }

    static boolean isPrime(long num) {
        if (num == 1) {
            return false;
        }
        if (num == 2) {
            return true;
        }
        if (num % 2 == 0) {
            return false;
        }
        if (num == 3) {
            return true;
        }
        for (int i = 3; i <= Math.sqrt(num) + 1; i += 2) {
            if (num % i == 0) {
                return false;
            }
        }
        return true;
    }

    public static void prefixSum(int[] a) {
        for (int i = 1; i < a.length; i++) {
            a[i] = a[i] + a[i - 1];
        }
    }

    public static void suffixSum(long[] a) {
        for (int i = a.length - 2; i > -1; i--) {
            a[i] = a[i] + a[i + 1];
        }
    }

    static long mod(long a, long b) {
        long r = a % b;
        return r < 0 ? r + b : r;
    }

    public static long binaryToDecimal(String w) {
        long r = 0;
        long l = 0;
        for (int i = w.length() - 1; i > -1; i--) {
            long x = (w.charAt(i) - '0') * (long) Math.pow(2, l);
            r = r + x;
            l++;
        }
        return r;
    }

    public static String decimalToBinary(long n) {
        String w = "";
        while (n > 0) {
            w = n % 2 + w;
            n /= 2;
        }
        return w;
    }

    public static boolean isSorted(int[] a) {
        for (int i = 0; i < a.length - 1; i++) {
            if (a[i] > a[i + 1]) {
                return false;
            }
        }
        return true;
    }

    public static void print(int a[]) throws IOException {
        for (int i = 0; i < a.length; i++) {
            log.write(a[i] + " ");
        }
        log.write("\n");
    }

    public static void read(int[] a) {
        for (int i = 0; i < a.length; i++) {
            a[i] = input.nextInt();

        }
    }

    static class pair {

        long x;
        long y;

        public pair(long x, long y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public String toString() {
            return x + " " + y;
        }
    }

    public static long LCM(long x, long y) {
        return x / GCD(x, y) * y;
    }

    public static long GCD(long x, long y) {
        if (y == 0) {
            return x;
        }
        return GCD(y, x % y);
    }

    public static void simplifyTheFraction(long a, long b) {
        long GCD = GCD(a, b);
        System.out.println(a / GCD + " " + b / GCD);

    }

    /**
     */ // class RedBlackNode
    static class RedBlackNode<T extends Comparable<T>> {

        /**
         * Possible color for this node
         */
        public static final int BLACK = 0;
        /**
         * Possible color for this node
         */
        public static final int RED = 1;
        // the key of each node
        public T key;

        /**
         * Parent of node
         */
        RedBlackNode<T> parent;
        /**
         * Left child
         */
        RedBlackNode<T> left;
        /**
         * Right child
         */
        RedBlackNode<T> right;
        // the number of elements to the left of each node
        public int numLeft = 0;
        // the number of elements to the right of each node
        public int numRight = 0;
        // the color of a node
        public int color;

        RedBlackNode() {
            color = BLACK;
            numLeft = 0;
            numRight = 0;
            parent = null;
            left = null;
            right = null;
        }

        // Constructor which sets key to the argument.
        RedBlackNode(T key) {
            this();
            this.key = key;
        }
    }// end class RedBlackNode

    static class RedBlackTree<T extends Comparable<T>> {

        // Root initialized to nil.
        private RedBlackNode<T> nil = new RedBlackNode<T>();
        private RedBlackNode<T> root = nil;

        public RedBlackTree() {
            root.left = nil;
            root.right = nil;
            root.parent = nil;
        }

        // @param: X, The node which the lefRotate is to be performed on.
        // Performs a leftRotate around X.
        private void leftRotate(RedBlackNode<T> x) {

            // Call leftRotateFixup() which updates the numLeft
            // and numRight values.
            leftRotateFixup(x);

            // Perform the left rotate as described in the algorithm
            // in the course text.
            RedBlackNode<T> y;
            y = x.right;
            x.right = y.left;

            // Check for existence of y.left and make pointer changes
            if (!isNil(y.left)) {
                y.left.parent = x;
            }
            y.parent = x.parent;

            // X's parent is nul
            if (isNil(x.parent)) {
                root = y;
            } // X is the left child of it's parent
            else if (x.parent.left == x) {
                x.parent.left = y;
            } // X is the right child of it's parent.
            else {
                x.parent.right = y;
            }

            // Finish of the leftRotate
            y.left = x;
            x.parent = y;
        }// end leftRotate(RedBlackNode X)

        // @param: X, The node which the leftRotate is to be performed on.
        // Updates the numLeft & numRight values affected by leftRotate.
        private void leftRotateFixup(RedBlackNode x) {

            // Case 1: Only X, X.right and X.right.right always are not nil.
            if (isNil(x.left) && isNil(x.right.left)) {
                x.numLeft = 0;
                x.numRight = 0;
                x.right.numLeft = 1;
            } // Case 2: X.right.left also exists in addition to Case 1
            else if (isNil(x.left) && !isNil(x.right.left)) {
                x.numLeft = 0;
                x.numRight = 1 + x.right.left.numLeft
                        + x.right.left.numRight;
                x.right.numLeft = 2 + x.right.left.numLeft
                        + x.right.left.numRight;
            } // Case 3: X.left also exists in addition to Case 1
            else if (!isNil(x.left) && isNil(x.right.left)) {
                x.numRight = 0;
                x.right.numLeft = 2 + x.left.numLeft + x.left.numRight;

            } // Case 4: X.left and X.right.left both exist in addtion to Case 1
            else {
                x.numRight = 1 + x.right.left.numLeft
                        + x.right.left.numRight;
                x.right.numLeft = 3 + x.left.numLeft + x.left.numRight
                        + x.right.left.numLeft + x.right.left.numRight;
            }

        }// end leftRotateFixup(RedBlackNode X)

        // @param: X, The node which the rightRotate is to be performed on.
        // Updates the numLeft and numRight values affected by the Rotate.
        private void rightRotate(RedBlackNode<T> y) {

            // Call rightRotateFixup to adjust numRight and numLeft values
            rightRotateFixup(y);

            // Perform the rotate as described in the course text.
            RedBlackNode<T> x = y.left;
            y.left = x.right;

            // Check for existence of X.right
            if (!isNil(x.right)) {
                x.right.parent = y;
            }
            x.parent = y.parent;

            // y.parent is nil
            if (isNil(y.parent)) {
                root = x;
            } // y is a right child of it's parent.
            else if (y.parent.right == y) {
                y.parent.right = x;
            } // y is a left child of it's parent.
            else {
                y.parent.left = x;
            }
            x.right = y;

            y.parent = x;

        }// end rightRotate(RedBlackNode y)

        // @param: y, the node around which the righRotate is to be performed.
        // Updates the numLeft and numRight values affected by the rotate
        private void rightRotateFixup(RedBlackNode y) {

            // Case 1: Only y, y.left and y.left.left exists.
            if (isNil(y.right) && isNil(y.left.right)) {
                y.numRight = 0;
                y.numLeft = 0;
                y.left.numRight = 1;
            } // Case 2: y.left.right also exists in addition to Case 1
            else if (isNil(y.right) && !isNil(y.left.right)) {
                y.numRight = 0;
                y.numLeft = 1 + y.left.right.numRight
                        + y.left.right.numLeft;
                y.left.numRight = 2 + y.left.right.numRight
                        + y.left.right.numLeft;
            } // Case 3: y.right also exists in addition to Case 1
            else if (!isNil(y.right) && isNil(y.left.right)) {
                y.numLeft = 0;
                y.left.numRight = 2 + y.right.numRight + y.right.numLeft;

            } // Case 4: y.right & y.left.right exist in addition to Case 1
            else {
                y.numLeft = 1 + y.left.right.numRight
                        + y.left.right.numLeft;
                y.left.numRight = 3 + y.right.numRight
                        + y.right.numLeft
                        + y.left.right.numRight + y.left.right.numLeft;
            }

        }// end rightRotateFixup(RedBlackNode y)

        public void insert(T key) {
            insert(new RedBlackNode<T>(key));
        }

        // @param: z, the node to be inserted into the Tree rooted at root
        // Inserts z into the appropriate position in the RedBlackTree while
        // updating numLeft and numRight values.
        private void insert(RedBlackNode<T> z) {

            // Create a reference to root & initialize a node to nil
            RedBlackNode<T> y = nil;
            RedBlackNode<T> x = root;

            // While we haven't reached a the end of the tree keep
            // tryint to figure out where z should go
            while (!isNil(x)) {
                y = x;

                // if z.key is < than the current key, go left
                if (z.key.compareTo(x.key) < 0) {

                    // Update X.numLeft as z is < than X
                    x.numLeft++;
                    x = x.left;
                } // else z.key >= X.key so go right.
                else {

                    // Update X.numGreater as z is => X
                    x.numRight++;
                    x = x.right;
                }
            }
            // y will hold z's parent
            z.parent = y;

            // Depending on the value of y.key, put z as the left or
            // right child of y
            if (isNil(y)) {
                root = z;
            } else if (z.key.compareTo(y.key) < 0) {
                y.left = z;
            } else {
                y.right = z;
            }

            // Initialize z's children to nil and z's color to red
            z.left = nil;
            z.right = nil;
            z.color = RedBlackNode.RED;

            // Call insertFixup(z)
            insertFixup(z);

        }// end insert(RedBlackNode z)

        // @param: z, the node which was inserted and may have caused a violation
        // of the RedBlackTree properties
        // Fixes up the violation of the RedBlackTree properties that may have
        // been caused during insert(z)
        private void insertFixup(RedBlackNode<T> z) {

            RedBlackNode<T> y = nil;
            // While there is a violation of the RedBlackTree properties..
            while (z.parent.color == RedBlackNode.RED) {

                // If z's parent is the the left child of it's parent.
                if (z.parent == z.parent.parent.left) {

                    // Initialize y to z 's cousin
                    y = z.parent.parent.right;

                    // Case 1: if y is red...recolor
                    if (y.color == RedBlackNode.RED) {
                        z.parent.color = RedBlackNode.BLACK;
                        y.color = RedBlackNode.BLACK;
                        z.parent.parent.color = RedBlackNode.RED;
                        z = z.parent.parent;
                    } // Case 2: if y is black & z is a right child
                    else if (z == z.parent.right) {

                        // leftRotaet around z's parent
                        z = z.parent;
                        leftRotate(z);
                    } // Case 3: else y is black & z is a left child
                    else {
                        // recolor and rotate round z's grandpa
                        z.parent.color = RedBlackNode.BLACK;
                        z.parent.parent.color = RedBlackNode.RED;
                        rightRotate(z.parent.parent);
                    }
                } // If z's parent is the right child of it's parent.
                else {

                    // Initialize y to z's cousin
                    y = z.parent.parent.left;

                    // Case 1: if y is red...recolor
                    if (y.color == RedBlackNode.RED) {
                        z.parent.color = RedBlackNode.BLACK;
                        y.color = RedBlackNode.BLACK;
                        z.parent.parent.color = RedBlackNode.RED;
                        z = z.parent.parent;
                    } // Case 2: if y is black and z is a left child
                    else if (z == z.parent.left) {
                        // rightRotate around z's parent
                        z = z.parent;
                        rightRotate(z);
                    } // Case 3: if y  is black and z is a right child
                    else {
                        // recolor and rotate around z's grandpa
                        z.parent.color = RedBlackNode.BLACK;
                        z.parent.parent.color = RedBlackNode.RED;
                        leftRotate(z.parent.parent);
                    }
                }
            }
            // Color root black at all times
            root.color = RedBlackNode.BLACK;

        }// end insertFixup(RedBlackNode z)

        // @param: node, a RedBlackNode
        // @param: node, the node with the smallest key rooted at node
        public RedBlackNode<T> treeMinimum(RedBlackNode<T> node) {

            // while there is a smaller key, keep going left
            while (!isNil(node.left)) {
                node = node.left;
            }
            return node;
        }// end treeMinimum(RedBlackNode node)

        // @param: X, a RedBlackNode whose successor we must find
        // @return: return's the node the with the next largest key
        // from X.key
        public RedBlackNode<T> treeSuccessor(RedBlackNode<T> x) {

            // if X.left is not nil, call treeMinimum(X.right) and
            // return it's value
            if (!isNil(x.left)) {
                return treeMinimum(x.right);
            }

            RedBlackNode<T> y = x.parent;

            // while X is it's parent's right child...
            while (!isNil(y) && x == y.right) {
                // Keep moving up in the tree
                x = y;
                y = y.parent;
            }
            // Return successor
            return y;
        }// end treeMinimum(RedBlackNode X)

        // @param: z, the RedBlackNode which is to be removed from the the tree
        // Remove's z from the RedBlackTree rooted at root
        public void remove(RedBlackNode<T> v) {

            RedBlackNode<T> z = search(v.key);

            // Declare variables
            RedBlackNode<T> x = nil;
            RedBlackNode<T> y = nil;

            // if either one of z's children is nil, then we must remove z
            if (isNil(z.left) || isNil(z.right)) {
                y = z;
            } // else we must remove the successor of z
            else {
                y = treeSuccessor(z);
            }

            // Let X be the left or right child of y (y can only have one child)
            if (!isNil(y.left)) {
                x = y.left;
            } else {
                x = y.right;
            }

            // link X's parent to y's parent
            x.parent = y.parent;

            // If y's parent is nil, then X is the root
            if (isNil(y.parent)) {
                root = x;
            } // else if y is a left child, set X to be y's left sibling
            else if (!isNil(y.parent.left) && y.parent.left == y) {
                y.parent.left = x;
            } // else if y is a right child, set X to be y's right sibling
            else if (!isNil(y.parent.right) && y.parent.right == y) {
                y.parent.right = x;
            }

            // if y != z, trasfer y's satellite data into z.
            if (y != z) {
                z.key = y.key;
            }

            // Update the numLeft and numRight numbers which might need
            // updating due to the deletion of z.key.
            fixNodeData(x, y);

            // If y's color is black, it is a violation of the
            // RedBlackTree properties so call removeFixup()
            if (y.color == RedBlackNode.BLACK) {
                removeFixup(x);
            }
        }// end remove(RedBlackNode z)

        // @param: y, the RedBlackNode which was actually deleted from the tree
        // @param: key, the value of the key that used to be in y
        private void fixNodeData(RedBlackNode<T> x, RedBlackNode<T> y) {

            // Initialize two variables which will help us traverse the tree
            RedBlackNode<T> current = nil;
            RedBlackNode<T> track = nil;

            // if X is nil, then we will start updating at y.parent
            // Set track to y, y.parent's child
            if (isNil(x)) {
                current = y.parent;
                track = y;
            } // if X is not nil, then we start updating at X.parent
            // Set track to X, X.parent's child
            else {
                current = x.parent;
                track = x;
            }

            // while we haven't reached the root
            while (!isNil(current)) {
                // if the node we deleted has a different key than
                // the current node
                if (y.key != current.key) {

                    // if the node we deleted is greater than
                    // current.key then decrement current.numRight
                    if (y.key.compareTo(current.key) > 0) {
                        current.numRight--;
                    }

                    // if the node we deleted is less than
                    // current.key thendecrement current.numLeft
                    if (y.key.compareTo(current.key) < 0) {
                        current.numLeft--;
                    }
                } // if the node we deleted has the same key as the
                // current node we are checking
                else {
                    // the cases where the current node has any nil
                    // children and update appropriately
                    if (isNil(current.left)) {
                        current.numLeft--;
                    } else if (isNil(current.right)) {
                        current.numRight--;
                    } // the cases where current has two children and
                    // we must determine whether track is it's left
                    // or right child and update appropriately
                    else if (track == current.right) {
                        current.numRight--;
                    } else if (track == current.left) {
                        current.numLeft--;
                    }
                }

                // update track and current
                track = current;
                current = current.parent;

            }

        }//end fixNodeData()

        // @param: X, the child of the deleted node from remove(RedBlackNode v)
        // Restores the Red Black properties that may have been violated during
        // the removal of a node in remove(RedBlackNode v)
        private void removeFixup(RedBlackNode<T> x) {

            RedBlackNode<T> w;

            // While we haven't fixed the tree completely...
            while (x != root && x.color == RedBlackNode.BLACK) {

                // if X is it's parent's left child
                if (x == x.parent.left) {

                    // set w = X's sibling
                    w = x.parent.right;

                    // Case 1, w's color is red.
                    if (w.color == RedBlackNode.RED) {
                        w.color = RedBlackNode.BLACK;
                        x.parent.color = RedBlackNode.RED;
                        leftRotate(x.parent);
                        w = x.parent.right;
                    }

                    // Case 2, both of w's children are black
                    if (w.left.color == RedBlackNode.BLACK
                            && w.right.color == RedBlackNode.BLACK) {
                        w.color = RedBlackNode.RED;
                        x = x.parent;
                    } // Case 3 / Case 4
                    else {
                        // Case 3, w's right child is black
                        if (w.right.color == RedBlackNode.BLACK) {
                            w.left.color = RedBlackNode.BLACK;
                            w.color = RedBlackNode.RED;
                            rightRotate(w);
                            w = x.parent.right;
                        }
                        // Case 4, w = black, w.right = red
                        w.color = x.parent.color;
                        x.parent.color = RedBlackNode.BLACK;
                        w.right.color = RedBlackNode.BLACK;
                        leftRotate(x.parent);
                        x = root;
                    }
                } // if X is it's parent's right child
                else {

                    // set w to X's sibling
                    w = x.parent.left;

                    // Case 1, w's color is red
                    if (w.color == RedBlackNode.RED) {
                        w.color = RedBlackNode.BLACK;
                        x.parent.color = RedBlackNode.RED;
                        rightRotate(x.parent);
                        w = x.parent.left;
                    }

                    // Case 2, both of w's children are black
                    if (w.right.color == RedBlackNode.BLACK
                            && w.left.color == RedBlackNode.BLACK) {
                        w.color = RedBlackNode.RED;
                        x = x.parent;
                    } // Case 3 / Case 4
                    else {
                        // Case 3, w's left child is black
                        if (w.left.color == RedBlackNode.BLACK) {
                            w.right.color = RedBlackNode.BLACK;
                            w.color = RedBlackNode.RED;
                            leftRotate(w);
                            w = x.parent.left;
                        }

                        // Case 4, w = black, and w.left = red
                        w.color = x.parent.color;
                        x.parent.color = RedBlackNode.BLACK;
                        w.left.color = RedBlackNode.BLACK;
                        rightRotate(x.parent);
                        x = root;
                    }
                }
            }// end while

            // set X to black to ensure there is no violation of
            // RedBlack tree Properties
            x.color = RedBlackNode.BLACK;
        }// end removeFixup(RedBlackNode X)

        // @param: key, the key whose node we want to search for
        // @return: returns a node with the key, key, if not found, returns null
        // Searches for a node with key k and returns the first such node, if no
        // such node is found returns null
        public RedBlackNode<T> search(T key) {

            // Initialize a pointer to the root to traverse the tree
            RedBlackNode<T> current = root;

            // While we haven't reached the end of the tree
            while (!isNil(current)) {

                // If we have found a node with a key equal to key
                if (current.key.equals(key)) // return that node and exit search(int)
                {
                    return current;
                } // go left or right based on value of current and key
                else if (current.key.compareTo(key) < 0) {
                    current = current.right;
                } // go left or right based on value of current and key
                else {
                    current = current.left;
                }
            }

            // we have not found a node whose key is "key"
            return null;

        }// end search(int key)

        // @param: key, any Comparable object
        // @return: return's the number of elements greater than key
        public int numGreater(T key) {

            // Call findNumGreater(root, key) which will return the number
            // of nodes whose key is greater than key
            return findNumGreater(root, key);

        }// end numGreater(int key)

        // @param: key, any Comparable object
        // @return: return's teh number of elements smaller than key
        public int numSmaller(T key) {

            // Call findNumSmaller(root,key) which will return
            // the number of nodes whose key is greater than key
            return findNumSmaller(root, key);

        }// end numSmaller(int key)

        // @param: node, the root of the tree, the key who we must
        // compare other node key's to.
        // @return: the number of nodes greater than key.
        public int findNumGreater(RedBlackNode<T> node, T key) {

            // Base Case: if node is nil, return 0
            if (isNil(node)) {
                return 0;
            } // If key is less than node.key, all elements right of node are
            // greater than key, add this to our total and look to the left
            else if (key.compareTo(node.key) < 0) {
                return 1 + node.numRight + findNumGreater(node.left, key);
            } // If key is greater than node.key, then look to the right as
            // all elements to the left of node are smaller than key
            else {
                return findNumGreater(node.right, key);
            }

        }// end findNumGreater(RedBlackNode, int key)

        /**
         * Returns sorted list of keys greater than key. Size of list will not
         * exceed maxReturned
         *
         * @param key Key to search for
         * @param maxReturned Maximum number of results to return
         * @return List of keys greater than key. List may not exceed
         * maxReturned
         */
        public List<T> getGreaterThan(T key, Integer maxReturned) {
            List<T> list = new ArrayList<T>();
            getGreaterThan(root, key, list);
            return list.subList(0, Math.min(maxReturned, list.size()));
        }

        private void getGreaterThan(RedBlackNode<T> node, T key,
                List<T> list) {
            if (isNil(node)) {
                return;
            } else if (node.key.compareTo(key) > 0) {
                getGreaterThan(node.left, key, list);
                list.add(node.key);
                getGreaterThan(node.right, key, list);
            } else {
                getGreaterThan(node.right, key, list);
            }
        }

        // @param: node, the root of the tree, the key who we must compare other
        // node key's to.
        // @return: the number of nodes smaller than key.
        public int findNumSmaller(RedBlackNode<T> node, T key) {

            // Base Case: if node is nil, return 0
            if (isNil(node)) {
                return 0;
            } // If key is less than node.key, look to the left as all
            // elements on the right of node are greater than key
            else if (key.compareTo(node.key) <= 0) {
                return findNumSmaller(node.left, key);
            } // If key is larger than node.key, all elements to the left of
            // node are smaller than key, add this to our total and look
            // to the right.
            else {
                return 1 + node.numLeft + findNumSmaller(node.right, key);
            }

        }// end findNumSmaller(RedBlackNode nod, int key)

        // @param: node, the RedBlackNode we must check to see whether it's nil
        // @return: return's true of node is nil and false otherwise
        private boolean isNil(RedBlackNode node) {

            // return appropriate value
            return node == nil;

        }// end isNil(RedBlackNode node)

        // @return: return's the size of the tree
        // Return's the # of nodes including the root which the RedBlackTree
        // rooted at root has.
        public int size() {

            // Return the number of nodes to the root's left + the number of
            // nodes on the root's right + the root itself.
            return root.numLeft + root.numRight + 1;
        }// end size()

    }// end class RedBlackTree
}


import java.util.Scanner;

public class CollectingBeatsisFun {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt()*2;
        int[] a = new int[10];
        for (int i = 0; i < 4; i++) {
            String s = scan.next();
            for (int j = 0; j < 4; j++) {
                if(s.charAt(j)!='.'){

                    ++a[s.charAt(j)-'0'];
                }
            }
        }
        for (int i = 0; i < 10; i++) {
            if(a[i]>n){

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

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

}


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

public class Main143A
{
  static PrintWriter out=new PrintWriter(System.out);
  public static boolean check(int x,int y,int z,int p)
  {
    return x!=y&&z!=p&&x!=p&&y!=z&&x!=z&&y!=p;
  }

  public static void main(String[] args) throws IOException
  {
    Scanner sc=new Scanner(System.in);
    int r1=sc.nextInt();
    int r2=sc.nextInt();
    int c1=sc.nextInt();
    int c2=sc.nextInt();
    int d1=sc.nextInt();
    int d2=sc.nextInt();
    int x=0,y=0,z=0,p=0;
    boolean flag=false;
    for(x=1;x<=9;x++)
    {
      for(y=1;y<=9;y++)
      {
        for(z=1;z<=9;z++)
        {
          for(p=1;p<=9;p++)
          {
            if((x+y)==r1&&(x+z)==c1&&(y+p)==c2&&(z+p)==r2&&(x+p)==d1&&(y+z)==d2&&check(x,y,z,p))
            {
              flag=true;
              break;
            }
          }
          if(flag) break;
        }
        if(flag) break;
      }
      if(flag) break;
    }
    if(flag)
    {
      out.println(x+" "+y);
      out.println(z+" "+p);
    }
    else
      out.println(-1);
    out.flush();

  }
  static class Scanner
  {
    BufferedReader br;
    StringTokenizer tk=new StringTokenizer("");
    public Scanner(InputStream is)
        {
      br=new BufferedReader(new InputStreamReader(is));
    }
        public int nextInt() throws IOException
        {
          if(tk.hasMoreTokens())
                return Integer.parseInt(tk.nextToken());
          tk=new StringTokenizer(br.readLine());
          return nextInt();
        }
        public long nextLong() throws IOException
        {
            if(tk.hasMoreTokens())
              return Long.parseLong(tk.nextToken());
            tk=new StringTokenizer(br.readLine());
            return nextLong();
        }
        public String next() throws IOException
        {
          if(tk.hasMoreTokens())
            return (tk.nextToken());
            tk=new StringTokenizer(br.readLine());
            return next();
        }
        public String nextLine() throws IOException
        {
          tk=new StringTokenizer("");
          return br.readLine();
        }
        public double nextDouble() throws IOException
        {
            if(tk.hasMoreTokens())
              return Double.parseDouble(tk.nextToken());
            tk=new StringTokenizer(br.readLine());
            return nextDouble();
        }
        public char nextChar() throws IOException
        {
            if(tk.hasMoreTokens())
              return (tk.nextToken().charAt(0));
            tk=new StringTokenizer(br.readLine());
            return nextChar();
        }
        public int[] nextIntArray(int n) throws IOException
        {
            int a[]=new int[n];
            for(int i=0;i<n;i++)
              a[i]=nextInt();
            return a;
        }
        public long[] nextLongArray(int n) throws IOException
        {
          long a[]=new long[n];
            for(int i=0;i<n;i++)
              a[i]=nextLong();
            return a;
        }
        public int[] nextIntArrayOneBased(int n) throws IOException
        {
          int a[]=new int[n+1];
            for(int i=1;i<=n;i++)
              a[i]=nextInt();
            return a;
        }
        public long[] nextLongArrayOneBased(int n) throws IOException
        {
          long a[]=new long[n+1];
          for(int i=1;i<=n;i++)
                a[i]=nextLong();
          return a;
        }
  }
}


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

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

    static class TaskB {
        private char[][] grid = new char[10][10];

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            for (int i = 0; i < 10; i++) {
                String s = in.readLine();
                for (int j = 0; j < 10; j++) {
                    grid[i][j] = s.charAt(j);
                }
            }

            for (int i = 0; i < 10; i++)
                for (int j = 0; j < 10; j++)
                    if (ok(i, j)) {
                        out.print("YES");
                        return;
                    }

            out.print("NO");
        }

        private boolean isOk(int x, int y) {
            return x >= 0 && x < 10 && y >= 0 && y < 10;
        }

        private boolean okD1(int x, int y) {
            for (int i = 1; i <= 4; i++) {
                if (!isOk(x - i, y + i)) return false;
            }
            int cX = 0, cE = 0;
            for (int i = 0; i <= 4; i++) {
                if (grid[x - i][y + i] == 'X') cX++;
                if (grid[x - i][y + i] == '.') cE++;
            }
            return cX == 4 && cE == 1;
        }

        private boolean okD2(int x, int y) {
            for (int i = 1; i <= 4; i++) {
                if (!isOk(x + i, y + i)) return false;
            }
            int cX = 0, cE = 0;
            for (int i = 0; i <= 4; i++) {
                if (grid[x + i][y + i] == 'X') cX++;
                if (grid[x + i][y + i] == '.') cE++;
            }
            return cX == 4 && cE == 1;
        }

        private boolean okD3(int x, int y) {
            for (int i = 1; i <= 4; i++) {
                if (!isOk(x + i, y - i)) return false;
            }
            int cX = 0, cE = 0;
            for (int i = 0; i <= 4; i++) {
                if (grid[x + i][y - i] == 'X') cX++;
                if (grid[x + i][y - i] == '.') cE++;
            }
            return cX == 4 && cE == 1;
        }

        private boolean okD4(int x, int y) {
            for (int i = 1; i <= 4; i++) {
                if (!isOk(x - i, y - i)) return false;
            }
            int cX = 0, cE = 0;
            for (int i = 0; i <= 4; i++) {
                if (grid[x - i][y - i] == 'X') cX++;
                if (grid[x - i][y - i] == '.') cE++;
            }
            return cX == 4 && cE == 1;
        }

        private boolean okV1(int x, int y) {
            for (int i = 1; i <= 4; i++) {
                if (!isOk(x - i, y)) return false;
            }
            int cX = 0, cE = 0;
            for (int i = 0; i <= 4; i++) {
                if (grid[x - i][y] == 'X') cX++;
                if (grid[x - i][y] == '.') cE++;
            }
            return cX == 4 && cE == 1;
        }

        private boolean okV2(int x, int y) {
            for (int i = 1; i <= 4; i++) {
                if (!isOk(x + i, y)) return false;
            }
            int cX = 0, cE = 0;
            for (int i = 0; i <= 4; i++) {
                if (grid[x + i][y] == 'X') cX++;
                if (grid[x + i][y] == '.') cE++;
            }
            return cX == 4 && cE == 1;
        }

        private boolean okH1(int x, int y) {
            for (int i = 1; i <= 4; i++) {
                if (!isOk(x, y - i)) return false;
            }
            int cX = 0, cE = 0;
            for (int i = 0; i <= 4; i++) {
                if (grid[x][y - i] == 'X') cX++;
                if (grid[x][y - i] == '.') cE++;
            }
            return cX == 4 && cE == 1;
        }

        private boolean okH2(int x, int y) {
            for (int i = 1; i <= 4; i++) {
                if (!isOk(x, y + i)) return false;
            }
            int cX = 0, cE = 0;
            for (int i = 0; i <= 4; i++) {
                if (grid[x][y + i] == 'X') cX++;
                if (grid[x][y + i] == '.') cE++;
            }
            return cX == 4 && cE == 1;
        }

        private boolean ok(int x, int y) {
            return okD1(x, y) || okD2(x, y) || okD3(x, y) || okD4(x, y) || okV1(x, y) || okV2(x, y) || okH1(x, y) || okH2(x, y);
        }

    }

    static class InputReader extends BufferedReader {
        public InputReader(InputStream in) {
            super(new InputStreamReader(in));
        }

        public void close() {
            try {
                super.close();
            } catch (Exception e) {
                System.err.println(Arrays.toString(e.getStackTrace()));
            }
        }

        public String readLine() {
            String s = null;
            try {
                s = super.readLine();
            } catch (Exception e) {
                System.err.println(Arrays.toString(e.getStackTrace()));
            }
            return s;
        }

    }
}


import java.io.*;
import java.util.*;
/**
 * @author Alvex - GoldenReam1503@gmail.com
 * Time: 10:41:13 AM
 * Date: Nov 15, 2015
 */
public class _255A_Gregs_Workout
{
    private static class Output
    {
        private final PrintWriter printer;
        public void printLine(Object...objects)
        {
            print(objects);
            printer.println();
        }
        public void print(Object...objects)
        {
            int i;
            for (i=0;i<objects.length;i++)
            {
                if (i!=0)
                    printer.print(' ');
                printer.print(objects[i]);
            }
        }
        public Output(OutputStream outputStream)
        {
            printer= new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }
        public void flush()
        {
            printer.flush();
        }
        public void close()
        {
            printer.close();
        }
    }
    private static class Input
    {
        private InputStream stream;
        private byte Buffer[]=new byte[1024];
        private int curChar;
        private int numberChars;
        private SpaceCharFilter filter;
        public interface SpaceCharFilter
        {
            public boolean isSpaceChar(int ch);
        }
        public Input(InputStream stream)
        {
            this.stream=stream;
        }
        public static boolean isWhitespace(int c)
        {
            boolean flag=false;
            if(c==' '|| c=='\n' || c=='\r' || c=='\t' || c==-1)
                flag=true;
            return flag;
        }
        public boolean isSpaceChar(int c)
        {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }
        public int read()
        {
            if (numberChars==-1)
                throw new InputMismatchException();
            if (curChar>=numberChars)
            {
                curChar = 0;
                try
                {
                    numberChars = stream.read(Buffer);
                }
                catch (IOException e)
                {
                    throw new InputMismatchException();
                }
                if (numberChars <= 0)
                    return -1;
            }
            return Buffer[curChar++];
        }
        public int readInt()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }
    }
    public static void main(String[] args)
    {
        Input in=new Input(System.in);
        Output out=new Output(System.out);
        int n=in.readInt();
        int a[]=new int[n],i;
        Map<Integer, String> muscle=new LinkedHashMap<>();
        for(i=0;i<n;i++)
            a[i]=in.readInt();
        int chest=0;
        int biceps=0;
        int back=0;
        for(i=0;i<n;i+=3)
            chest+=a[i];
        for(i=1;i<n;i+=3)
            biceps+=a[i];
        for(i=2;i<n;i+=3)
            back+=a[i];
        muscle.put(chest, "chest");
        muscle.put(biceps, "biceps");
        muscle.put(back, "back");
        int max=0;
        if(chest>biceps)
            max=chest;
        else
            max=biceps;
        if(max<back)
            max=back;
        out.printLine(muscle.get(max));
        out.flush();
        out.close();
    }
}


import java.util.Scanner;

public class CODEF {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] c = s.toCharArray();

        boolean flag = false;
        int i = c.length -1;

        if(c.length >=10) {
            if (c[0] == 'C') {
                if (c[1] == 'O') {
                    if (c[2] == 'D') {
                        if (c[3] == 'E') {
                            if (c[4] == 'F') {
                                if (c[5] == 'O') {
                                    if (c[6] == 'R') {
                                        if (c[7] == 'C') {
                                            if (c[8] == 'E') {
                                                if (c[9] == 'S') {
                                                    {flag = true;}
                                                }
                                                else if(c[i] == 'S'){
                                                    {flag = true;}
                                                }
                                            }
                                            else if(c[i] == 'S' && c[i-1]=='E'){
                                                {flag = true;}
                                            }
                                        }
                                        else if(c[i] == 'S' && c[i-1]=='E'
                                                && c[i-2] == 'C'){
                                            {flag = true;}
                                        }
                                    }
                                    else if(c[i] == 'S' && c[i-1]=='E'
                                            && c[i-2] == 'C' && c[i-3] == 'R'){
                                        {flag = true;}
                                    }
                                }
                                else if(c[i] == 'S' && c[i-1]=='E'
                                        && c[i-2] == 'C' && c[i-3] == 'R'
                                        && c[i-4] == 'O'){
                                    {flag = true;}
                                }
                            }
                            else if(c[i] == 'S' && c[i-1]=='E'
                                    && c[i-2] == 'C' && c[i-3] == 'R'
                                    && c[i-4] == 'O' && c[i -5] == 'F'){
                                {flag = true;}
                            }
                        }
                        else if(c[i] == 'S' && c[i-1]=='E'
                                && c[i-2] == 'C' && c[i-3] == 'R'
                                && c[i-4] == 'O' && c[i -5] == 'F'
                                && c[i-6] == 'E'){
                            {flag = true;}
                        }
                    }
                    else if(c[i] == 'S' && c[i-1]=='E'
                            && c[i-2] == 'C' && c[i-3] == 'R'
                            && c[i-4] == 'O' && c[i -5] == 'F'
                            && c[i-6] == 'E' && c[i-7] =='D'){
                        {flag = true;}
                    }
                }
                else if(c[i] == 'S' && c[i-1]=='E'
                        && c[i-2] == 'C' && c[i-3] == 'R'
                        && c[i-4] == 'O' && c[i-5] == 'F'
                        && c[i-6] == 'E' && c[i-7] =='D'
                        && c[i-8] == 'O'){
                    {flag = true;}
                }
            }
            else if(c[i] == 'S' && c[i-1]=='E'
                    && c[i-2] == 'C' && c[i-3] == 'R'
                    && c[i-4] == 'O' && c[i-5] == 'F'
                    && c[i-6] == 'E' && c[i-7] =='D'
                    && c[i-8] == 'O' && c[i -9] == 'C'){
                {flag = true;}
            }
        }
        if(flag){
            System.out.println("YES");
        }
        else{
            System.out.println("NO");
        }

    }
}


// package CF1076;

import java.util.Scanner;

public class CF1076B {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long m = s.nextLong();
        long ans;
        if (m % 2 == 0) {
            ans = m / 2;
        } else {
            long p = primeFactors(m);
            ans = (m - p) / 2 + 1;
        }
        System.out.println(ans);
    }

    public static long primeFactors(long n) {
        // Print the number of 2s that divide n

        while (n % 2 == 0) {
            return 2;
        }

        // n must be odd at this point.  So we can
        // skip one element (Note i = i +2)
        for (long i = 3; i <= Math.sqrt(n); i += 2) {
            // While i divides n, print i and divide n
            while (n % i == 0) {
                return i;
            }
        }

        // This condition is to handle the case whien
        // n is a prime number greater than 2
        if (n > 2)
            return n;

        return -1;
    }

}


import java.util.Scanner;

//527A
public class asd {

    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long a = in.nextLong();
        long b = in.nextLong();
        in.close();
        long s = 1;

        while(true){
            if(a==b){
                System.out.println(s);
                break;
            }

            if(a==1){
                System.out.println(b+s-1);
                break;
            }
            else if(b==1){
                System.out.println(a+s-1);
                break;
            }
            /*
            if(a<b){
                s++;
                b-=a;
            }
            else if(a>b){
                s++;
                a-=b;
            }
            */

            if(a<b){
                long k = b/a;
                s+=k;
                b-=(k*a);
            }
            else if(a>b){
                long k = a/b;
                s+=k;
                a-=(k*b);
            }

            if (a==0 || b==0){
                System.out.println(s-1);
                break;
            }
        }
    }

}


/**
 * recursion
 */
import java.util.*;

import javax.lang.model.util.ElementScanner6;
public class recursion {
static boolean check(int t){
    String m=""+t;
    HashSet<Character>H=new HashSet<>();
    for(char ch:m.toCharArray()){
        if(H.contains(ch)){
            return false;
        }
        else
        H.add(ch);
    }

    return true;
}
    public static void main(String[] args) {
    //intitalise the matrix to the on state
    int a[][]={
          {1,1,1},
          {1,1,1},
          {1,1,1}
    };
 Scanner scan=new Scanner(System.in);
 int b[][]=new int[3][3];
 for(int i=0;i<3;++i){
     for(int j=0;j<3;++j){
         b[i][j]=scan.nextInt();
     }
 }
 //changing the states
 for(int i=0;i<3;++i){
     for(int j=0;j<3;++j){
         if(b[i][j]!=0){
             int temp=b[i][j];
             if(b[i][j]%2==1){
                   if(a[i][j]==1){
                       a[i][j]=0;
                   }
                   else
                   a[i][j]=1;

                     if(j+1<a[0].length){
                         if(a[i][j+1]==1){
                             a[i][j+1]=0;
                         }
                         else
                         a[i][j+1]=1;
                     }

                  if(j-1>=0){
                     if(a[i][j-1]==1){
                         a[i][j-1]=0;
                     }
                     else
                     a[i][j-1]=1;
                 }

                if(i-1>=0){

                    if(a[i-1][j]==1){
                        a[i-1][j]=0;
                    }
                    else
                    a[i-1][j]=1;
                }

                if(i+1<a.length){
                    if(a[i+1][j]==1){
                        a[i+1][j]=0;
                    }
                    else
                    a[i+1][j]=1;
                }

             }

         }
     }
 }
 for(int i=0;i<3;++i){
    for(int j=0;j<3;++j){
       System.out.print(a[i][j]);
    }
    System.out.println();
}

    }
}