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

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

    static class polycarpandletters {
        public void solve(int testNumber, InputReader scan, OutputWriter out) {
            int n = scan.nextInt();
            String s = scan.next();
            String[] array = s.split("[A-Z]{1,}");
            int max = 0;
            HashSet<Character> set = new HashSet<>();
            for (String a : array) {
                for (int i = 0; i < a.length(); i++) {
                    set.add(a.charAt(i));
                }
                max = Math.max(set.size(), max);
//            out.println(a);
                set.clear();
            }
            out.println(max);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

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

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

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

        public void println(int i) {
            writer.println(i);
        }

    }

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

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

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

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

        public String nextString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

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

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

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

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

        }

    }
}


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

public class Main {
	static long mod = 1000000007;
	public static void main(String[] args) {
		long[][] c = new long[101][101];
		c[0][0] = 1;
		for(int i = 1; i <= 100; i++)
		for(int x = 0; x <= 100; x++)
			c[i][x] = ((x - 1 >= 0 ? c[i - 1][x - 1] : 0) + c[i - 1][x]) % mod;

		Scanner r = new Scanner(System.in);

		int NN = r.nextInt();

		int[] a = new int[10];
		for(int i = 0; i < 10; i++)
			a[i] = r.nextInt();

		int s = 0;
		for(int i = 0; i < 10; i++)
			s += a[i];

		long ret = 0;

		if(s == 0)ret += 9;
		else if(s == 1)ret++;

		for(int x = 1; x <= 9; x++){
			int[] b = a.clone();
			b[x] = Math.max(0, b[x] - 1);

			long[][] dp = new long[11][NN + 1];
			dp[0][0] = 1;

			for(int i = 0; i <= 9; i++)
			for(int rem = 0; rem <= NN; rem++)
			for(int z = b[i]; z <= rem; z++){
				dp[i + 1][rem] += c[rem][z] * dp[i][rem - z];
				dp[i + 1][rem] %= mod;
			}

			for(int N = 2; N <= NN; N++){
				ret += dp[10][N - 1];
				ret %= mod;
			}
		}

		System.out.println(ret);
	}
}


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

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

    static class TaskA
    {
        public void solve(int testNumber, FastScanner in, FastPrinter out)
        {
            long n = in.nextLong();
            long low = 0;
            long high = 14142136;
            while (high - low > 1)
            {
                long mid = low + (high - low) / 2;
                long last = mid * (mid + 1);
                last /= 2;
                if (last <= n)
                {
                    low = mid;
                } else
                {
                    high = mid;
                }
            }
            long last = low * (low + 1);
            last /= 2;
            if (last == n)
            {
                out.println(low);
                return;
            }
            out.println(n - last);
//

//        long low = -1;
//        long high = ((long) 1e9);
//        while (high - low > 1)
//        {
//            long mid = low + (high - low) / 2;
//            long last = mid * (mid + 1);
//            last /= 2;
//            if (last <= 1e14)
//            {
//                low = mid;
//            } else
//            {
//                high = mid;
//            }
//        }
//        System.out.println("MAX = " + low + " max value = " + (low * (low + 1)) / 2);
//        low = low + 1;
//        System.out.println((low * (low + 1)) / 2);
        }

    }

    static class FastPrinter extends PrintWriter
    {
        public FastPrinter(OutputStream out)
        {
            super(out);
        }

        public FastPrinter(Writer out)
        {
            super(out);
        }

    }

    static class FastScanner
    {
        public BufferedReader br;
        public StringTokenizer st;

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

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

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

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

    }
}


import java.io.*;
import java.util.*;
import static java.lang.Integer.parseInt;
import java.math.BigInteger;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tk;
//        Scanner in=new Scanner(System.in);
        // PrintWriter p = new PrintWriter(System.out);
        StringBuilder out = new StringBuilder();
        tk = new StringTokenizer(in.readLine());
        int n = parseInt(tk.nextToken());
        char[] a = in.readLine().toCharArray();
        boolean f = true;
        int cnt = 0;

        for (int i = 0; i < a.length;) {
            if (a[i] == '1') {
                cnt++;
                i++;

            } else if (a[i] == '0') {
                if (f) {
                    out.append(cnt);
                    f = false;
                } else if (!f) {
                    out.replace(out.length() - 1, out.length(), cnt + "");
                }

                while (i < a.length && a[i] == '0') {
                    out.append(a[i]);
                    i++;
                }
                cnt = 0;

            }
        }
        if(cnt>0&&out.length()>0)
            out.replace(out.length()-1,out.length(),cnt+"");
        else if(cnt>0)
            out.append(cnt);
        System.out.println(out);
    }
}


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

public class Main {
    static String f(){
        Scanner scanner = new Scanner(System.in);
        LinkedList<String> strings = new LinkedList<String>(Arrays.asList(scanner.next().split("")));
        int flag =0;
        int stringSize = strings.size();
        int divSize = Math.floorDiv(stringSize,2);
        for (int i = 0; i < divSize; i++) {
            if(!(strings.pollFirst().equals(strings.pollLast()))){
                if(++flag==2){
                    return "NO";
                }
            }
        }
        if(flag == 1 || (flag == 0 && stringSize%2 == 1)) return "YES";
        else return "NO";
    }
    public static void main(String[] args){
        System.out.println(f());

    }
}


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

public class Main {
	public static void main(String args[]) throws FileNotFoundException {
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		new Solver().solve(in, out);
		out.close();
	}
}

class Fibonacci{
	private long mod;
	private Map<Long, Long> calculatedNumbers;

	public Fibonacci(long mod){
		calculatedNumbers = new TreeMap<>();
		calculatedNumbers.put(0l, 1l);
		calculatedNumbers.put(1l, 1l);
		this.mod = mod;
	}

	public long fib(long n){
		if(calculatedNumbers.containsKey(n)) return calculatedNumbers.get(n);

		long k = n/2, res;
		if(n%2 == 0){
			res = (fib(k)*fib(k)+fib(k-1)*fib(k-1))%mod;
		}else{
			res = (fib(k)*fib(k+1)+fib(k-1)*fib(k))%mod;
		}
		calculatedNumbers.put(n, res);
		return res;
	}
}

class Exponentation{
	//a^b mod m
	public static long calc(long a, long b, long m){
		if(b == 0) return 1;
		if(b == 1) return a;
		if(b%2 == 0) return calc(a*a%m, b/2, m);
		else return a*calc((a*a%m), (b-1)/2, m)%m;
	}
}

class Solver{
	long n, k, l, MOD;

	void read(InputReader in){
		n = in.nextLong();
		k = in.nextLong();
		l = in.nextLong();
		MOD = in.nextLong();
	}

	public void solve(InputReader in, PrintWriter out){
		read(in);
		if(l != 64 && (1l << l)-1 < k){
			out.println(0);
			return;
		}

		long zeroPos = new Fibonacci(MOD).fib(n+1);
		long onePos = Exponentation.calc(2, n, MOD)-zeroPos;
		while(onePos < 0) onePos += MOD;

		long res = 1;
		for(int i=0; i<l; i++){
			if((k & (1l << i)) != 0) res *= onePos;
			else res *= zeroPos;
			res %= MOD;
		}
		out.println(res%MOD);
	}
}

class InputReader {
	public BufferedReader reader;
	String currentLine[];
	int token;

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

	public String next(){
		while (currentLine == null || token >= currentLine.length) {
			try {
				currentLine = reader.readLine().split("\\s+");
				token = 0;
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return currentLine[token++];
	}

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

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


import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class Test {
  static PrintWriter writer =
      new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
  int R, C;
  long[][] ch = new long[61][61];
  int[] cntA = new int[61], cntB = new int[61];
  long best = Long.MAX_VALUE;
  String str;
  Map<Long, Long> cache = new HashMap<>();
  Set<Long> tried = new HashSet<>();

  public static void main(String[] args) {
    Test te = new Test();
    te.start();
    writer.flush();
  }

  static int readInt() {
    int ans = 0;
    boolean neg = false;
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (c == '-') {
          start = true;
          neg = true;
          continue;
        } else if (c >= '0' && c <= '9') {
          start = true;
          ans = ans * 10 + c - '0';
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return neg ? -ans : ans;
  }

  static long readLong() {
    long ans = 0;
    boolean neg = false;
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (c == '-') {
          start = true;
          neg = true;
          continue;
        } else if (c >= '0' && c <= '9') {
          start = true;
          ans = ans * 10 + c - '0';
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return neg ? -ans : ans;
  }

  static String readString() {
    StringBuilder b = new StringBuilder();
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (!Character.isWhitespace(c)) {
          start = true;
          b.append((char) c);
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return b.toString();
  }

  static int readChars(char[] a, int off) {
    int cnt = 0;
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (Character.isLetterOrDigit(c)) {
          start = true;
          a[off + cnt++] = (char) c;
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return cnt;
  }

  void dfs(long x, long y, int v1, int v2) {
    long diff = Math.abs(x - y);
    if (best <= 1 || diff - ch[v1][R] * ch[v2][R] >= best) return;
    if (v1 == R - 1 && v2 == R - 1) {
      if (diff < best) best = diff;
      return;
    }
    long key = x*10_000 + v1*100 + v2;
    if (tried.contains(key)) return;
    if (v1 >= R) {
      long cur = ch[v1][R] - ch[v1 - 1][R];
      long other = ch[v2][R];
      dfs(x, y + cur * other, v1 - 1, v2);
    }
    if (v2 >= R) {
      long cur = ch[v2][R] - ch[v2 - 1][R];
      long other = ch[v1][R];
      dfs(x + cur * other, y, v1, v2-1);
    }
    tried.add(key);
  }

  long solve(long x, long y, int v1, int v2) {
    long diff = Math.abs(x - y);
    if (diff - ch[v1][R] * ch[v2][R] > best) return 0;
    long key = x*10000 + v1*100 + v2;
    Long v = cache.get(key);
    if (v != null) return v;
    if (v1 < R || v2 < R) {
      if (v1 >= cntA[v1 + v2] && v2 >= cntB[v1 + v2]) {
        int sum = v1 + v2;
        v1 -= cntA[sum];
        v2 -= cntB[sum];
        return ch[v1 + v2][v1];
      }
      return 0;
    }
    long ans = 0;
    char c = str.charAt(v1 + v2 - 1);
    if (c != 'B') {
      long cur = ch[v1][R] - ch[v1 - 1][R];
      long other = ch[v2][R];
      ans += solve(x, y + cur * other, v1 - 1, v2);
    }
    if (c != 'A') {
      long cur = ch[v2][R] - ch[v2 - 1][R];
      long other = ch[v1][R];
      ans += solve(x + cur * other, y, v1, v2 - 1);
    }
    cache.put(key, ans);
    return ans;
  }

  void start() {
    R = readInt();
    C = readInt();
    for (int i = 0; i <= 2*(R + C); i++)
      for (int j = 0; j <= i; j++)
        if (j == 0 || j == i) ch[i][j] = 1;
        else ch[i][j] = ch[i - 1][j - 1] + ch[i - 1][j];
    long x = 0, y = 0;
    int v1 = R + C, v2 = R + C;
    while (v1 >= R && v2 >= R)
      if (x > y) {
        long cur = ch[v1][R] - ch[v1 - 1][R];
        long other = ch[v2][R];
        y += cur * other;
        v1--;
      } else {
        long cur = ch[v2][R] - ch[v2 - 1][R];
        long other = ch[v1][R];
        x += cur * other;
        v2--;
      }
    best = Math.abs(x - y);
    dfs(0, 0, R + C, R + C);
    str = readString();
    for (int i = 0; i < 2 * (R + C); i++) {
      cntA[i + 1] = cntA[i] + (str.charAt(i) == 'A' ? 1 : 0);
      cntB[i + 1] = cntB[i] + (str.charAt(i) == 'B' ? 1 : 0);
    }
    long ans = solve(0, 0, R + C, R + C);
    writer.println(ans);
  }
}


// package CodeForces;

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

public class Problem_988E {
	static boolean valid(char[]tmp)
	{
		int n=tmp.length;
		if(tmp[n-2]=='2' && tmp[n-1]=='5')
			return true;
		if(tmp[n-2]=='5' && tmp[n-1]=='0')
			return true;
		if(tmp[n-2]=='7' && tmp[n-1]=='5')
			return true;
		if(tmp[n-2]=='0' && tmp[n-1]=='0')
			return true;
		return false;
	}
	static int move(int i,int j)
	{
		char []tmp=c.clone();
		int moves=0;
		if(i>j)
			i--;
		while(j<tmp.length-1)
		{
			char cc=tmp[j];
			tmp[j]=tmp[j+1];
			tmp[j+1]=cc;
			moves++;
			j++;
		}
		while(i<tmp.length-2)
		{
			char cc=tmp[i];
			tmp[i]=tmp[i+1];
			tmp[i+1]=cc;
			moves++;
			i++;
		}
		int z;
		for(z=0;z<tmp.length;z++)
			if(tmp[z]!='0')
			{
				char cc=tmp[z];
				tmp[z]=tmp[0];
				tmp[0]=cc;
				moves+=z;
				break;
			}
		if(valid(tmp))
			return moves;
		return -1;
	}
	static int solve(int x,int y)
	{
		int ans=(int)1e9;
		for(int i:lastindx[x])
		{
			for(int j:lastindx[y])
			{
				if(i==j)
					continue;
				int move=move(i,j);
				if(move!=-1)
					ans=Math.min(ans, move);
			}
		}
		return ans;
	}
	static char c[];
	static ArrayList<Integer> lastindx[];
	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter pw = new PrintWriter(System.out);
		c=sc.nextLine().toCharArray();
		lastindx=new ArrayList[10];
		for(int i=0;i<10;i++)
			lastindx[i]=new ArrayList<>();
		for(int i=0;i<c.length;i++)
			lastindx[c[i]-'0'].add(i);
		int ans=(int)1e9;
		ans=Math.min(ans, solve(2,5));
		ans=Math.min(ans, solve(5,0));
		ans=Math.min(ans, solve(7,5));
		ans=Math.min(ans, solve(0,0));
		pw.print(ans==(int)1e9?-1:ans);
		pw.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

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

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

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

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

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

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

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

	}
}


//package CF;

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

public class Domino_v1 {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		long T = Integer.parseInt(br.readLine());
		while (T-- > 0) {
			String[] s = br.readLine().split(" ");
			int n = Integer.parseInt(s[0]);
			int m = Integer.parseInt(s[1]);
			int k = Integer.parseInt(s[2]);
			solve(n, m, k);
		}
	}

	private static void solve(int n, int m, int k) {
		int horizontal_domino = k;
		int vertical_domino = n * m / 2 - k;

		boolean flag = true;
		if (n % 2 != 0) {
			horizontal_domino -= m / 2;
			if (horizontal_domino < 0) {
				flag = false;
			}
		} else if (m % 2 != 0) {
			vertical_domino -= n / 2;
			if (vertical_domino < 0) {
				flag = false;
			}
		}

		if (horizontal_domino % 2 != 0 || vertical_domino % 2 != 0) {
			flag = false;
		}

		System.out.println(flag ? "YES" : "NO");
	}
}


import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.math.BigInteger;
import java.util.Scanner;

public class Test {
	public static void redirectIn(String fileName){
		FileInputStream fileStream=null;
		try {
			fileStream=new FileInputStream(fileName);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		BufferedInputStream input=new BufferedInputStream(fileStream);
		System.setIn(input);
	}
	public static void redirectOut(String fileName){
		FileOutputStream fileStream=null;
		try {
			fileStream=new FileOutputStream(fileName);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		PrintStream output=new PrintStream(fileStream);
		System.setOut(output);
	}
	public static Scanner initCin(){
		//redirectIn("test.in");
		return new Scanner(new BufferedInputStream(System.in));
	}
	public static PrintStream initOut(){
		//redirectOut("test.in");
		return System.out;
	}
	public final static PrintStream out=initOut();
	public final static Scanner cin=initCin();

	public static BigInteger n,x,y,c;
	public static BigInteger f(BigInteger k,BigInteger m){
		BigInteger temp=k.subtract(m);
		if(k.compareTo(m)==1) return temp.multiply(temp);
		return new BigInteger("0");
	}
	public static BigInteger h(BigInteger k,BigInteger m){
		BigInteger temp=k.subtract(m);
		BigInteger one=new BigInteger("1");
		if(k.compareTo(m)==1) return temp.add(one).multiply(temp).shiftRight(1);
		return new BigInteger("0");
	}
	public static BigInteger H(BigInteger ans,BigInteger k,BigInteger x,BigInteger y) {
		BigInteger one=new BigInteger("1");
		if(k.subtract(y).compareTo(x.subtract(one))==1&&
				k.subtract(x).compareTo(y.subtract(one))==1)
			return ans.add(h(k.subtract(y), x.subtract(one)));
		return ans;
	}
	public static BigInteger calc(BigInteger k) {
		BigInteger one=new BigInteger("1");
		BigInteger ans=k.add(one).multiply(k);
		ans=ans.add(ans).add(one);

		BigInteger xsubone=x.subtract(one),ysubone=y.subtract(one);
		BigInteger nsubx=n.subtract(x),nsuby=n.subtract(y);
		ans=ans.subtract(
				f(k, xsubone).add(f(k, ysubone)).add(f(k, nsubx)).add(f(k, nsuby)
						));
		//if(k-x>y-1&&k-y>x-1) and+=h(k-x,y-1);
		ans=H(ans,k,x,y);
		//if(k-(n-y+1)>x-1&&k-x>n-y) ans+=h(k-x, n-y);
		ans=H(ans, k, x, nsuby.add(one));
		//if(k-(n-x+1)>y-1&&k-y>n-x) ans+=h(k-y, n-x);
		ans=H(ans, k, y, nsubx.add(one));
		//if(k-(n-x+1)>n-y&&k-(n-y+1)>n-x) ans+=h(k-(n-y+1), n-x);
		ans=H(ans, k, nsubx.add(one), nsuby.add(one));
		return ans;
	}
	public static void main(String[] args){
		n=new BigInteger(cin.next());x=new BigInteger(cin.next());
		y=new BigInteger(cin.next());c=new BigInteger(cin.next());
		BigInteger one=new BigInteger("1");
		BigInteger l=new BigInteger("0"),r=n.multiply(n).add(one);
		while(l.compareTo(r)==-1){
			BigInteger m=l.add(r).shiftRight(1);
			if(calc(m).compareTo(c)==-1)
				l=m.add(one);
			else
				r=m;
		}
		out.println(l);
	}
}


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

public class Main{
	static long even(long l, long r){
	    if(r - l <= 20){
	        long ans = 0L;
	        for(long i = l; i <= r; i++){if(i % 2 == 0){ans++;}}
	        return ans;
	    }
	    long l1 = (l % 2 == 0) ? l : (l + 1);
	    long r1 = (r % 2 == 1) ? r : (r - 1);
	    long ans = (r1 - l1 + 1) / 2;
	    if(r % 2 == 0)
	        ans++;
	    return ans;
	}
	static long odd(long l, long r){
		return (r - l + 1) - even(l, r);
	}
	public static void main(String args[]) throws IOException {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		long x1, y1, x2, y2;
		x1 = in.nextLong(); y1 = in.nextLong(); x2 = in.nextLong(); y2 = in.nextLong();
		out.println(((y2 - y1)/2 + 1) * (x2 - x1 + 1) - (x2 - x1)/2);
		out.flush();
	}
}


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

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));

		int l = Integer.parseInt(r.readLine());
		boolean[] v = new boolean[l];

		char[] s = r.readLine().toCharArray();
		int n = s.length;
		for(char i:s)if(i!='?')v[i-'a']=true;

		if((n+1)/2 < l){
			System.out.println("IMPOSSIBLE");
			System.exit(0);
		}

		//Check.
		for (int i = 0; i <= n/2 ; i++) {
			if(s[i]!='?' && s[n-i-1]!='?' && s[i]!=s[n-i-1]){
				System.out.println("IMPOSSIBLE");
				System.exit(0);
			}
		}
		for (int i = n/2; i >=0; i--) {
			if(s[i]=='?' && s[n-i-1]=='?'){
				s[i] = get(v);
				s[n-i-1] = s[i];
			}
			if(s[i]=='?' || s[n-i-1]=='?'){
				if(s[i]=='?')s[i]=s[n-i-1];
				else s[n-i-1]=s[i];
			}
		}

		for(boolean i:v)if(!i){
			System.out.println("IMPOSSIBLE");
			System.exit(0);
		}

		String out = "";
		for(char i:s)out+=i;

		System.out.println(out);

	}

	private static char get(boolean[] v) {
		for (int i = v.length-1; i>=0; i--) {
			if(v[i]==false){
				v[i] = true;
				return (char) (i+'a');
			}
		}
		return (char)(0+'a');
	}
}


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.Arrays;
import java.util.StringTokenizer;

public class B {

    static StringTokenizer st;
    static BufferedReader br;
    static PrintWriter pw;
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int n = nextInt();
        int m = nextInt();
        boolean[]lider = new boolean[n+1];
        Arrays.fill(lider, true);
        int[]timeexit = new int[n+1];
        char[]w = new char[m+1];
        int[]t = new int[m+1];
        for (int i = 1; i <= m; i++) {
            w[i] = next().charAt(0);
            t[i] = nextInt();
        }
        int last = 0;
        boolean[]in = new boolean[n+1];
        int cntin = 0;
        for (int i = 1; i <= m; i++) {
            if (w[i]=='+') {
                in[t[i]] = true;
                cntin++;
            }
            else {
                int s = 1;
                if (!in[t[i]])
                    s = 0;
                if (cntin > s) {
                    lider[t[i]] = false;
                }
                if (!in[t[i]]) {
                    last = i;
                }
                else
                    cntin--;
                in[t[i]] = false;
            }
        }
        for (int i = 1; i <= m; i++) {
            if (w[i]=='+') {
                if (timeexit[t[i]]+1 != i)
                    lider[t[i]] = false;
            }
            else {
                timeexit[t[i]] = i;
            }
        }
        int s = 0;
        for (int i = 1; i <= n; i++) {
            if (in[i])
                s++;
        }
        if (s != 0) {
            for (int i = 1; i <= m; i++) {
                if (!in[t[i]])
                    lider[t[i]] = false;
            }
        }
        if (last != 0) {
            for (int i = 1; i < last; i++) {
                if (t[i] != t[last])
                    lider[t[i]] = false;
            }
        }
        for (int i = 1; i <= n; i++) {
            if (timeexit[i] != 0 && timeexit[i] != m && !in[i])
                lider[i] = false;
        }
        int cnt = 0;
        for (int i = 1; i <= n; i++) {
            if (lider[i])
                cnt++;
        }
        pw.println(cnt);
        for (int i = 1; i <= n; i++) {
            if (lider[i])
                pw.print(i+" ");
        }
        pw.close();
    }
    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
    private static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
    private static String next() throws IOException {
        while (st==null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}


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

public class A {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		long[] V = new long[1000010];
		Arrays.fill(V, 0);
		V[N] = 0;
		long ans = 0;
		long[] sum = new long[2];
		for (int i = N-1; i >= 0; i--) {
			V[i] = 1;
			V[i] += sum[(i+1)%2];
			V[i] %= MOD;
			ans += V[i];
			sum[i%2] += V[i];
		}
		ans %= MOD;
		System.out.println(ans);
	}
	static long MOD = 1000000007L;
}


import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

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

public class E {

	static void solve() throws Exception {
		int n = scanInt(), m = scanInt();
		String map[] = new String[n];
		for (int i = 0; i < n; i++) {
			map[i] = scanString();
		}
		int ans = 0;
		int i = 0, j = 0;
		while (true) {
			if (map[i].charAt(j) == '*') {
				++ans;
			}
			if (i == n - 1 && j == m - 1) {
				break;
			} else if (i == n - 1) {
				++j;
			} else if (j == m - 1) {
				++i;
			} else {
				for (int d = 1;; d++) {
					if (j + d >= m || map[i].charAt(j + d) == '*') {
						++j;
						break;
					} else if (i + d >= n || map[i + d].charAt(j) == '*') {
						++i;
						break;
					}
				}
			}
		}
		out.print(ans);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}


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

public class D {
	private static int n, k;
	private static int[] a;

	public static void main(String[] args) {
		n = ini();
		k = ini();
		a = ina(n);

		Arrays.sort(a);

		int MX = (int)2e5+5;
		int[] count = new int[MX];
		long[] steps = new long[MX];

		for(int i=0; i<n; i++) {
			int v = a[i];
			long st = 0;
			while(true) {
				if (count[v]<k) {
					count[v]++;
					steps[v]+=st;
				}
				if (v==0) break;
				v/=2;
				st++;
			}
		}
		long ans = (long)1e15;
		for(int i=0; i<MX; i++) {
			if (count[i]==k) {
				ans = Math.min(ans, steps[i]);
			}
		}
		println(ans);

//		int[] map = new int[MX];
//		for(int x: a) {
//			map[x]++;
//		}
//
//		int[] ans = new int[MX];
//		int[] track = new int[MX];
//
//		for(int i=0; i<MX; i++) {
//			int temp = i;
//			int count = 0;
//			while(true) {
//				if (track[temp]+count*map[i]<=k) {
//					ans[temp] += count*map[i];
//					track[temp]+=map[i];
//				} else {
//					ans[temp] += count*
//				}
//				temp/=2;
//				count++;
//				if (temp==0) {
//					ans[0] += count;
//					track[0]++;
//					break;
//				}
//			}
//
//		}
//		for(int i=0; i<10; i++) {
//			println(i+" "+track[i]+" "+ans[i]);
//		}
//
//		int sol = (int)1e9;
//		for(int i=0; i<MX; i++) {
//			if (track[i]>=k) {
//				sol = Math.min(sol, ans[i]);
//			}
//		}
//		println(sol);
		out.flush();
		out.close();

	}

	//NONPROBLEM CODE

	private static InputReader in = new InputReader(System.in);
	private static PrintWriter out = new PrintWriter(System.out);

	private static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;

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

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

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

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

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

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

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

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

	}

	//INPUT SHORTCUTS

	private static int[] ina(int n) {
		int[] temp = new int[n];
		for (int i = 0; i < n; i++) {
			temp[i] = in.nextInt();
		}
		return temp;
	}

	private static int ini() {
		return in.nextInt();
	}

	//OTHER SHORTCUTS
	public static void sort(int[] a) {
		Arrays.sort(a);
	}

	//PRINT SHORTCUTS

	private static void println(Object... o) {
		for (Object x : o) {
			out.write(x + " ");
		}
		out.write("\n");
		out.flush();
	}

	private static void print(Object... o) {
		for (Object x : o) {
			out.write(x + " ");
		}
		out.flush();
	}

	private static void debug(Object... o) {
		for (Object x : o) {
			out.write(x + " ");
		}
		out.write("\n");
		out.flush();
	}
}


import java.util.Scanner;

public class LinksAndPearls {

	public static void main(String[] args) {
		Scanner scan = new Scanner (System.in);
		String chain = scan.nextLine();
		int len = chain.length();
		chain = chain.replaceAll("o", "");
		int o = len-chain.length();
		int dash = chain.length();
		if(o>0) {
		if((dash==0) || (o==1) || ((dash%o==0 && dash>=o) && o>1)) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	} else {
		System.out.println("YES");
	}

	}}


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

public class A {
    static MyScanner sc;
    static PrintWriter pw;

    public static void main(String[] args) throws Throwable {
        sc = new MyScanner();
        pw = new PrintWriter(System.out);

        double x = sc.nextDouble();
        double y = sc.nextDouble();
        double z = sc.nextDouble();

        boolean greater = x > 1 || y > 1 || z > 1;
        String[] exp =
                {"x^y^z", "x^z^y", "(x^y)^z", "(x^z)^y",
                        "y^x^z", "y^z^x", "(y^x)^z", "(y^z)^x",
                        "z^x^y", "z^y^x", "(z^x)^y", "(z^y)^x",};

        double[] vals = new double[12];

        if (greater) {
            Arrays.fill(vals, -1e18);
            if (x > 1) {
                vals[0] = z * Math.log(y) + Math.log(Math.log(x));
                vals[1] = y * Math.log(z) + Math.log(Math.log(x));
                vals[2] = Math.log(y) + Math.log(z) + Math.log(Math.log(x));
            }
            if (y > 1) {
                vals[4] = z * Math.log(x) + Math.log(Math.log(y));
                vals[5] = x * Math.log(z) + Math.log(Math.log(y));
                vals[6] = Math.log(x) + Math.log(z) + Math.log(Math.log(y));
            }
            if (z > 1) {
                vals[8] = y * Math.log(x) + Math.log(Math.log(z));
                vals[9] = x * Math.log(y) + Math.log(Math.log(z));
                vals[10] = Math.log(x) + Math.log(y) + Math.log(Math.log(z));
            }
            String ans = "";
            double mx = -2e18;
            for (int i = 0; i < 12; i++)
                if (vals[i] > mx) {
                    mx = vals[i];
                    ans = exp[i];
                }
            pw.println(ans);

        } else {
            Arrays.fill(vals, 1e18);

            vals[0] = z * Math.log(y) + Math.log(Math.log(1 / x));
            vals[1] = y * Math.log(z) + Math.log(Math.log(1 / x));
            vals[2] = Math.log(y) + Math.log(z) + Math.log(Math.log(1 / x));
            vals[4] = z * Math.log(x) + Math.log(Math.log(1 / y));
            vals[5] = x * Math.log(z) + Math.log(Math.log(1 / y));
            vals[6] = Math.log(x) + Math.log(z) + Math.log(Math.log(1 / y));
            vals[8] = y * Math.log(x) + Math.log(Math.log(1 / z));
            vals[9] = x * Math.log(y) + Math.log(Math.log(1 / z));
            vals[10] = Math.log(x) + Math.log(y) + Math.log(Math.log(1 / z));

            String ans = "";
            double mn = 2e18;
            for (int i = 0; i < 12; i++)
                if (vals[i] < mn) {
                    mn = vals[i];
                    ans = exp[i];
                }
            pw.println(ans);

        }

        pw.flush();
        pw.close();
    }

    static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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


import java.util.*;
import java.io.*;
public class SmallestNumber {
    static BufferedReader br;
    static int[] n;
    static char[] operations;
    public static void main(String[] args) {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            init();
            System.out.println(solve());
            br.close();
        }
        catch(Exception e) {
            e.printStackTrace();
        }
    }
    private static void init() throws IOException {
    	n = new int[4];
    	operations = new char[3];
    	StringTokenizer st = new StringTokenizer(br.readLine());
    	for(int i = 0; i < 4; i++)
    		n[i] = Integer.parseInt(st.nextToken());
    	st = new StringTokenizer(br.readLine());
    	for(int i = 0; i < 3; i++)
    		operations[i] = st.nextToken().charAt(0);
    }
    private static String solve() {
    	int[] total;
    	if(operations[0] == '*' && operations[1] == '*' && operations[2] == '*') {
    		long l = n[0] * n[1] * n[2];
    		return String.valueOf(l * n[3]);
    	}
    	else if(operations[0] == '+' && operations[1] == '*' && operations[2] == '*') {
    		total = new int[6];
    		for(int i = 0; i < 6; i++) {
    			if(i == 0) total[i] = (n[0] + n[1]) * n[2] * n[3];
    			else if(i == 1) total[i] = (n[0] + n[2]) * n[1] * n[3];
    			else if(i == 2) total[i] = (n[0] + n[3]) * n[1] * n[2];
    			else if(i == 3) total[i] = (n[1] + n[2]) * n[0] * n[3];
    			else if(i == 4) total[i] = (n[1] + n[3]) * n[0] * n[2];
    			else total[i] = (n[2] + n[3]) * n[0] * n[1];
    		}
    	}
    	else if(operations[0] == '*' && operations[1] == '+' && operations[2] == '*') {
    		total = new int[24];
    		for(int i = 0; i < 24; i++) {
    			if(i == 0) total[i] = (n[0] * n[2] + n[3]) * n[1];
    			else if(i == 1) total[i] = (n[0] * n[3] + n[2]) * n[1];
    			else if(i == 2) total[i] = (n[0] * n[1] + n[3]) * n[2];
    			else if(i == 3) total[i] = (n[0] * n[3] + n[1]) * n[2];
    			else if(i == 4) total[i] = (n[0] * n[1] + n[2]) * n[3];
    			else if(i == 5) total[i] = (n[0] * n[2] + n[1]) * n[3];
    			else if(i == 6) total[i] = (n[1] * n[2] + n[3]) * n[0];
    			else if(i == 7) total[i] = (n[1] * n[3] + n[2]) * n[0];
    			else if(i == 8) total[i] = (n[1] * n[0] + n[3]) * n[2];
    			else if(i == 9) total[i] = (n[1] * n[3] + n[0]) * n[2];
    			else if(i == 10) total[i] = (n[1] * n[0] + n[2]) * n[3];
    			else if(i == 11) total[i] = (n[1] * n[2] + n[0]) * n[3];
    			else if(i == 12) total[i] = (n[2] * n[1] + n[3]) * n[0];
    			else if(i == 13) total[i] = (n[2] * n[3] + n[1]) * n[0];
    			else if(i == 14) total[i] = (n[2] * n[0] + n[3]) * n[1];
    			else if(i == 15) total[i] = (n[2] * n[3] + n[0]) * n[1];
    			else if(i == 16) total[i] = (n[2] * n[0] + n[1]) * n[3];
    			else if(i == 17) total[i] = (n[2] * n[1] + n[0]) * n[3];
    			else if(i == 18) total[i] = (n[3] * n[1] + n[2]) * n[0];
    			else if(i == 19) total[i] = (n[3] * n[2] + n[1]) * n[0];
    			else if(i == 20) total[i] = (n[3] * n[0] + n[2]) * n[1];
    			else if(i == 21) total[i] = (n[3] * n[2] + n[0]) * n[1];
    			else if(i == 22) total[i] = (n[3] * n[0] + n[1]) * n[2];
    			else total[i] = (n[3] * n[1] + n[0]) * n[2];
    		}
    	}
    	else if(operations[0] == '*' && operations[1] == '*' && operations[2] == '+') {
    		total = new int[3];
    		for(int i = 0; i < 3; i++) {
    			if(i == 0) total[i] = n[0] * n[1] + n[2] * n[3];
    			else if(i == 1) total[i] = n[0] * n[2] + n[1] * n[3];
    			else total[i] = n[0] * n[3] + n[1] * n[2];
    		}
    	}
    	else if(operations[0] == '*' && operations[1] == '+' && operations[2] == '+') {
    		total = new int[6];
    		for(int i = 0; i < 6; i++) {
    			if(i == 0) total[i] = n[0] * n[1] + n[2] + n[3];
    			else if(i == 1) total[i] = n[0] * n[2] + n[1] + n[3];
    			else if(i == 2) total[i] = n[0] * n[3] + n[1] + n[2];
    			else if(i == 3) total[i] = n[1] * n[2] + n[0] + n[3];
    			else if(i == 4) total[i] = n[1] * n[3] + n[0] + n[2];
    			else total[i] = n[2] * n[3] + n[0] + n[1];
    		}
    	}
    	else if(operations[0] == '+' && operations[1] == '*' && operations[2] == '+') {
    		total = new int[30];
    		for(int i = 0; i < 30; i++) {
    			if(i == 0) total[i] = n[2] * (n[0] + n[1]) + n[3];
    			else if(i == 1) total[i] = (n[0] + n[1]) * n[3] + n[2];
    			else if(i == 2) total[i] = (n[0] + n[2]) * n[1] + n[3];
    			else if(i == 3) total[i] = (n[0] + n[2]) * n[3] + n[1];
    			else if(i == 4) total[i] = (n[0] + n[3]) * n[1] + n[2];
    			else if(i == 5) total[i] = (n[0] + n[3]) * n[2] + n[1];
    			else if(i == 6) total[i] = (n[1] + n[0]) * n[2] + n[3];
    			else if(i == 7) total[i] = (n[1] + n[0]) * n[3] + n[2];
    			else if(i == 8) total[i] = (n[1] + n[2]) * n[0] + n[3];
    			else if(i == 9) total[i] = (n[1] + n[2]) * n[3] + n[0];
    			else if(i == 10) total[i] = (n[1] + n[3]) * n[0] + n[2];
    			else if(i == 11) total[i] = (n[1] + n[3]) * n[2] + n[0];
    			else if(i == 12) total[i] = (n[2] + n[0]) * n[1] + n[3];
    			else if(i == 13) total[i] = (n[2] + n[0]) * n[3] + n[1];
    			else if(i == 14) total[i] = (n[2] + n[1]) * n[0] + n[3];
    			else if(i == 15) total[i] = (n[2] + n[1]) * n[3] + n[0];
    			else if(i == 16) total[i] = (n[2] + n[3]) * n[0] + n[1];
    			else if(i == 17) total[i] = (n[2] + n[3]) * n[1] + n[0];
    			else if(i == 18) total[i] = (n[3] + n[2]) * n[0] + n[1];
    			else if(i == 19) total[i] = (n[3] + n[2]) * n[1] + n[0];
    			else if(i == 20) total[i] = (n[3] + n[1]) * n[0] + n[2];
    			else if(i == 21) total[i] = (n[3] + n[1]) * n[2] + n[0];
    			else if(i == 22) total[i] = (n[3] + n[0]) * n[1] + n[2];
    			else if(i == 23) total[i] = n[0] * n[1] + (n[2] + n[3]);
    			else if(i == 24) total[i] = n[0] * n[2] + (n[1] + n[3]);
    			else if(i == 25) total[i] = n[0] * n[3] + (n[1] + n[2]);
    			else if(i == 26) total[i] = n[1] * n[2] + (n[0] + n[3]);
    			else if(i == 27) total[i] = n[1] * n[3] + (n[0] + n[2]);
    			else if(i == 28) total[i] = n[2] * n[3] + (n[0] + n[1]);
    			else total[i] = (n[3] + n[0]) * n[2] + n[1];
    		}
    	}
    	else if(operations[0] == '+' && operations[1] == '+' && operations[2] == '*') {
    		total = new int[7];
    		for(int i = 0; i < 7; i++) {
    			if(i == 0) total[i] = (n[1] + n[2] + n[3]) * n[0];
    			else if(i == 1) total[i] = (n[0] + n[2] + n[3]) * n[1];
    			else if(i == 2) total[i] = (n[0] + n[1] + n[3]) * n[2];
    			else if(i == 3) total[i] = (n[0] + n[1] + n[2]) * n[3];
    			else if(i == 4) total[i] = (n[0] + n[1]) * (n[2] + n[3]);
    			else if(i == 5) total[i] = (n[0] + n[2]) * (n[1] + n[3]);
    			else total[i] = (n[0] + n[3]) * (n[1] + n[2]);
    		}
    	}
    	else
    		return String.valueOf(n[0] + n[1] + n[2] + n[3]);
//    	System.out.println(Arrays.toString(total));
    	Arrays.sort(total);
//    	System.out.println(Arrays.toString(total));
		return String.valueOf(total[0]);
    }
}


import java.util.Scanner;

public class HitBall203D {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		double a, b, m;
		a = in.nextInt();
		b = in.nextInt();
		m = in.nextInt();
		double vx, vy, vz;
		vx = in.nextInt();
		vy = in.nextInt();
		vz = in.nextInt();
		double t = -1 * m / vy;
		double x = t * vx + a / 2;
		double z = t * vz;
		while (z - 2 * b >= 0)
			z -= 2 * b;
		if (z > b)
			z = 2 * b - z;
		if (x < 0) {
			while (x < 0)
				x += 2 * a;
		} else {
			while (x - 2 * a >= 0)
				x -= 2 * a;
		}
		if (x > a)
			x = 2 * a - x;
		System.out.printf("%f %f\n", x, z);
	}
}


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

public class TaskC {
    public static String doMain(Reader reader) throws IOException {
        MyReader in = new MyReader(reader);
        int n = in.nextInt();
        int p = in.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; n - i * p >= i; ++i) {
            int count = check(n - p * i);
            if (count > i){
                continue;
            }
            return i+"";
        }
        return "-1";
    }

    private static int check(int n) {
        int answer = 0;
        while (n > 0) {
            answer += n % 2;
            n /= 2;
        }
        return answer;
    }

    public static void main(String[] args) throws IOException {
        String result = doMain(new InputStreamReader(System.in));
        System.out.println(result);
    }

    static class MyReader {
        BufferedReader bf;

        StringTokenizer st;

        String last;

        MyReader(Reader reader) throws IOException {
            bf = new BufferedReader(reader);
            readNextLine();
        }

        String nextToken() throws IOException {
            while (!st.hasMoreTokens()) {
                readNextLine();
            }
            return st.nextToken();
        }

        void readNextLine() throws IOException {
            last = bf.readLine();
            if (last == null) last = "";
            st = new StringTokenizer(last);
        }

        String nextLine() throws IOException {
            String s = last;
            readNextLine();
            return s;
        }

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

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

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

        int[] readIntArray(int n) throws IOException {
            int[] answer = new int[n];
            for (int i = 0; i < n; ++i) {
                answer[i] = nextInt();
            }
            return answer;
        }

        long[] readLongArray(int n) throws IOException {
            long[] answer = new long[n];
            for (int i = 0; i < n; ++i) {
                answer[i] = nextLong();
            }
            return answer;
        }

        double[] readDoubleArray(int n) throws IOException {
            double[] answer = new double[n];
            for (int i = 0; i < n; ++i) {
                answer[i] = nextDouble();
            }
            return answer;
        }
    }
}


import java.util.Scanner;
public class D {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
System.out.print((n+1)/36+" "+(n+1)%36/3);
}
}


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

// you can compare with output.txt and expected out
public class Round818E {
	MyPrintWriter out;
	MyScanner in;

//	final static long FIXED_RANDOM;
//	static {
//		FIXED_RANDOM = System.currentTimeMillis();
//	}
	final static String IMPOSSIBLE = "IMPOSSIBLE";
	final static String POSSIBLE = "POSSIBLE";
	final static String YES = "YES";
	final static String NO = "NO";

    private void initIO(boolean isFileIO) {
        if (System.getProperty("ONLINE_JUDGE") == null && isFileIO) {
        	try{
	            in = new MyScanner(new FileInputStream("input.txt"));
	            out = new MyPrintWriter(new FileOutputStream("output.txt"));
        	}
        	catch(FileNotFoundException e){
        		e.printStackTrace();
        	}
        }
        else{
    		in = new MyScanner(System.in);
    	    out = new MyPrintWriter(new BufferedOutputStream(System.out));
        }
    }

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

		Round818E sol = new Round818E();
		sol.run();
    }

	private void run() {
		boolean isDebug = false;
		boolean isFileIO = true;
		boolean hasMultipleTests = false;

		initIO(isFileIO);

		//test();

		int t = hasMultipleTests? in.nextInt() : 1;

	    for (int i = 1; i <= t; ++i) {
	    	if(isDebug){
		    	out.printf("Test %d\n", i);
	    	}

	    	getInput();

	    	solve();

	    	printOutput();
	    }

	    in.close();
	    out.close();
	}

	static long MOD = 1_000_000_007;

	void test() {
		for(int i=2; i<=100; i++) {
			n = i;
			long[] compare = new long[n+1];
			long expected = 0;
			for(int a=1; a<=n; a++) {
				for(int b=1; b<=n; b++) {
					long c = n-a-b;
					if(c < 0)
						continue;
					int g = gcd(a, b);
					long gg = gcd(c, g);
					expected += gg*(c/gg)*(g/gg);
					compare[g] += gg*(c/gg)*(g/gg);
				}
			}
			solve();
			if(expected != ans) {
				solve();
			}

		}
	}

	// use suitable one between matrix(2, n), matrix(n, 2), transposedMatrix(2, n) for graph edges, pairs, ...
	int n;
	void getInput() {
		n = in.nextInt();
	}

	void printOutput() {
		out.printlnAns(ans);
	}

	long[] check;
	long ans;
	void solve(){
		// sum lcm(c, gcd(a, b)) for a+b+c = n

		// for each g = gcd(a, b),

		// g = 1
		// lcm = c = n-a-b, so need to count #(a, b) s.t. gcd(a,b)=1 and sum of a+b for such pairs

		// g = 2
		// a = 2a', b = 2b'
		// lcm = c if 2 | n, 2c otherwise

		// g = 3
		// same strategy

		// gcd(g, n - ga' - gb') = gcd(g, n) = k
		// lcm(g, n - ga' - gb') = g*(n-ga'-gb')*k --- i.e., only need #(a, b) and sum of a+b

		// given s,
		// for each a,
		// want to count #b s.t. gcd(a, b) = 1, a + b <= s, b < a
		// for this, simply generate all divisors and exclude them

//		ArrayList<Integer>[] divisors = new ArrayList[n+1];
//		ArrayList<Long>[] prefixSum = new ArrayList[n+1];

//		for(int i=2; i<=n; i++)
//			divisors[i] = new ArrayList<Integer>();
//		for(int i=2; i<=n; i++) {
//			if(divisors[i].isEmpty()) {
//				divisors[i].add(1);
//				divisors[i].add(i);
//				// i*i <= n
//				if(n/i >= i) {
//					for(int j=i*i; j<=n; j+=i)
//						if(divisors[j].isEmpty())
//							divisors[j].add(i);
//				}
//			}
//			else {
//				int prime = divisors[i].remove(0);
//				int maxPrime = 1;
//				{
//					int m = i/prime;
//					while(m % prime == 0) {
//						m /= prime;
//						maxPrime *= prime;
//					}
//				}
//				for(int divisor: divisors[i/prime]) {
//					if(divisor % maxPrime == 0)
//						divisors[i].add(divisor*prime);
//					divisors[i].add(divisor);
//				}
//				Collections.sort(divisors[i]);
//			}
//			prefixSum[i] = new ArrayList<Long>();
//			long sum = 0;
//			for(int divisor: divisors[i]){
//				sum += divisor;
//				prefixSum[i].add(sum);
//			}
//		}

		ArrayList<Integer>[] primeFactors = new ArrayList[n+1];
		for(int i=2; i<=n; i++)
			primeFactors[i] = new ArrayList<Integer>();

//		int[][] prefixCnt = new int[n+1][];
//		long[][] prefixSum = new long[n+1][];

		for(int i=2; i<=n; i++) {
			if(primeFactors[i].isEmpty()) {
				primeFactors[i].add(i);
				// i*i <= n
				if(n/i >= i) {
					for(int j=i*i; j<=n; j+=i)
						if(primeFactors[j].isEmpty())
							primeFactors[j].add(i);
				}
			}
			else {
				int prime = primeFactors[i].get(0);
				int rest = i/prime;
				while(rest % prime == 0)
					rest /= prime;
				if(rest > 1)
					for(int factor: primeFactors[rest])
						primeFactors[i].add(factor);
			}
//			int N = n/i;
//			int[] cnt = new int[N+1];
//			long[] sum = new long[N+1];
//			prefixCnt[i] = cnt;
//			prefixSum[i] = sum;
//			for(int j=1; j<=N; j++) {
//				cnt[j] = cnt[j-1];
//				sum[j] = sum[j-1];
//				if(j % i == 0) {
//					cnt[j]++;
//					sum[j]+=j;
//				}
//			}
		}

		ans = 0;
		check = new long[n+1];
		for(long g=1; g<=n; g++) {
			if(g*2 + 1 > n)
				break;
			long cnt = 0;
			long sum = 0;
			// 1) a < b

			// want to count #b' s.t. gcd(a', b') = 1, a' + b' <= s, b' < a'
			// g(a'+b')+1 <= n
			for(int ap=2; ap<=n; ap++) {
				if(g*(ap+1) + 1 > n)
					break;

				long maxBp = Math.min(ap-1, (n-1)/g - ap);
				long currCnt = maxBp;
				sum += maxBp*(maxBp+1)/2 % MOD;

				int k = primeFactors[ap].size();
				for(int mask=1; mask<(1<<k); mask++) {
					long curr = 1;
					int sign = 1;
					for(int pos=0; pos<k; pos++) {
						if((mask & (1<<pos)) > 0) {
							curr *= primeFactors[ap].get(pos);
							sign *= -1;
						}
					}
					// s*curr + g*ap + 1 <= n
					long s = Math.min((ap-1)/curr, (n-1 - g*ap)/curr/g);
//					currCnt += prefixCnt[curr][s] * sign;
//					sum += prefixSum[curr][s] * sign;
					currCnt += s * sign;
					sum += curr * s * (s+1)/2 * sign;
				}

//				HashSet<Integer> bad = new HashSet<>();
//				for(int prime: primeFactors[ap]) {
//					for(int i=1; i<=n; i++) {
//						int bp = prime*i;
//						if(bp >= ap || g*(ap+bp) + 1 > n)
//							break;
//						if(!bad.contains(bp)) {
//							bad.add(bp);
//							currCnt--;
//							sum -= bp;
//						}
//					}
//				}

				cnt += currCnt;
				sum += currCnt * ap;
				sum %= MOD;

//				int k = divisors[ap].size();
//				int lo = 0;
//				int hi = k-2;
//				while(lo < hi) {
//					int mid = (lo+hi+1)/2;
//					int bp = divisors[ap].get(mid);
//					if(g*(ap+bp) + 1 > n)
//						hi = mid-1;
//					else
//						lo = mid;
//				}
//				// g*(ap+maxBp)+1 <= n
//				long maxBp = Math.min(ap-1, (n-1)/g - ap);
//				// g(1+...+maxBp)
//				long currCnt = maxBp - lo; // 1 is always ok
//				cnt += currCnt;
//				sum += currCnt * ap % MOD;
//				sum += maxBp*(maxBp+1)/2 % MOD;
//				sum -= (prefixSum[ap].get(lo)-1) % MOD;
			}

			// then *2
			cnt *= 2;
			sum *= g*2;

			// 2) a = b = g
			cnt ++;
			sum += g*2;

			cnt %= MOD;
			sum %= MOD;
			if(sum < 0)
				sum += MOD;

			// (1, 1)
			// (1, 2), (1, 3)
			// (2, 1), (3, 1)

			// n = 6
			// (1, 1)
			// (1, 2)
			// (1, 3), (2, 3)
			// (1, 4)
			// cnt = 1 + 4*2 = 9
			// sum = 2 + 17*2 = 36
			// 4 + (3 + 2 + 1 + 1)*2 = 18

			// (2, 2)
			// 2

			// 6 * 9 = 54
			// 36

			// lcm(g, n - ga' - gb') = g/k*(n-ga'-gb')/k*k --- i.e., only need #(a, b) and sum of a+b
			check[(int)g] -= ans;
			long k = gcd(g, n);
			ans += g*n/k*cnt % MOD;
			ans -= g/k*sum % MOD;
			check[(int)g] += ans;
		}
		ans %= MOD;
		if(ans < 0)
			ans += MOD;
	}

	static long gcd(long a, long b){
		if(a < b){
			long temp = b;
			b = a;
			a = temp;
		}
		// a > b
		while (b > 0) {
			long r = a % b;
			a = b;
			b = r;
		}
		return a;
	}

	static int gcd(int a, int b){
		if(a < b){
			int temp = b;
			b = a;
			a = temp;
		}
		// a > b
		while (b > 0) {
			int r = a % b;
			a = b;
			b = r;
		}
		return a;
	}

//	Optional<T> solve()
//	return Optional.empty();

	static class Pair implements Comparable<Pair>{
		final static long FIXED_RANDOM = System.currentTimeMillis();
		int first, second;
		public Pair(int first, int second) {
			this.first = first;
			this.second = second;
		}

		@Override
		public int hashCode() {
			// http://xorshift.di.unimi.it/splitmix64.c
			long x = first;
			x <<= 32;
			x += second;
			x += FIXED_RANDOM;
			x += 0x9e3779b97f4a7c15l;
			x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9l;
			x = (x ^ (x >> 27)) * 0x94d049bb133111ebl;
			return (int)(x ^ (x >> 31));
		}
		@Override
		public boolean equals(Object obj) {
//			if (this == obj)
//				return true;
//			if (obj == null)
//				return false;
//			if (getClass() != obj.getClass())
//				return false;
			Pair other = (Pair) obj;
			return first == other.first && second == other.second;
		}
		@Override
		public String toString() {
			return "[" + first + "," + second + "]";
		}

		@Override
		public int compareTo(Pair o) {
			int cmp = Integer.compare(first, o.first);
			return cmp != 0? cmp: Integer.compare(second, o.second);
		}
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		// 32768?
		public MyScanner(InputStream is, int bufferSize) {
			br = new BufferedReader(new InputStreamReader(is), bufferSize);
		}

		public MyScanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
			// br = new BufferedReader(new InputStreamReader(System.in));
			// br = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt")));
		}

		public void close() {
			try {
				br.close();
			} catch (IOException e) {
				e.printStackTrace();
			}

		}

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

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

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

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

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

		int[][] nextMatrix(int n, int m) {
			return nextMatrix(n, m, 0);
		}

		int[][] nextMatrix(int n, int m, int offset) {
			int[][] mat = new int[n][m];
			for(int i=0; i<n; i++) {
				for(int j=0; j<m; j++) {
					mat[i][j] = nextInt()+offset;
				}
			}
			return mat;
		}

		int[][] nextTransposedMatrix(int n, int m){
			return nextTransposedMatrix(n, m, 0);
		}

		int[][] nextTransposedMatrix(int n, int m, int offset){
			int[][] mat = new int[m][n];
			for(int i=0; i<n; i++) {
				for(int j=0; j<m; j++) {
					mat[j][i] = nextInt()+offset;
				}
			}
			return mat;
		}

		int[] nextIntArray(int len) {
			return nextIntArray(len, 0);
		}
		int[] nextIntArray(int len, int offset){
	    	int[] a = new int[len];
			for(int j=0; j<len; j++)
	    		a[j] = nextInt()+offset;
	    	return a;
		}

		long[] nextLongArray(int len) {
			return nextLongArray(len, 0);
		}
		long[] nextLongArray(int len, int offset){
	    	long[] a = new long[len];
			for(int j=0; j<len; j++)
	    		a[j] = nextLong()+offset;
	    	return a;
		}

		String[] nextStringArray(int len) {
			String[] s = new String[len];
			for(int i=0; i<len; i++)
				s[i] = next();
			return s;
		}
	}

	public static class MyPrintWriter extends PrintWriter{
		public MyPrintWriter(OutputStream os) {
			super(os);
		}

//		public <T> void printlnAns(Optional<T> ans) {
//			if(ans.isEmpty())
//				println(-1);
//			else
//				printlnAns(ans.get());
//		}

		public void printlnAns(OptionalInt ans) {
			println(ans.orElse(-1));
		}

		public void printlnAns(long ans) {
			println(ans);
		}

		public void printlnAns(int ans) {
			println(ans);
		}

		public void printlnAns(boolean ans) {
			if(ans)
				println(YES);
			else
				println(NO);
		}

		public void printAns(long[] arr){
			if(arr != null && arr.length > 0){
				print(arr[0]);
				for(int i=1; i<arr.length; i++){
					print(" ");
					print(arr[i]);
				}
			}
		}
		public void printlnAns(long[] arr){
			printAns(arr);
			println();
		}

		public void printAns(int[] arr){
			if(arr != null && arr.length > 0){
				print(arr[0]);
				for(int i=1; i<arr.length; i++){
					print(" ");
					print(arr[i]);
				}
			}
		}
		public void printlnAns(int[] arr){
			printAns(arr);
			println();
		}

		public <T> void printAns(ArrayList<T> arr){
			if(arr != null && arr.size() > 0){
				print(arr.get(0));
				for(int i=1; i<arr.size(); i++){
					print(" ");
					print(arr.get(i));
				}
			}
		}
		public <T> void printlnAns(ArrayList<T> arr){
			printAns(arr);
			println();
		}

		public void printAns(int[] arr, int add){
			if(arr != null && arr.length > 0){
				print(arr[0]+add);
				for(int i=1; i<arr.length; i++){
					print(" ");
					print(arr[i]+add);
				}
			}
		}
		public void printlnAns(int[] arr, int add){
			printAns(arr, add);
			println();
		}

		public void printAns(ArrayList<Integer> arr, int add) {
			if(arr != null && arr.size() > 0){
				print(arr.get(0)+add);
				for(int i=1; i<arr.size(); i++){
					print(" ");
					print(arr.get(i)+add);
				}
			}
		}

		public void printlnAns(ArrayList<Integer> arr, int add){
			printAns(arr, add);
			println();
		}

		public void printlnAnsSplit(long[] arr, int split){
			if(arr != null){
				for(int i=0; i<arr.length; i+=split){
					print(arr[i]);
					for(int j=i+1; j<i+split; j++){
						print(" ");
						print(arr[j]);
					}
					println();
				}
			}
		}

		public void printlnAnsSplit(int[] arr, int split){
			if(arr != null){
				for(int i=0; i<arr.length; i+=split){
					print(arr[i]);
					for(int j=i+1; j<i+split; j++){
						print(" ");
						print(arr[j]);
					}
					println();
				}
			}
		}

		public <T> void printlnAnsSplit(ArrayList<T> arr, int split){
			if(arr != null && !arr.isEmpty()){
				for(int i=0; i<arr.size(); i+=split){
					print(arr.get(i));
					for(int j=i+1; j<i+split; j++){
						print(" ");
						print(arr.get(j));
					}
					println();
				}
			}
		}
	}

	static private void permutateAndSort(long[] a) {
		int n = a.length;
		Random R = new Random(System.currentTimeMillis());
		for(int i=0; i<n; i++) {
			int t = R.nextInt(n-i);
			long temp = a[n-1-i];
			a[n-1-i] = a[t];
			a[t] = temp;
		}
		Arrays.sort(a);
	}

	static private void permutateAndSort(int[] a) {
		int n = a.length;
		Random R = new Random(System.currentTimeMillis());
		for(int i=0; i<n; i++) {
			int t = R.nextInt(n-i);
			int temp = a[n-1-i];
			a[n-1-i] = a[t];
			a[t] = temp;
		}
		Arrays.sort(a);
	}

	static private int[][] constructChildren(int n, int[] parent, int parentRoot){
		int[][] childrens = new int[n][];

		int[] numChildren = new int[n];
		for(int i=0; i<parent.length; i++) {
			if(parent[i] != parentRoot)
				numChildren[parent[i]]++;
		}

		for(int i=0; i<n; i++) {
			childrens[i] = new int[numChildren[i]];
		}

		int[] idx = new int[n];
		for(int i=0; i<parent.length; i++) {
			if(parent[i] != parentRoot)
				childrens[parent[i]][idx[parent[i]]++] = i;
		}

		return childrens;
	}

	static private int[][][] constructDirectedNeighborhood(int n, int[][] e){
		int[] inDegree = new int[n];
		int[] outDegree = new int[n];
		for(int i=0; i<e.length; i++) {
			int u = e[i][0];
			int v = e[i][1];
			outDegree[u]++;
			inDegree[v]++;
		}

		int[][] inNeighbors = new int[n][];
		int[][] outNeighbors = new int[n][];
		for(int i=0; i<n; i++) {
			inNeighbors[i] = new int[inDegree[i]];
			outNeighbors[i] = new int[outDegree[i]];
		}

		for(int i=0; i<e.length; i++) {
			int u = e[i][0];
			int v = e[i][1];
			outNeighbors[u][--outDegree[u]] = v;
			inNeighbors[v][--inDegree[v]] = u;
		}

		return new int[][][] {inNeighbors, outNeighbors};
	}

	static private int[][] constructNeighborhood(int n, int[][] e) {
		int[] degree = new int[n];
		for(int i=0; i<e.length; i++) {
			int u = e[i][0];
			int v = e[i][1];
			degree[u]++;
			degree[v]++;
		}

		int[][] neighbors = new int[n][];
		for(int i=0; i<n; i++)
			neighbors[i] = new int[degree[i]];

		for(int i=0; i<e.length; i++) {
			int u = e[i][0];
			int v = e[i][1];
			neighbors[u][--degree[u]] = v;
			neighbors[v][--degree[v]] = u;
		}

		return neighbors;
	}

	static private void drawGraph(int[][] e) {
		makeDotUndirected(e);
		try {
			final Process process = new ProcessBuilder("dot", "-Tpng", "graph.dot")
					.redirectOutput(new File("graph.png"))
					.start();
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

	}

	static private void makeDotUndirected(int[][] e) {
		MyPrintWriter out2 = null;
		 try {
			out2 = new MyPrintWriter(new FileOutputStream("graph.dot"));
		} catch (FileNotFoundException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		out2.println("strict graph {");
		for(int i=0; i<e.length; i++){
			out2.println(e[i][0] + "--" + e[i][1] + ";");
		}
		out2.println("}");
		out2.close();
	}

	static private void makeDotDirected(int[][] e) {
		MyPrintWriter out2 = null;
		 try {
			out2 = new MyPrintWriter(new FileOutputStream("graph.dot"));
		} catch (FileNotFoundException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		out2.println("strict digraph {");
		for(int i=0; i<e.length; i++){
			out2.println(e[i][0] + "->" + e[i][1] + ";");
		}
		out2.println("}");
		out2.close();
	}

}


/*
 *    Nachiket V Trivedi
 *    DAIICT
 */
import java.util.*;
import java.io.*;
import java.math.*;
public class demo1
{

	public static void main(String[] args)
	{
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		//------Start-----
		long n=in.nextLong();
		int k=in.nextInt();
		TreeSet<Long> al=new TreeSet<Long>();
		for(long i=1;i*i<=n;i++)
		{
			if(n%i==0)
			{
				al.add(i);
				al.add(n/i);
			}
		}

		if(al.size()<k)
			out.println("-1");
		else
		{
			int j=0;
			for(long i:al)
			{
				j++;
				if(j==k)
				{
					out.print(i);
					break;
				}
			}
		}
		//-----The End----
		out.close();
	}
	//start writing new static method here

	//My template methods are here--------------------------------------------------
	static boolean[] sieveOfEratosthenes(int n)//#1
	{
		// Create a boolean array "prime[0..n]" and initialize
		// all entries it as true. A value in prime[i] will
		// finally be false if i is Not a prime, else true.
		boolean prime[] = new boolean[n+1];
		for(int i=0;i<n;i++)
			prime[i] = true;

		for(int p = 2; p*p <=n; p++)
		{
			// If prime[p] is not changed, then it is a prime
			if(prime[p] == true)
			{
				// Update all multiples of p
				for(int i = p*2; i <= n; i += p)
					prime[i] = false;
			}
		}
		return prime;

	}
	static TreeSet primeFactors(long n)//#2
	{
		TreeSet<Long> ts=new TreeSet();
		while(n%2==0)
		{
			ts.add((long)2);
			n=n/2;
		}
		for(long i=3;i<=Math.sqrt(n);i+=2)
		{
			while(n%i==0)
			{
				ts.add(i);
				n=n/i;
			}
		}
		if(n>2)
			ts.add(n);
		return ts;
	}
	static boolean isPrime(long num)//#3
	{
		if (num < 2) return false;
		if (num == 2) return true;
		if (num % 2 == 0) return false;
		for (int i = 3; i * i <= num; i += 2)
			if (num % i == 0) return false;
		return true;
	}
	static long modular_exponentiation(long a, long b, long c)// calculates (a^b)%c
	{
		//while calling this function pass a as a%m and IF c in prime then pass b as b%(m-1)..coz of fermet's theorem
		//if c is not prime then pass only b.
		a=a%c;
		if(b == 0)
			return 1;
		if(b == 1)
			return a%c;
		else if( b%2 == 0)                                           //if b is even
		{
			return modular_exponentiation((a *a)%c,b/2,c);
		}
		else                                                                    // if b is odd.
		{
			return (a*modular_exponentiation((a*a%c),b/2,c))%c;
		}
	}
	static int findGCD(int number1, int number2) //complexity O(log(max(n1,n2)))
	{
		if(number2 == 0)
			return number1;
		return findGCD(number2, number1%number2);
	}
	static void extendedEuclid(int A, int B) {
		//gcd(A,B)=Ax+By....this calculates the coefficients...
		//make those variables global and open these comments
		if(B == 0)
		{
			//	        gcd = A;
			//	        x = 1;
			//	        y = 0;
		}
		else
		{
			extendedEuclid(B, A%B);
			//			int temp = x;
			//			x = y;
			//			y = temp - (A/B)*y;
		}
	}

	static void modInverse(int A, int M)
	{
		//A and M must be coprime for modinverse to exist.
		//If M is prime the call modexponentiation(A,M-2,M)
	    extendedEuclid(A,M);
	    //return (x%M+M)%M;    //this is x of Ax+By=GCD from euclid...x may be negative
	}
	static void debug(Object... o)// to print any object like an array
	{
		System.out.println(Arrays.deepToString(o));
	}
	static public ArrayList<ArrayList<Integer>> FindAllsubsets(int[] S)//2^n complexity
	{
		if (S == null)
			return null;
		Arrays.sort(S);
		ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>();
		for (int i = 0; i < S.length; i++) {
			ArrayList<ArrayList<Integer>> temp = new ArrayList<ArrayList<Integer>>();
			//get sets that are already in result
			for (ArrayList<Integer> a : result) {
				temp.add(new ArrayList<Integer>(a));
			}
			//add S[i] to existing sets
			for (ArrayList<Integer> a : temp) {
				a.add(S[i]);
			}
			//add S[i] only as a set
			ArrayList<Integer> single = new ArrayList<Integer>();
			single.add(S[i]);
			temp.add(single);
			result.addAll(temp);
		}
		//add empty set
		result.add(new ArrayList<Integer>());
		return result;
	}
	static int greatestIndexNotExceeding(int[] data, int limit, int lb, int ub)
	{
		final int mid = (lb + ub) / 2;
		// Need to go lower but can't
		if (mid == lb && data[mid] > limit)
			return -1;
		// Found a candidate, and can't go higher
		if (data[mid] <= limit && (mid == ub || data[mid + 1] > limit))
			return mid;
		if (data[mid] <= limit)
			// Consider upper half
			return greatestIndexNotExceeding(data, limit, mid + 1, ub);
		else
			// Consider lower half
			return greatestIndexNotExceeding(data, limit, lb, mid);
	}

	//Pair class is here
	static class Pair implements Comparable<Pair>
	{
		long u;
		long v;
		BigInteger bi;
		public Pair(long u, long v) {
			this.u = u;
			this.v = v;
		}

		public int hashCode() {
			int hu = (int) (u ^ (u >>> 32));
			int hv = (int) (v ^ (v >>> 32));
			return 31 * hu + hv;
		}

		public boolean equals(Object o) {
			Pair other = (Pair) o;
			return u == other.u && v == other.v;
		}

		public int compareTo(Pair other) {
			return Long.compare(u, other.u) != 0 ? Long.compare(u, other.u) : Long.compare(v, other.v);
		}

		public String toString() {
			return "[u=" + u + ", v=" + v + "]";
		}
	}
	//End of My Templates-----------------InputReader class starts from here--------------------------------------------------------------
	public static class InputReader
	{
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream inputstream)
		{
			reader = new BufferedReader(new InputStreamReader(inputstream));
			tokenizer = null;
		}

		public String nextLine()
		{
			String fullLine=null;
			while (tokenizer == null || !tokenizer.hasMoreTokens())
			{
				try
				{
					fullLine=reader.readLine();
				}
				catch (IOException e)
				{
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}
		public String next()
		{
			while (tokenizer == null || !tokenizer.hasMoreTokens())
			{
				try
				{
					tokenizer = new StringTokenizer(reader.readLine());
				}
				catch (IOException e)
				{
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public long nextLong()
		{
			return Long.parseLong(next());
		}
		public int nextInt()
		{
			return Integer.parseInt(next());
		}
	}

}

//---------------------------------------------------------------


import java.util.*;

public class CF560BGetaldIntoArts {
    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);
        boolean b = true;

        int a1 = s.nextInt();
        int b1 = s.nextInt();
        int a2 = s.nextInt();
        int b2 = s.nextInt();
        int a3 = s.nextInt();
        int b3 = s.nextInt();

        if(a1 >= Math.max(a2,a3) && b2+b3<=b1) b = true;

        else if(a1 >= Math.max(a2,b3) && b2+a3<=b1) b = true;

        else if(a1 >= Math.max(a3,b2) && b3+a2<=b1) b = true;

        else if(a1 >= Math.max(b2,b3) && a2+a3<=b1) b = true;
        else b = false;

        if(b1 >= Math.max(a2,a3) && b2+b3<=a1) b = true;

        else if(b1 >= Math.max(a2,b3) && b2+a3<=a1) b = true;

        else if(b1>=Math.max(a3,b2) && b3+a2<=a1) b = true;

        else if(b1>=Math.max(b2,b3) && a2+a3<=a1) b = true;

        if(b == false){
            System.out.println("NO");
        }
        else System.out.println("YES");

    }
}


//package com.company;

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

public class Main {
    public static class Task {
        public class Number {
            int factNum;
            int[] primeFactorCounts;
            int largestFactor;
            int S = 0;
            public Number(int f, int[] primeFactorCounts) {
                this.factNum = f;
                this.primeFactorCounts = primeFactorCounts;
                for (largestFactor = primeFactorCounts.length - 1; largestFactor >= 0; largestFactor--) {
                    if (primeFactorCounts[largestFactor] != 0) break;
                }
                for (int y: primeFactorCounts)S += y;
            }
            int getL() {
                if (largestFactor == -1) return -1;
                int r = largestFactor;
                primeFactorCounts[r]--;
                if (primeFactorCounts[r] == 0) largestFactor--;
                return r;
            }
        }

        List<Integer> primes;
        int[] factor;

        public void precompute() {
            int n = 5001;
            primes = new ArrayList<>();
            factor = new int[n];
            Arrays.fill(factor, -1);
            for (int i = 2; i < n; ++i) {
                if (factor[i] == -1) {
                    factor[i] = primes.size();
                    primes.add(i);
                }
                for (int j = 0; j < primes.size () && i * primes.get(j) < n; ++j) {
                    int p = primes.get(j);
                    factor[i * p] = j;
                    if (i % p == 0) {
                        break;
                    }
                }
            }
        }

        List<Integer> fact(int x) {
            List<Integer> retL = new ArrayList<>();
            while (x != 1) {
                retL.add(factor[x]);
                x /= primes.get(factor[x]);
            }
            return retL;
        }

        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            precompute();
            int[] primeF = new int[700];
            Number[] numbers = new Number[5001];
//            numbers[0] = new Number(1, Arrays.copyOf(primeF, 700));
            numbers[1] = new Number(1, Arrays.copyOf(primeF, 700));
            for (int i = 2; i <= 5000; i++) {
                List<Integer> f = fact(i);
                for (int y: f) primeF[y]++;
                numbers[i] = new Number(i, Arrays.copyOf(primeF, 700));
            }
//            pw.println(Arrays.toString(numbers[5000].primeFactorCounts));
//            System.err.println(numbers[5000].S);
            Map<Integer, Integer> numToCount = new HashMap<>();
            int n = sc.nextInt();
            for (int i = 0; i < n; i++) {
                int a = sc.nextInt();
                a = Math.max(a, 1);
                numToCount.put(a, numToCount.getOrDefault(a, 0) + 1);
            }
            long total = 0;
            for (Map.Entry<Integer, Integer> en : numToCount.entrySet()) {
                total += (long) en.getValue() * numbers[en.getKey()].S;
            }
            outer:
            while (true) {
                Map<Integer, Integer> kG = new HashMap<>();
                for (Map.Entry<Integer, Integer> en : numToCount.entrySet()) {
                    int k = en.getKey();
                    int v = en.getValue();
                    int lf = numbers[k].largestFactor;
                    if (lf == -1) continue ;
                    kG.put(lf, kG.getOrDefault(lf, 0) + v);
                }
                for (Map.Entry<Integer, Integer> en: kG.entrySet()) {
                    if (n - en.getValue() < en.getValue()) {
                        total -= en.getValue() - (n - en.getValue());
                        Map<Integer, Integer> nC = new HashMap<>();
                        for (Map.Entry<Integer, Integer> en1 : numToCount.entrySet()) {
                            int lf = numbers[en1.getKey()].getL();
                            if (lf == en.getKey()) {
                                nC.put(en1.getKey(), en1.getValue());
                            }
                        }
                        numToCount = nC;
                        continue outer;
                    }
                }
                pw.println(total);
                return;
            }
        }
    }

    static long TIME_START, TIME_END;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//        Scanner sc = new Scanner(new FileInputStream("input"));
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
//        PrintWriter pw = new PrintWriter(new FileOutputStream("output"));

        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
        System.err.println("Memory increased: " + (usedMemoryAfter - usedMemoryBefore) / 1000000);
        System.err.println("Time used: " + (TIME_END - TIME_START) + ".");
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

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

        public Scanner(FileReader s) throws FileNotFoundException {
            br = new BufferedReader(s);
        }

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

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

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

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

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

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


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

public class A741 {
	static int min;
	static boolean[] visited;
	static int[] adj;
	static long[] cyc;
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		adj = new int[n];
		visited = new boolean[n];
		cyc = new long[n];
		TreeSet<Integer> set = new TreeSet<>();
		for(int i = 0;i<n;i++)
		{
			adj[i] = sc.nextInt()-1;
			set.add(adj[i]);
		}

		if(set.size()<adj.length)
		{
			System.out.println(-1);
			return;
		}

		for(int i = 0;i<n;i++)
		{
			visited = new boolean[n];
			dfs(i,i,0);
		}

		System.out.println(lcm(cyc));
	}
	static void dfs(int u, int t, int steps){
		if(visited[u])
			if(u==t)
			{
				if(steps%2==0)
					steps = steps/2;

				cyc[t] = steps;
				return;
			}
			else
				return;

		visited[u] = true;

		dfs(adj[u],t,steps+1);
	}
	static long gcd(long a, long b)
	{
	    while (b > 0)
	    {
	        long temp = b;
	        b = a % b; // % is remainder
	        a = temp;
	    }
	    return a;
	}

	static long gcd(long[] input)
	{
	    long result = input[0];
	    for(int i = 1; i < input.length; i++) result = gcd(result, input[i]);
	    return result;
	}
	static long lcm(long a, long b)
	{
	    return a * (b / gcd(a, b));
	}

	static long lcm(long[] input)
	{
	    long result = input[0];
	    for(int i = 1; i < input.length; i++) result = lcm(result, input[i]);
	    return result;
	}
	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

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

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

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

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

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

		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}

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

	}
}


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

public class R400qE {

  static int mod = 1000000007;

  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter w = new PrintWriter(System.out);

    long n = in.nextLong();
    long k = (in.nextLong() + 1) / 2;

    while (n > 1 && k > 0) {
      n = phi(n);
      k--;
    }

    w.println(n % mod);
    w.close();
  }

  static long phi(long n) {
    long result = n;
    for (long p = 2; p * p <= n; ++p) {
      if (n % p == 0) {
        while (n % p == 0)
          n /= p;
        result /= p;
        result *= p - 1;
      }
    }

    if (n > 1) {
      result /= n;
      result *= n - 1;
    }

    return result;
  }

  static int f(int n) {
    if (n == 1) {
      return 1;
    }
    int ans = 0;
    for (int i = 1; i < n; i++) {
      if (gcd(i, n - i) == 1) {
        ans++;
      }
    }
    return ans;
  }

  static int g(int n) {
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      if (n % i == 0) {
        ans += f(n / i);
      }
    }
    return ans;
  }

  public static int gcd(int a, int b) {
    while (b != 0) {
      int t = b;
      b = a % b;
      a = t;
    }
    return a;
  }

  static class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;

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

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

    public int nextInt() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      int res = 0;
      do {
        res *= 10;
        res += c - '0';
        c = read();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public long nextLong() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      long res = 0;
      do {
        res *= 10;
        res += c - '0';
        c = read();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

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

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

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

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

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

  }

}


import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

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

static class Solver {

	int hm, am, dm, hy;
    public void solve(int testNumber, InputReader in, PrintWriter out) {
    	hy = in.nextInt();
    	int ay = in.nextInt();
    	int dy = in.nextInt();
    	hm = in.nextInt();
    	am = in.nextInt();
    	dm = in.nextInt();
    	int hc = in.nextInt();
    	int ac = in.nextInt();
    	int dc = in.nextInt();
    	long ans = Long.MAX_VALUE;
		for (int a = 0; a < 200; a++) {
			for (int d = 0; d < 200; d++) {
				int h = hpToWin(a+ay, d+dy);
				if (h == -1) continue;
				long cost = h*hc + a*ac + d*dc;
				ans = Math.min(ans, cost);
			}
		}
    	System.out.println(ans);
    }

    public int hpToWin(int ay, int dy) {
    	if (ay-dm <= 0) return -1; //impossible
    	if (am-dy <= 0) return 0;

    	double turns = (double)hm / (double)(ay-dm);
    	int turnY = (int) Math.ceil(turns);

    	// so you need turnY+1 and take am-dy per turn
    	return Math.max(0, turnY * (am-dy) + 1 - hy);
    }

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

}

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

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

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

    public int nextInt() {
        return Integer.parseInt(next());
    }
    public long nextLong() {
        return Long.parseLong(next());
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}
}


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

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

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String a = in.nextLine();
            int n = in.nextInt();
            String cw = "^>v<";
            String ccw = "^<v>";
            boolean iscw = false;
            boolean isccw = false;

            int id = 0;
            for (int i = 0; i < 4; i++) {
                if (a.charAt(0) == cw.charAt(i))
                    id = i;
            }
            id = (id + n) % 4;

            if (cw.charAt(id) == a.charAt(2)) {
                iscw = true;
            }

            id = 0;
            for (int i = 0; i < 4; i++) {
                if (a.charAt(0) == ccw.charAt(i))
                    id = i;
            }
            id = (id + n) % 4;
            if (ccw.charAt(id) == a.charAt(2)) {
                isccw = true;
            }

            if (iscw == isccw)
                out.print("undefined");
            else if (iscw)
                out.print("cw");
            else
                out.print("ccw");
        }

    }
}