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

public class spit
{
  public static void main (String[] args) throws IOException
  {
     StringTokenizer st= new StringTokenizer(in.readLine());
     int n=Integer.parseInt(st.nextToken());
     int[] x=new int[n];
     int[] d=new int[n];
     for (int i=0;i<n;i++)
     {
       st=new StringTokenizer(in.readLine());
       x[i]=Integer.parseInt(st.nextToken());
       d[i]=Integer.parseInt(st.nextToken());
     }
     boolean bo=false;
     for (int i=0;i<n;i++)
       for (int j=0;j<n;j++)
       if (i!=j)
     {
       if ((x[i]+d[i]==x[j]) && (x[j]+d[j]==x[i])) bo=true;
     }
     if (bo) out.println("YES"); else out.println("NO");
     out.flush();
     in.readLine();
  }

  private static BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
  private static PrintWriter out=new PrintWriter(
                         new BufferedWriter(new OutputStreamWriter(System.out)));
}


import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class test
{
	private static class Triple
	{
		public int h;
		public int w;
		public int r;

		public Triple(int h, int w, int r)
		{
			this.h = h;
			this.w = w;
			this.r = r;
		}
	}

	private static int n;
	private static int k;
	private static int t;

	private static Triple[] data;

	private static int f(int num)
	{
		int answer = 0;
		int[] male = new int[n];
		int[] fema = new int[n];

		for(int i = 0;i<k;i++)
		{
			if(num%2 == 1)
			{
				male[data[i].h]++;
				fema[data[i].w]++;
				answer += data[i].r;
			}
			num/=2;
		}

		for(int i = 0;i<n;i++)
		{
			if(male[i] > 1 || fema[i] > 1)
			{
				return -1;
			}
		}
		return answer;
	}

	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		k = sc.nextInt();
		t = sc.nextInt() - 1;

		data = new Triple[k];

		for(int i = 0;i<k;i++)
		{
			int h = sc.nextInt() - 1;
			int w = sc.nextInt() - 1;
			int r = sc.nextInt();
			data[i] = new Triple(h, w, r);
		}

		int MAX = 1 << k;

		ArrayList<Integer> answer = new ArrayList<Integer>();
		for(int i = 0; i < MAX; i++)
		{
			int test = f(i);
			if(test >= 0)
			{
				answer.add(test);
			}
		}
		Collections.sort(answer);
		System.out.println( answer.get(t) );

    }

}


import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class test
{
	private static class Triple
	{
		public int h;
		public int w;
		public int r;

		public Triple(int h, int w, int r)
		{
			this.h = h;
			this.w = w;
			this.r = r;
		}
	}

	private static int n;
	private static int k;
	private static int t;

	private static Triple[] data;

	private static int f(int num)
	{
		int answer = 0;
		int[] male = new int[n];
		int[] fema = new int[n];

		for(int i = 0;i<k;i++)
		{
			if(num%2 == 1)
			{
				male[data[i].h]++;
				fema[data[i].w]++;

				if(male[data[i].h] > 1 || fema[data[i].w] > 1)
				{
					return -1;
				}
				answer += data[i].r;
			}
			num/=2;
		}
		return answer;
	}

	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		k = sc.nextInt();
		t = sc.nextInt() - 1;

		data = new Triple[k];

		for(int i = 0;i<k;i++)
		{
			int h = sc.nextInt() - 1;
			int w = sc.nextInt() - 1;
			int r = sc.nextInt();
			data[i] = new Triple(h, w, r);
		}

		int MAX = 1 << k;

		ArrayList<Integer> answer = new ArrayList<Integer>();
		for(int i = 0; i < MAX; i++)
		{
			int test = f(i);
			if(test >= 0)
			{
				answer.add(test);
			}
		}
		Collections.sort(answer);
		System.out.println( answer.get(t) );

    }

}


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

import static java.lang.Math.*;

public class F implements Runnable{

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            try{
                tok = new StringTokenizer(in.readLine());
            }catch (Exception e){
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException{
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException{
        return Double.parseDouble(readString());
    }

    public static void main(String[] args){
        new Thread(null, new F(), "", 256 * (1L << 20)).start();
    }

    long timeBegin, timeEnd;

    void time(){
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory(){
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10) + " KB");
    }

    void debug(Object... objects){
        if (DEBUG){
            for (Object o: objects){
                System.err.println(o.toString());
            }
        }
    }

    public void run(){
        try{
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            time();
            memory();
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    boolean DEBUG = false;

    void solve() throws IOException{
        int n = readInt();

        int k = readInt();

        int t = readInt();
        int[] h = new int[k];
        int[] w = new int[k];
        int[] r = new int[k];

        for (int i = 0; i < k; i++){
            h[i] = readInt() - 1;
            w[i] = readInt() - 1;
            r[i] = readInt();
        }

        boolean[] usedH = new boolean[n];
        boolean[] usedW = new boolean[n];

        long lim = (1L << k);

        ArrayList<Long> list = new ArrayList<Long>();
    mask:   for (long i = 0; i < lim; i++){
            Arrays.fill(usedH, false);
            Arrays.fill(usedW, false);
            long res = 0;
            for (int j = 0; j < k; j++){
                if ((i & (1 << j)) == 0) continue;
                if (usedH[h[j]]) continue mask;
                if (usedW[w[j]]) continue mask;

                res += r[j];
                usedH[h[j]] = usedW[w[j]] = true;
            }

            list.add(res);
        }

        Collections.sort(list);

        out.print(list.get(t - 1));
    }
}


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

public class F {

	BufferedReader in;
	StringTokenizer st;
	PrintWriter out;

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

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

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

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

	void solve() throws Exception {
		int n = nextInt(), k = nextInt(), req = nextInt();
		int upd[] = new int[k];
		int cost[] = new int[k];

		int cnt = 0;
		for (int i = 0; i < k; i++) {
			int q = nextInt() - 1, w = nextInt() - 1 + n;
			upd[i] = (1 << q) + (1 << w);
			cost[i] = nextInt();
		}
		ArrayList<Integer> all = new ArrayList<Integer>();
		for (int i = 0; i < (1 << k); i++) {
			boolean sat = true;
			int ti = i;
			int mask = 0;
			int ans = 0;
			for (int j = 0; j < k && sat; j++) {
				if (i % 2 == 0) {
					sat &= ((mask & upd[j]) == 0);
					mask |= upd[j];
					ans += cost[j];
				}
				i /= 2;
			}

			if (sat)
				all.add(ans);
			i = ti;
		}

		int q = all.size();
		int a[] = new int[q];
		for (int i = 0; i < q; i++)
			a[i] = all.get(i);
		Arrays.sort(a);
		out.println(a[req - 1]);
	}

	void run() {
		try {
			Locale.setDefault(Locale.US);
			boolean oj = System.getProperty("ONLINE_JUDGE") != null;
			Reader reader = oj ? new InputStreamReader(System.in) : new FileReader("input.txt");
			Writer writer = oj ? new OutputStreamWriter(System.out) : new FileWriter("output.txt");
			in = new BufferedReader(reader);
			out = new PrintWriter(writer);
			solve();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

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

	}

}


import java.util.*;

import static java.util.Arrays.stream;
import static java.util.stream.Collectors.toMap;

public class Main {
    static int n;
    static char[] chars;
    static int[] vals;

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

        n = sc.nextInt();
        sc.nextLine();
        String s = sc.nextLine().trim();
        chars = s.toCharArray();

        vals = new int[n];
        for (int i = 0; i < n; i ++) {
            vals[i] = sc.nextInt();
        }
        sc.nextLine();

        List<Char> wrongChars = new ArrayList<>();
        List<Char> chars1 = new ArrayList<>();
        for (int i = 0; i < n / 2; i++) {
            if (vals[i] > vals[n - i - 1]) {
                swap(i);
            }

            Char chr = new Char(chars[i], vals[i], i);
            if (chars[i] == chars[n - i - 1]) {
                wrongChars.add(chr);
            }
            chars1.add(chr);
        }
        chars1.sort(Comparator.comparing(c -> c.val));

        int diff = 0;
//        int[] vals1 = Arrays.copyOf(vals, n/2);
        if (!isAntiPalindrome(chars)) {
            if (wrongChars.size() == 1) {
                Char wrongChar = wrongChars.get(0);
                for (int i = 0; i < n/2; i++) {
                    Char chr = chars1.get(i);
                    if (chr.chr != wrongChar.chr && chars[n - chr.idx - 1] != wrongChar.chr) {
                        diff = wrongChar.val + chr.val;
                        break;
                    }
                }
            } else if (wrongChars.size() > 1) {
                Map<Character, Integer> map = wrongChars.stream().collect(toMap(n -> n.chr, n -> 1, (a, b) -> a+1, TreeMap::new));
                Map.Entry<Character, Integer> max = map.entrySet().stream().max(Comparator.comparing(Map.Entry::getValue)).get();
                List<Char> append = new ArrayList<>();
                while (max.getValue() * 2 > wrongChars.size() + append.size()) {
                    Character maxChar = max.getKey();
                    for (int i = 0; i < n/2; i++) {
                        Char chr = chars1.get(i);
                        if (chr.chr != maxChar && chars[n - chr.idx - 1] != maxChar && !wrongChars.contains(chr)) {
                            append.add(chr);
                            break;
                        }
                    }
                }
                diff = wrongChars.stream().mapToInt(chr -> chr.val).sum() + append.stream().mapToInt(chr -> chr.val).sum();
            }
        }

        int sum = stream(vals).sum();
        System.out.println(sum - diff);
    }

    private static void swap(int i) {
        char tmp = chars[i];
        chars[i] = chars[n - i - 1];
        chars[n - i - 1] = tmp;

        int tmpVal = vals[i];
        vals[i] = vals[n - i - 1];
        vals[n - i - 1] = tmpVal;
    }

    private static void swap(int i, int j) {
        char tmp = chars[i];
        chars[i] = chars[j];
        chars[j] = tmp;

        int tmpVal = vals[i];
        vals[i] = vals[n - i - 1];
        vals[n - i - 1] = tmpVal;
    }

    private static boolean isAntiPalindrome(char[] chars) {
        int n = chars.length;
        for (int i = 0; i < n/2; i++) {
            if (chars[i] == chars[n - i - 1]) {
                return false;
            }
        }
        return true;
    }

    static class Char {
        char chr;
        int val;
        int idx;

        Char(char chr, int val, int idx) {
            this.chr = chr;
            this.val = val;
            this.idx = idx;
        }

        @Override
        public String toString() {
            return "Char{" +
                    "chr=" + chr +
                    ", val=" + val +
                    ", idx=" + idx +
                    '}';
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.*;

/**
 * Created by nadya on 28/10/17.
 */
public class Educational {
    public static void main(String[] args) throws IOException {
        Educational c = new Educational();
        c.start();
    }

    private void start() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer str = new StringTokenizer(in.readLine());
        int n = Integer.parseInt(str.nextToken());
        String s = in.readLine();
        int b[] = new int[n];
        TreeMap<Integer, Set<Integer>> w = new TreeMap<Integer, Set<Integer>>();
        w.put(0, new HashSet<Integer>());

        str = new StringTokenizer(in.readLine());
        for (int i = 0; i < n; ++i) {
            b[i] = Integer.parseInt(str.nextToken());
            if (!w.containsKey(b[i])) w.put(b[i], new HashSet<Integer>());
            w.get(b[i]).add(i);
        }
        char[] res = s.toCharArray();

        ArrayList<Integer> waitingList = new ArrayList<Integer>();
        for (int i = 0; i < n / 2; ++i) {
            if (res[i] == res[getvisavis(n, i)]) {
                if (waitingList.isEmpty()) {
                    waitingList.add(i);
                } else {
                    for (Integer j : waitingList) {
                        if (res[j] != res[i]) {
                            int minB1 = b[j] < b[getvisavis(n, j)] ? j : getvisavis(n, j);
                            int minB2 = b[i] < b[getvisavis(n, i)] ? i : getvisavis(n, i);
                            swap(res, minB1, minB2);
                            b[minB1] = 0;
                            b[minB2] = 0;
                            waitingList.remove(j);
                            break;
                        }
                    }
                    waitingList.add(i);
                }
            }
        }

        for (int i = 0; i < n; ++i) {
            // if (b[i] == 0) continue;
            if (!w.containsKey(b[i])) w.put(b[i], new HashSet<Integer>());
            w.get(b[i]).add(i);
        }

        for (int i = 0; i < n / 2; ++i) {
            if (res[i] == res[getvisavis(n, i)]) {

                boolean finished = false;

                int indexToChange = b[i] < b[getvisavis(n, i)] ? i : getvisavis(n, i);

                for (Map.Entry<Integer, Set<Integer>> l : w.entrySet()) {
                    Set<Integer> candidates = l.getValue();
                    for (Integer j : candidates) {
                        if (j == i || j == indexToChange || res[indexToChange] == res[j] || res[indexToChange] == res[getvisavis(n, j)]) {
                            continue;
                        }

                        swap(res, indexToChange, j);

                        b[j] = 0;
                        b[indexToChange] = 0;

                        w.get(0).add(j);
                        w.get(0).add(indexToChange);

                        w.get(b[indexToChange]).remove(indexToChange);
                        w.get(b[j]).remove(j);

                        finished = true;
                        break;
                    }

                    if (finished) break;
                }
                if (res[i] == res[getvisavis(n, i)]) System.out.println("alarma");
            }
        }
        for (int i = 0; i < n / 2; ++i) {
            if (res[i] == res[getvisavis(n, i)]) {
                System.out.println("FFFF");
            }
        }

        int sum = 0;
        for (int i = 0; i < n; ++i) {
            //if (!changed[i]) {
            sum += b[i];
            // }
        }

        System.out.println(sum);
    }

    public static int getvisavis(int n, int i) {
        return n - i - 1;
    }

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


import com.sun.javafx.geom.Edge;

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

public class F {

	static final int INF = (int)1e9;
	static ArrayList<Integer>[] adjList;
	static int[][] res, cost;
	static int[] p;

	static void addEdge(int u, int v, int c, int w)
	{
		adjList[u].add(v);
		adjList[v].add(u);
		res[u][v] = c;
		cost[u][v] = w;
		cost[v][u] = -w;
	}

	static int augment(int v, int flow)
	{
		if(v == src)
			return flow;
		int u = p[v];
		flow = augment(u, Math.min(flow, res[u][v]));
		res[u][v] -= flow;
		res[v][u] += flow;
		totalCost += flow * cost[u][v];
		return flow;
	}

	static int totalCost;

	static int mcmf(int V)
	{
		totalCost = 0;

		while(true)
		{
			p = new int[V];
			Arrays.fill(p, -1);
			p[0] = 0;
			int[] dist = new int[V];
			Arrays.fill(dist, INF);
			dist[0] = 0;
			for(int k = 0; k < V - 1; ++k)
				for(int u = 0; u < V; ++u)
					for(int v: adjList[u])
						if(res[u][v] > 0 && dist[v] > dist[u] + cost[u][v])
						{
							dist[v] = dist[u] + cost[u][v];
							p[v] = u;
						}

			if(p[sink] == -1)
				break;
			augment(sink, INF);
		}
		return totalCost;
	}

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

		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();
		int[] f = new int[26];
		for(char c: s)
			f[c - 'a']++;
		int[] beu = new int[n];
		int sum = 0;
		for(int i = 0; i < n; ++i)
			sum += beu[i] = sc.nextInt();

		int gateOffset = 2, nodeOffset = gateOffset + n / 2 * 26, charOffset = nodeOffset + n;
		int V = charOffset + 26;
		res = new int[V][V];
		cost = new int[V][V];
		adjList = new ArrayList[V];
		for(int i = 0; i < V; ++i)
			adjList[i] = new ArrayList<>(1);

		// Source and Sink
		src = 0; sink = 1;

		// Source -> Indices Nodes -> Limiter Gates
		for(int i = 0; i < n; ++i)
		{
			addEdge(src, nodeOffset + i, 1, 0);
			for(int c = 0; c < 26; ++c)
			{
				int x = i * 2 < n ? i : n - i - 1;
				int gateIn = gateOffset + n / 2 * c + x;
				addEdge(nodeOffset + i, gateIn, 1, s[i] - 'a' == c ? 0 : beu[i]);
			}
		}

		// Limiter Gates -> Characters -> Sink
		for(int c = 0; c < 26; ++c)
		{
			addEdge(charOffset + c, sink, f[c], 0);
			for(int gate = 0; gate < n / 2; ++gate)
				addEdge(gateOffset + n / 2 * c + gate, charOffset + c, 1, 0);
		}

		out.println(sum - mcmf(V));
		out.close();
	}

	static int src, sink;

	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.util.*;

import static java.util.Arrays.stream;
import static java.util.stream.Collectors.toMap;

public class Main {
    static int n;
    static char[] chars;
    static int[] vals;

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

        n = sc.nextInt();
        sc.nextLine();
        String s = sc.nextLine().trim();
        chars = s.toCharArray();

        vals = new int[n];
        for (int i = 0; i < n; i ++) {
            vals[i] = sc.nextInt();
        }
        sc.nextLine();

        List<Char> wrongChars = new ArrayList<>();
        List<Char> chars1 = new ArrayList<>();
        for (int i = 0; i < n / 2; i++) {
            boolean wrong = false;
            if (chars[i] == chars[n - i - 1]) {
                if (vals[i] > vals[n - i - 1]) {
                    swap(i);
                }
                wrong = true;
            }

            Char chr = new Char(chars[i], vals[i], i);
            if (wrong) wrongChars.add(chr);
            chars1.add(chr);
        }
        chars1.sort(Comparator.comparing(c -> c.val));

        int diff = 0;
//        int[] vals1 = Arrays.copyOf(vals, n/2);
        if (!isAntiPalindrome(chars)) {
            if (wrongChars.size() == 1) {
                Char wrongChar = wrongChars.get(0);
                for (int i = 0; i < n/2; i++) {
                    Char chr = chars1.get(i);
                    if (chr.chr != wrongChar.chr && chars[n - chr.idx - 1] != wrongChar.chr) {
                        diff = wrongChar.val + chr.val;
                        break;
                    }
                }
            } else if (wrongChars.size() > 1) {
                Map<Character, Integer> map = wrongChars.stream().collect(toMap(n -> n.chr, n -> 1, (a, b) -> a+1, TreeMap::new));
                Map.Entry<Character, Integer> max = map.entrySet().stream().max(Comparator.comparing(Map.Entry::getValue)).get();
                List<Char> append = new ArrayList<>();
                while (max.getValue() * 2 > wrongChars.size() + append.size()) {
                    Character maxChar = max.getKey();
                    for (int i = 0; i < n/2; i++) {
                        Char chr = chars1.get(i);
                        if (chr.chr != maxChar && wrongChars.stream().noneMatch(wchr -> chars[n - wchr.idx - 1] != maxChar)) {
                            append.add(chr);
                            break;
                        }
                    }
                }
                diff = wrongChars.stream().mapToInt(chr -> chr.val).sum() + append.stream().mapToInt(chr -> chr.val).sum();
            }
        }

        int sum = stream(vals).sum();
        System.out.println(sum - diff);
    }

    private static void swap(int i) {
        char tmp = chars[i];
        chars[i] = chars[n - i - 1];
        chars[n - i - 1] = tmp;

        int tmpVal = vals[i];
        vals[i] = vals[n - i - 1];
        vals[n - i - 1] = tmpVal;
    }

    private static void swap(int i, int j) {
        char tmp = chars[i];
        chars[i] = chars[j];
        chars[j] = tmp;

        int tmpVal = vals[i];
        vals[i] = vals[n - i - 1];
        vals[n - i - 1] = tmpVal;
    }

    private static boolean isAntiPalindrome(char[] chars) {
        int n = chars.length;
        for (int i = 0; i < n/2; i++) {
            if (chars[i] == chars[n - i - 1]) {
                return false;
            }
        }
        return true;
    }

    static class Char {
        char chr;
        int val;
        int idx;

        Char(char chr, int val, int idx) {
            this.chr = chr;
            this.val = val;
            this.idx = idx;
        }

        @Override
        public String toString() {
            return "Char{" +
                    "chr=" + chr +
                    ", val=" + val +
                    ", idx=" + idx +
                    '}';
        }
    }
}


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 VK16_3F {

	static int B;
	static int P;
	static int Q;

	static long[] iFact;
	static long[] iFact2;

	public static void main0(String[] args) {
		System.out.println(Integer.toUnsignedString(inv(7)));
	}

	static int[] pCnt;
	static int[] cCnt;

	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter printer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		StringTokenizer inputData = new StringTokenizer(reader.readLine());
		B = Integer.parseInt(inputData.nextToken());
		P = Integer.parseInt(inputData.nextToken());
		P = Math.min(P, B);
		Q = Integer.parseInt(inputData.nextToken());

		pCnt = new int[P + 1];
		cCnt = new int[P + 1];

		Arrays.fill(pCnt, 1);// if there are no nights left, irrespective of number of sleeping places and as long as
								// there is at least one bear left, you can always get at most one barrel
		if (P == B) {
			pCnt[0] = 0;
		}

		long ans = 0;
		for (int n = 1; n <= Q; n++) {
			for (int p = 0; p <= P; p++) {
				calculate(p, n);
			}
			int res = n * cCnt[P];
			ans ^= Integer.toUnsignedLong(res);
			int[] temp = pCnt;
			pCnt = cCnt;
			cCnt = temp;
			Arrays.fill(temp, 0);
		}
		printer.println(ans);
		printer.close();
	}

	static void calculate(int p, int n) {
		int b = B - (P - p);
		int endI = Math.min(b, p);

		int sum = 0;
		for (int i = 0; i <= endI; i++) {
			sum += comb(b, i) * pCnt[p - i];
		}
		cCnt[p] = sum;
	}

	static int comb(int n, int k) {
		int num = 1;
		int den = 1;
		int pow2 = 0;

		if (n - k < k) {
			k = n - k;
		}

		for (int i = 1; i <= k; i++) {
			int cPow2 = Integer.numberOfTrailingZeros(i);
			pow2 -= cPow2;
			den = den * (i >> cPow2);

			cPow2 = Integer.numberOfTrailingZeros(n + 1 - i);
			pow2 += cPow2;
			num = num * ((n + 1 - i) >> cPow2);
		}
		return num * inv(den) << pow2;
	}

	static int inv(int n) {
		int x = 1;
		x = x * (2 - x * n); /* Newton's method */
		x = x * (2 - x * n); /* 5 steps enough for 32 bits */
		x = x * (2 - x * n);
		x = x * (2 - x * n);
		x = x * (2 - x * n);
		return x;
	}
}


import static java.lang.Double.parseDouble;
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.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class F {

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

	static void solve() throws Exception {
		int n = nextInt();
		int p = nextInt();
		int q = nextInt();
		if (p >= n) {
			p = n - 1;
		}
		int c[] = new int[p + 1];
		c[0] = 1;
		for (int i = 1, val = 1, pow = 0; i <= p; i++) {
			int mul = n - i + 1;
			int shift = Integer.numberOfTrailingZeros(mul);
			val *= mul >> shift;
			pow += shift;
			mul = i;
			shift = Integer.numberOfTrailingZeros(mul);
			val *= BigInteger.valueOf(mul >> shift).modInverse(BigInteger.valueOf(0x100000000L)).intValue();
			pow -= shift;
			c[i] = pow >= 32 ? 0 : val << pow;
		}
		int ans = 0;
		for (int day = 1; day <= q; day++) {
			int cans = 0;
			for (int i = 0, pow = 1; i <= p; i++, pow *= day) {
				cans += c[i] * pow;
			}
			ans ^= day * cans;
		}
		out.print(ans & 0xffffffffL);
	}

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

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

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

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

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


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

public class VK16_3F {

	static int B;
	static int P;
	static int Q;

	static long[] iFact;
	static long[] iFact2;

	public static void main0(String[] args) {
		System.out.println(Integer.toUnsignedString(inv(7)));
	}

	static int[] numF;
	static int[] numFP;
	static int[] iNumF;

	static int[] denF;
	static int[] denFP;
	static int[] iDenF;

	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter printer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		StringTokenizer inputData = new StringTokenizer(reader.readLine());

		B = Integer.parseInt(inputData.nextToken());
		P = Integer.parseInt(inputData.nextToken());
		P = Math.min(P, B);
		Q = Integer.parseInt(inputData.nextToken());

		numF = new int[P * 2 + 1];
		numF[0] = 1;
		numFP = new int[P * 2 + 1];

		iNumF = new int[P * 2 + 1];

		for (int i = 1; i <= P * 2; i++) {
			int cPow = Integer.numberOfTrailingZeros(B - i + 1);
			numF[i] = numF[i - 1] * ((B - i + 1) >> cPow);
			numFP[i] = numFP[i - 1] + cPow;
		}

		for (int i = 0; i <= P * 2; i++) {
			iNumF[i] = inv(numF[i]);
		}

		denF = new int[P * 2 + 1];
		denF[0] = 1;
		denFP = new int[P * 2 + 1];

		iDenF = new int[P * 2 + 1];

		for (int i = 1; i <= P * 2; i++) {
			int cPow = Integer.numberOfTrailingZeros(i);
			denF[i] = denF[i - 1] * (i >> cPow);
			denFP[i] = denFP[i - 1] + cPow;
		}

		for (int i = 0; i <= P * 2; i++) {
			iDenF[i] = inv(denF[i]);
		}

		int ans = 0;
		for (int n = 1; n <= Q; n++) {
			ans ^= n * calculate(n);
		}
		printer.println(Integer.toUnsignedString(ans));
		printer.close();
	}

	static int calculate(int n) {
		int cPow = 1;
		int sum = 0;
		int endI = Math.min(P, B - 1);
		for (int i = 0; i <= endI; i++) {
			sum += comb(B, i) * cPow;
			cPow *= n;
		}
		return sum;
	}

	static int comb(int n, int k) {
		int off = B - n;
		int cNumF = numF[k + off] * iNumF[off];
		int cNumP = numFP[k + off] - numFP[off];
		return (cNumF * iDenF[k]) << (cNumP - denFP[k]);
	}

	static int inv(int n) {
		int x = 1;
		x = x * (2 - x * n); /* Newton's method */
		x = x * (2 - x * n); /* 5 steps enough for 32 bits */
		x = x * (2 - x * n);
		x = x * (2 - x * n);
		x = x * (2 - x * n);
		return x;
	}
}


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 VK16_3F {

	static int B;
	static int P;
	static int Q;

	static long[] iFact;
	static long[] iFact2;

	public static void main0(String[] args) {
		System.out.println(Integer.toUnsignedString(inv(7)));
	}

	static int[] pCnt;
	static int[] cCnt;

	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter printer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		StringTokenizer inputData = new StringTokenizer(reader.readLine());
		B = Integer.parseInt(inputData.nextToken());
		P = Integer.parseInt(inputData.nextToken());
		P = Math.min(P, B);
		Q = Integer.parseInt(inputData.nextToken());

		pCnt = new int[P + 1];
		cCnt = new int[P + 1];

		Arrays.fill(pCnt, 1);// if there are no nights left, irrespective of number of sleeping places and as long as
								// there is at least one bear left, you can always get at most one barrel
		if (P == B) {
			pCnt[0] = 0;
		}

		int ans = 0;
		for (int n = 1; n <= Q; n++) {
			for (int p = 0; p <= P; p++) {
				calculate(p, n);
			}
			ans ^= n * cCnt[P];
			int[] temp = pCnt;
			pCnt = cCnt;
			cCnt = temp;
			Arrays.fill(temp, 0);
		}
		printer.println(ans);
		printer.close();
	}

	static void calculate(int p, int n) {
		int b = B - (P - p);
		int endI = Math.min(b, p);

		int sum = 0;
		for (int i = 0; i <= endI; i++) {
			sum += comb(b, i) * pCnt[p - i];
		}
		cCnt[p] = sum;
	}

	static int comb(int n, int k) {
		int num = 1;
		int den = 1;
		int pow2 = 0;

		if (n - k < k) {
			k = n - k;
		}

		for (int i = 1; i <= k; i++) {
			int cPow2 = Integer.numberOfTrailingZeros(i);
			pow2 -= cPow2;
			den = den * (i >> cPow2);

			cPow2 = Integer.numberOfTrailingZeros(n + 1 - i);
			pow2 += cPow2;
			num = num * ((n + 1 - i) >> cPow2);
		}
		return num * inv(den) << pow2;
	}

	static int inv(int n) {
		int x = 1;
		x = x * (2 - x * n); /* Newton's method */
		x = x * (2 - x * n); /* 5 steps enough for 32 bits */
		x = x * (2 - x * n);
		x = x * (2 - x * n);
		x = x * (2 - x * n);
		return x;
	}
}


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

public class E {

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

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

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

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

    public static void main(String[] args) {

        long n = r.nextLong();
        long ring = search(n);
        long prev = gg(ring - 1);
        long section = (n - prev) / ring;
        long rem = n - (prev + (ring * section));
        long x, y;
        if(n == 0){
            System.out.println("0 0");
            return;
        }

        if(section == 6){
            section = 0;
        }

        if(section == 0){
            x = 2 * ring; y = 0;
            x -= rem; y += (2 * rem);
        } else if(section == 1){
            x = 1 * ring; y = 2 * ring;
            x -= (2 * rem);
        } else if(section == 2){
            x = -1 * ring; y = 2 * ring;
            x -= rem; y -= (2 * rem);
        } else if(section == 3){
            x = -2 * ring; y = 0;
            x += rem; y -= (2 * rem);
        } else if(section == 4){
            x = -1 * ring; y = -2 * ring;
            x += 2 * rem;
        } else{ // (section == 5)
            x = 1 * ring; y = -2 * ring;
            x += rem; y += (2 * rem);
        }
        pw.println(x + " " + y + " ");
        pw.close();
    }

    static long search(long n) {
        long left = 0;
        long right = (int) 6E8;
        while (left < right) {
            long mid = left + (right - left) / 2;
            if (gg(mid) < n && gg(mid + 1) > n) {
                return 1 + mid;
            } else if(gg(mid) == n){
                return mid;
            }
            else if (gg(mid) > n) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
        return -1;
    }

    static long gg(long n) {
        return (3 * n * (n + 1));
    }
}

/**
 * _ _ _ | | | | | | ___ ___ __| | ___ | |__ _ _ __| | __ _ _ __ _ __ ___ _ __ _
 * _ __ _ ___ / __/ _ \ / _` |/ _ \ | '_ \| | | | / _` |/ _` | '__| '__/ _ \ '_
 * \ | | | |/ _` |/ _ \ | (_| (_) | (_| | __/ | |_) | |_| | | (_| | (_| | | | |
 * | __/ | | | | |_| | (_| | (_) | \___\___/ \__,_|\___| |_.__/ \__, |
 * \__,_|\__,_|_| |_| \___|_| |_| \__, |\__,_|\___/ __/ | ______ __/ | |___/
 * |______|___/
 */


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

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

  static class TaskE {
    int dirs = new int[][]{
      {-2, 0},
      {-1, -2},
      {1, -2},
      {2, 0},
      {1, 2},
      {-1, 2},
    };

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      Pair<Long, Long> p = findCell(in.nextLong());
      out.println(p.x + " " + p.y);
    }

    private Pair<Long, Long> findCell(long n) {
      if (n == 0) {
        return new Pair<>(0l, 0l);
      }
      n--;
      // inclusive
      long low = 0, up = n;
      while (low < up) {
        long test = (low + up) / 2;
        long group = test / 6;
        double g = test / 6;
        g = g * (g + 1) * 3 + g + (g + 1) * (test % 6 + 1) + (test % 6 >= 4 ? 1 : 0);
        if (g > n) {
          up = test;
          continue;
        }
        long before = group * (group + 1) * 3 + group;
        long total = before + (group + 1) * (test % 6 + 1) + (test % 6 >= 4 ? 1 : 0);
        if (total < n) { low = test + 1; } else { up = test; }
      }
      long test = low;
      long[] counts = new long[6];
      long group = test / 6;
      Arrays.fill(counts, group * (group + 1) / 2);
      counts[4] += group;
      for (int i = 0; i < test % 6; ++i) { counts[i] += group + 1; }
      if (test % 6 == 5) { counts[4]++; }
      long before = group * (group + 1) * 3 + group;
      long total = before + (group + 1) * (test % 6) + (test % 6 > 4 ? 1 : 0);
      n -= total;
      counts[(int) (test % 6)] += n;
      long x = 1, y = 2;
      for (int i = 0; i < counts.length; i++) {
        x += dirs[i][0] * counts[i];
        y += dirs[i][1] * counts[i];
      }
      return new Pair<>(x, y);
    }

  }

  static class Pair<X, Y> implements Comparable<Pair<X, Y>> {
    public X x;
    public Y y;

    public Pair(X x, Y y) {
      this.x = x;
      this.y = y;
    }

    public int hashCode() {
      int res = x == null ? 0 : x.hashCode();
      return res * 31 + (y == null ? 0 : y.hashCode());
    }

    public boolean equals(Object o) {
      if (this == o) { return true; }
      if (o == null) { return false; }
      if (getClass() != o.getClass()) { return false; }
      Pair p = (Pair) o;
      if ((x == null && p.x != null) || !x.equals(p.x)) { return false; }
      if ((y == null && p.y != null) || !y.equals(p.y)) { return false; }
      return true;
    }

    public String toString() {
      return String.format("(" + x + ", " + y + ")");
    }

    @SuppressWarnings({"unchecked"})
    public int compareTo(Pair<X, Y> o) {
      int res = ((Comparable<X>) x).compareTo(o.x);
      if (res != 0) { return res; }
      return ((Comparable<Y>) y).compareTo(o.y);
    }

  }
}


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

public class Main{
	static class InputReader{
		public BufferedReader r;
		public StringTokenizer t;
		public InputReader(InputStream tmp){
			r = new BufferedReader(new InputStreamReader(tmp), 32768);
			t = null;
		}
		public String nextString() throws IOException {
			while(t == null || !t.hasMoreTokens()){
				t = new StringTokenizer(r.readLine());
			}
			return t.nextToken();
		}
		public int nextInt() throws IOException {
			return Integer.parseInt(nextString());
		}
	}
	static long sum(long l, long r, long cnt){
		if(cnt == 0){return 0;}
		return (l + r) * cnt / 2;
	}
	static boolean can(long id, long n){
		long s = 1 + sum(6, 6 * id, id);
		return s >= n;
	}
	static long  find(long n){
		long l = 0, r = 10;
		for(int i = 0; i < 15; i++){r *= 10;}
		while(r - l > 1){
			long m = (l + r) / 2;
			if(can(m, n)){
				r = m;
			}
			else{
				l = m + 1;
			}
		}
		if(can(l, n)){return l;}
		return r;
	}
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		long n = Long.parseLong(in.readLine());
		n++;
		if(n == 1){out.println(0 + " " + 0); out.flush(); return;}
		int id = find(n);
		//if(1 + sum(6, 6 * id, id) > n){id--;}
		n -= 2 + sum(6, 6 * (id - 1), id - 1);
		//out.println(n);
		//long m = n - id;
		//if(m < 0){m = m + 6 * (id - 1);}
		long m = n + 1;
		if(m == 6 * id){m = 0;}
		//out.println(m);
		long part = m / (long)id;
		long prx = 0;
		long pry = 0;
		long d = m % (long)id;
		if(part == 1){
			prx = id;
			pry = 2 * id;
			prx -= 2 * (m % (long)id);
		}
		if(part == 2){
			prx = -id;
			pry = 2 * id;
			prx -= (m % (long)id);
			pry -= 2 * (m % (long)id);
		}
		if(part == 3){
			prx = -2 * id;
			pry = 0;
			prx += (m % (long)id);
			pry -= 2 * d;
		}
		if(part == 4){
			prx = -id;
			pry = -2 * id;
			prx += 2 * d;
		}
		if(part == 5){
			prx = id;
			pry = -2 * id;
			prx += d;
			pry += 2 * d;
		}
		if(part == 0){
			prx = 2 * id;
			pry = 0;
			prx -= (m % (long)id);
			pry += 2 * (m % (long)id);
		}
		out.println(prx + " " + pry);
		out.flush();
	}
}


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

public class E {

    public static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    public static StringTokenizer tok;

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

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

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

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

    public static class Pair {
        public long x, y;
        public Pair(long x, long y) {
            this.x = x;
            this.y = y;
        }
    }

    public static long func(long number) {
        return number * (3 * number + 2);
    }

    public static Pair result(long v, long n) {
        long vLeft = n - func(v);
        long x = v, y = -2 * v;
        v++;
        if (vLeft <= v) {
            x += vLeft;
            y += vLeft * 2;
            return new Pair(x, y);
        }
        x += v;
        y += v * 2;
        vLeft -= v;
        if (vLeft <= v - 1) {
            x -= vLeft;
            y += vLeft * 2;
            return new Pair(x, y);
        }
        x -= v - 1;
        y += (v - 1) * 2;
        vLeft -= v - 1;
        if (vLeft <= v) {
            x -= vLeft * 2;
            return new Pair(x, y);
        }
        x -= v * 2;
        vLeft -= v;
        if (vLeft <= v) {
            x -= vLeft;
            y -= vLeft * 2;
            return new Pair(x, y);
        }
        x -= v;
        y -= v * 2;
        vLeft -= v;
        if (vLeft <= v) {
            x += vLeft;
            y -= vLeft * 2;
            return new Pair(x, y);
        }
        x += v;
        y -= v * 2;
        vLeft -= v;
        x += vLeft * 2;
        return new Pair(x, y);
    }

    public static void main(String[] args) throws IOException {
        long n = nextLong();
        long rounds = (long)Math.floor(new BigDecimal(Math.sqrt(new BigDecimal(n).multiply(new BigDecimal(3.0)).add(new BigDecimal(1.0)).doubleValue())).subtract(new BigDecimal(1.0)).doubleValue());

        Pair answer = result(rounds, n);
        System.out.println(answer.x + " " + answer.y);
    }
}


import java.awt.Point;
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.ArrayList;
import java.util.Set;
import java.util.StringTokenizer;

public class D {

    static StringTokenizer st;
    static BufferedReader in;
    static int[]f;
    static ArrayList<Integer>[]g, gt;
    static boolean[] used, used2;
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int n = nextInt();
        int m = nextInt();
        f = new int[n+1];
        for (int i = 1; i <= n; i++) {
            f[i] = nextInt();
        }
        g = new  ArrayList[n+1];
        gt = new ArrayList[n+1];
        for (int i = 1; i <= n; i++) {
            g[i] = new ArrayList<Integer>();
            gt[i] = new ArrayList<Integer>();
        }
        for (int i = 1; i <= m; i++) {
            int v1 = nextInt();
            int v2 = nextInt();
            g[v1].add(v2);
            gt[v2].add(v1);
        }
        used = new boolean[n+1];
        used2 = new boolean[n+1];
        for (int i = 1; i <= n; i++) {
            if (f[i]==1 && !used[i])
                dfs(i);
            if (f[i]==2 && !used2[i])
                dfs2(i);
        }
        for (int i = 1; i <= n; i++) {
            if (used[i] && used2[i])
                pw.println(1);
            else
                pw.println(0);
        }
        pw.close();
    }
    private static void dfs2(int v) {
        used2[v] = true;
        if (f[v]==1)
            return;
        for (int to : gt[v]) {
            if (!used2[to])
                dfs2(to);
        }
    }
    private static void dfs(int v) {
        used[v] = true;
        for (int to : g[v]) {
            if (!used[to])
                dfs(to);
        }
    }
    private static int nextInt() throws IOException{
        return Integer.parseInt(next());
    }

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


import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.InputMismatchException;

public class R3_D2_D {
    static ArrayList<Integer>[] edge;
    static ArrayList<Integer>[] revEdge;
    static boolean vis1[];
    static boolean vis2[];

    public static void dfs1(int index) {
        if (!vis1[index]) {
            vis1[index] = true;
            for (int a : edge[index])
                dfs1(a);
        }
    }

    public static void dfs2(int index) {
        if (!vis2[index]) {
            vis2[index] = true;
            for (int a : revEdge[index])
                dfs2(a);
        }
    }

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

        InputReader in = new InputReader(System.in);
        int n = in.readInt();
        int m = in.readInt();
        vis1 = new boolean[n];
        vis2 = new boolean[n];
        int[] inp = new int[n];
        for (int i = 0; i < inp.length; i++) {
            inp[i] = in.readInt();
        }
        edge = new ArrayList[n];
        revEdge = new ArrayList[n];
        for (int j = 0; j < inp.length; j++) {
            edge[j] = new ArrayList<Integer>();
            revEdge[j] = new ArrayList<Integer>();
        }
        for (int i = 0; i < m; i++) {
            int a = in.readInt() - 1;
            int b = in.readInt() - 1;
            if(inp[b]==1)
                continue;
            edge[a].add(b);
            revEdge[b].add(a);
        }
        for (int i = 0; i < inp.length; i++) {
            if (inp[i] == 1)
                dfs1(i);
        }
        for (int i = 0; i < inp.length; i++) {
            if (inp[i] == 2)
                dfs2(i);
        }
        for (int i = 0; i < inp.length; i++) {
            if(vis1[i] && vis2[i])
                System.out.println(1);
            else
                System.out.println(0);
        }
    }

    public static class tr {
        int x;
        int y;
        int z;

        public tr(int a, int b, int c) {
            x = a;
            y = b;
            z = c;
        }
    }

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

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

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

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

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

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

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

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

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

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

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

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

}


import java.io.*;
import java.util.*;
public class D {
	private static void solve() throws IOException {
		n = nextInt();
		m = nextInt();
		f = new int[n+1];
		boolean[] visF = new boolean[n+1];
		boolean[] visE = new boolean[n+1];
		Queue<Integer> starts = new LinkedList<Integer>(); //all the locations of starts
		Queue<Integer> ends = new LinkedList<Integer>(); //all the locations of ends
		for(int i = 1; i < n+1; i++) {
			f[i] = nextInt();
			if(f[i] == 1)
				starts.add(i);
			else if(f[i] == 2)
				ends.add(i);
		}
		adj = new ArrayList[n+1];
		back = new ArrayList[n+1];
		for(int i = 0; i < n+1; i++) {
			adj[i] = new ArrayList<Integer>();
		}
		for(int i = 0; i < m; i++) {
			int f = nextInt();
			int s = nextInt();
			adj[f].add(s);
			back[s].add(f);
		}
		//see if can be found from a 1
		while(!starts.isEmpty()) {
			int cur = starts.poll();
			if(visF[cur])
				continue;
			visF[cur] = true;
			ArrayList<Integer> temp = adj[cur];
			for(int i = 0; i < temp.size(); i++) {
				starts.add(temp.get(i));
			}
		}
		while(!ends.isEmpty()) {
			int cur = ends.poll();
			if(visE[cur])
				continue;
			visE[cur] = true;
			if(f[cur] == 1)
				continue;
			ArrayList<Integer> temp = back[cur];
			for(int i = 0; i < temp.size(); i++) {
				ends.add(temp.get(i));
			}
		}
		for(int i = 1; i < visF.length; i++) {
			if(visF[i] && visE[i])
				out.println(1);
			else
				out.println(0);
		}
	}
	static int b, n, m, k, l;
	static int[] a, f;
	static ArrayList<Integer>[] adj, back;

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

	static BufferedReader br;
	static StringTokenizer st;
	static PrintWriter out;

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

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

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

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


import java.io.*;
import java.util.*;
public class D {
	private static void solve() throws IOException {
		n = nextInt();
		m = nextInt();
		f = new int[n+1];
		boolean[] visF = new boolean[n+1];
		boolean[] visE = new boolean[n+1];
		Queue<Integer> starts = new LinkedList<Integer>(); //all the locations of starts
		Queue<Integer> ends = new LinkedList<Integer>(); //all the locations of ends
		for(int i = 1; i < n+1; i++) {
			f[i] = nextInt();
			if(f[i] == 1)
				starts.add(i);
			else if(f[i] == 2)
				ends.add(i);
		}
		adj = new ArrayList<LinkedList<Integer>>(m);
		back = new ArrayList<LinkedList<Integer>>(m);
		for(int i = 0; i < n+1; i++) {
			adj.add(new LinkedList<Integer>());
			back.add(new LinkedList<Integer>());
		}
		for(int i = 0; i < m; i++) {
			int f = nextInt();
			int s = nextInt();
			adj.get(f).add(s);
			back.get(s).add(f);
		}
		//see if can be found from a 1
		while(!starts.isEmpty()) {
			int cur = starts.poll();
			if(visF[cur])
				continue;
			visF[cur] = true;
			LinkedList<Integer> temp = adj.get(cur);
			for(int i = 0; i < temp.size(); i++) {
				starts.add(temp.get(i));
			}
		}
		while(!ends.isEmpty()) {
			int cur = ends.poll();
			if(visE[cur])
				continue;
			visE[cur] = true;
			if(f[cur] == 1)
				continue;
			LinkedList<Integer> temp = back.get(cur);
			for(int i = 0; i < temp.size(); i++) {
				ends.add(temp.get(i));
			}
		}
		for(int i = 1; i < visF.length; i++) {
			if(visF[i] && visE[i])
				out.println(1);
			else
				out.println(0);
		}
	}
	static int b, n, m, k, l;
	static int[] a, f;
	static ArrayList<LinkedList<Integer>> adj, back;

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

	static BufferedReader br;
	static StringTokenizer st;
	static PrintWriter out;

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

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

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

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


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

public class A {
    FastScanner in;
    PrintWriter out;

    int gcd(int x, int y) {
        return x == 0 ? y : gcd(y % x, x);
    }

    int getCost(int n, boolean[] already) {
        boolean[] z = new boolean[n];
        for (int x = 3; x < n; x++) {
            if (!already[x]) {
                continue;
            }
            int g = gcd(n, x);
            int add = n / g;
            for (int i = 0; i < n; i += add) {
                z[i] = true;
            }
        }
        int cost = 0;
        for (int i = 0; i < n; i++) {
            cost += z[i] ? 0 : 1;
        }
        return cost;
    }

    int getAns(int maxN, int k) {
        int res = 0;
        boolean[] already = new boolean[maxN + 1];
        for (int it = 0; it < k; it++) {
            int mincost = Integer.MAX_VALUE;
            int minVal = -1;
            for (int n = 3; n <= maxN; n++) {
                if (already[n]) {
                    continue;
                }
                int cost = getCost(n, already);
                if (cost < mincost) {
                    mincost = cost;
                    minVal = n;
                }
            }
            already[minVal] = true;
            res += mincost;
        }
        return res;
    }

    void solve() {
        out.println(getAns(in.nextInt(), in.nextInt()));
    }

    void solve123() {
        for (int n = 3; n <= 50; n++) {
            boolean[] z = new boolean[n];
            for (int x = 3; x < n; x++) {
                int g = gcd(n, x);
                int add = n / g;
                for (int i = 0; i < n; i += add) {
                    z[i] = true;
                }
            }
            int cost = 0;
            for (int i = 0; i < n; i++) {
                cost += z[i] ? 0 : 1;
            }
            System.err.println(n + " -> " + cost);
        }
    }

    void run() {
        try {
            in = new FastScanner(new File("A.in"));
            out = new PrintWriter(new File("A.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {

        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();

        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

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

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

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

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

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

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

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

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


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

public class Main {
	static final long MOD = 998244353;
	static int[] primes;
	static int P;
    public static void main(String[] args) throws IOException {
        FastScanner sc=new FastScanner();
        int N = sc.nextInt();
        int K = sc.nextInt();
        primes = new int[78498];
        primes[0] = 2;
        P = 1;
        for (int num = 3; num <= N; num++) {
        	boolean prime = true;
        	for (int i = 0; i < P; i++) {
        		if (num % primes[i] == 0) {
        			prime = false;
        			break;
        		}
        		if (primes[i]*primes[i] > num) {
        			break;
        		}
        	}
        	if (prime) {
        		primes[P] = num;
        		P++;
        	}
        }
        int[][] totients = new int[N+1][2];
        HashMap<Integer,Integer> getT = new HashMap<Integer,Integer>();
        getT.put(1,1);
        getT.put(2,1);
        for (int i = 0; i <= N; i++) {
        	if (i < 3) {
        		totients[i][0] = Integer.MAX_VALUE;
        		continue;
        	}
        	totients[i][0] = totient(i);
        	totients[i][1] = i;
        	getT.put(i,totients[i][0]);
        }
        Arrays.sort(totients, new Comparator<int[]>() {
        	  @Override
        	  public int compare(int[] arr1, int[] arr2) {
        	    return arr1[0]-arr2[0];
        	  }
        });

        long ans = 2;
        for (int i = 0; i < K; i++)
        	ans += totients[i][0];
        System.out.println(ans);
    }

    public static int totient(int n) {
    	//From Geeks4Geeks
        int result = n;
        for (int p: primes) {
        	if (p == 0 || p * p > n) {
        		break;
        	}
            if (n % p == 0) {
                while (n % p == 0)
                    n /= p;
                result -= result / p;
            }
        }
        if (n > 1)
            result -= result / n;
        return result;
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner()
        {
            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;
        }
    }
}

class Node {
	public int n;
	public HashSet<Node> children;

	public Node(int n) {
		this.n = n;
		children = new HashSet<Node>();
	}

	public void addChild(Node node) {
		children.add(node);
	}

	public void removeChild(Node node) {
		children.remove(node);
	}
}

class BinaryIndexedTree {
	  public long[] arr;

	  public BinaryIndexedTree (int N) {
	    arr = new long[N+1];
	    arr[0] = 0;
	  }

	  //add k to the i-th element.
	  public void add(long k, int i) {
	    int node = i+1;
	    while (node < arr.length) {
	      arr[node] += k;
	      node += node & (-node);
	    }
	  }

	  //sum up the elements from input[s_i] to input[e_i], from [s_i,e_i).
	  public long sum(int s_i, int e_i) {
	    return sum(e_i) - sum(s_i);
	  }

	  public long sum(int i) {
	    long total = 0;
	    int node = i;
	    while (node > 0) {
	      total += arr[node];
	      node -= node & (-node);
	    }
	    return total;
	  }
}


import java.util.*;
import java.io.*;
import java.text.*;
public class Main{
    //SOLUTION BEGIN
    //Into the Hardware Mode
    void pre() throws Exception{}
    void solve(int TC)throws Exception{
        int n = ni(), k = ni();

        int[] phi = new int[1+n];

        for(int i = 1; i<= n; i++){
            phi[i] += i;
            for(int j = i+i; j<= n; j+= i)phi[j] -= phi[i];
        }
        int[][] pair = new int[n-2][];
        for(int i = 0; i< n-2; i++)pair[i] = new int[]{i+3, phi[i+3]};
        Arrays.sort(pair, (int[] i1, int[] i2) -> Integer.compare(i1[1], i2[1]));

        int ans1 = 1, ans2 = 2, cnt1 = 0, cnt2 = 0;
        for(int i = 0; i< n-2 && cnt1 < k; i++){
            if(pair[i][0]%2 == 0)continue;
            ans1 += pair[i][1];cnt1++;
        }
        for(int i = 0; i< n-2 && cnt2 < k; i++){
            ans2 += pair[i][1];cnt2++;
        }
        int ans = INF;
        if(cnt1 == k)ans = ans1;
        if(cnt2 == k)ans = Math.min(ans, ans2);
        pn(ans);
    }
    void add(int[] cnt, int x, int b){
        if(cnt[x] > 2 || b < 0)return;
       add(cnt, x, b-1);
       if(((x>>b)&1)==1){
           int nx = x^(1<<b);
           cnt[nx]++;
           add(cnt, nx, b-1);
       }
    }
    //SOLUTION END
    void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
    void exit(boolean b){if(!b)System.exit(0);}
    long IINF = (long)1e18, mod = (long)1e9+7;
    final int INF = (int)1e9, MX = (int)2e6+5;
    DecimalFormat df = new DecimalFormat("0.00000000");
    double PI = 3.141592653589793238462643383279502884197169399, eps = 1e-6;
    static boolean multipleTC = false, memory = false, fileIO = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        if(fileIO){
            in = new FastReader("input.txt");
            out = new PrintWriter("output.txt");
        }else {
            in = new FastReader();
            out = new PrintWriter(System.out);
        }
        //Solution Credits: Taranpreet Singh
        int T = (multipleTC)?ni():1;
        pre();
        for(int t = 1; t<= T; t++)solve(t);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }

    int digit(long s){int ans = 0;while(s>0){s/=10;ans++;}return ans;}
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n()throws Exception{return in.next();}
    String nln()throws Exception{return in.nextLine();}
    int ni()throws Exception{return Integer.parseInt(in.next());}
    long nl()throws Exception{return Long.parseLong(in.next());}
    double nd()throws Exception{return Double.parseDouble(in.next());}

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

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

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

        String nextLine() throws Exception{
            String str = "";
            try{
                str = br.readLine();
            }catch (IOException e){
                throw new Exception(e.toString());
            }
            return str;
        }
    }
}


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

public class Codeforces1208G {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int k = Integer.parseInt(st.nextToken());

		if (k == 1) {
			System.out.println(3);
		}
		else {
			int[] phitable = new int[n+1];
			for (int i = 1; i <= n; i++) {
				phitable[i] += i;
				for (int j = 2; j <= n/i; j++) {
					phitable[i*j] -= phitable[i];
				}
			}

			sort(phitable);
			long ans = 0;
			for (int i = 1; i <= (k+2); i++) {
				ans += (long) phitable[i];
			}
			System.out.println(ans);
		}

	}

	public static void sort(int[] array) {
    	int N import java.io.*;
import java.util.*;

public class Codeforces1208G {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int k = Integer.parseInt(st.nextToken());

		if (k == 1) {
			System.out.println(3);
		}
		else {
			int[] phitable = new int[n+1];
			for (int i = 1; i <= n; i++) {
				phitable[i] += i;
				for (int j = 2; j <= n/i; j++) {
					phitable[i*j] -= phitable[i];
				}
			}

			sort(phitable);
			long ans = 0;
			for (int i = 1; i <= (k+2); i++) {
				ans += (long) phitable[i];
			}
			System.out.println(ans);
		}

	}

	public static void sort(int[] array) {
    	int N = array.length;
    	if (N != 1) {
    		int[] firstHalf = Arrays.copyOfRange(array, 0, N/2);
    		sort(firstHalf);
        	int[] secondHalf = Arrays.copyOfRange(array, N/2, N);
        	sort(secondHalf);
        	int firstCounter = 0;
        	int secondCounter = 0;
        	for (int i = 0; i < N; i++) {
        		if (firstCounter == N/2) {
        			array[firstCounter+secondCounter] = secondHalf[secondCounter];
        			secondCounter++;
        		}
        		else if ((secondCounter == N-N/2) || firstHalf[firstCounter] <= secondHalf[secondCounter]) {
        			array[firstCounter+secondCounter] = firstHalf[firstCounter];
        			firstCounter++;
        		}
        		else {
        			array[firstCounter+secondCounter] = secondHalf[secondCounter];
        			secondCounter++;
        		}
        	}
    	}
    }

}= array.length;
    	if (N != 1) {
    		int[] firstHalf = Arrays.copyOfRange(array, 0, N/2);
    		sort(firstHalf);
        	int[] secondHalf = Arrays.copyOfRange(array, N/2, N);
        	sort(secondHalf);
        	int firstCounter = 0;
        	int secondCounter = 0;
        	for (int i = 0; i < N; i++) {
        		if (firstCounter == N/2) {
        			array[firstCounter+secondCounter] = secondHalf[secondCounter];
        			secondCounter++;
        		}
        		else if ((secondCounter == N-N/2) || firstHalf[firstCounter] <= secondHalf[secondCounter]) {
        			array[firstCounter+secondCounter] = firstHalf[firstCounter];
        			firstCounter++;
        		}
        		else {
        			array[firstCounter+secondCounter] = secondHalf[secondCounter];
        			secondCounter++;
        		}
        	}
    	}
    }

}


import java.util.*;

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

    final int MOD = 1000000007;

    void run() {
        String start = next();
        String end = next();
        int K = nextInt();
        int N = start.length();

        if (K == 0) {
            if (start.equals(end)) {
                System.out.println(1);
            } else {
                System.out.println(0);
            }

            return;
        }

        int zero = (N - 1) * (K - 1);
        long rest = 1;
        for (int i = 0; i < K - 1; i++) {
            rest *= (N - 1);
            rest %= MOD;
        }
        rest = (rest - K + 1) % MOD;

        int[] dp = new int[N];
        dp[0] = zero;
        for (int i = 1; i < N; i++) dp[i] = (int)rest;

        int ans = 0;
        String s1, s2;
        for (int i = 0; i < N; i++) {
            s1 = start.substring(0, i);
            s2 = start.substring(i);

            if (end.equals(s2.concat(s1))) {
                ans += dp[i];
                if (ans >= MOD) ans -= MOD;
            }
        }

        System.out.println(ans);
    }

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

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

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

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

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

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


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

public class D {

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

	int mod(long x) { return (int)((x + 1L*MOD*MOD) % MOD); }

	public D () throws IOException {
		String START = sc.next();
		String END = sc.next();
		int K = sc.nextInt();

		int N = START.length();
		int A0 = 1, A = 0, S = 1;
		for (int k = 1; k <= K; ++k) {
			int B0 = mod(S - A), B = mod(S - A0);
			A0 = B0; A = B; S = mod(1L*(N-1)*A + A0);
		}

		int res = 0;
		if (START.equals(END))
			res = mod(res + A0);
		for (int i = 1; i < N; ++i)
			if ((START.substring(i, N) + START.substring(0, i)).equals(END))
					res = mod(res + A);
		exit(res);
	}

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

	static MyScanner sc;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

		private final BufferedReader r;

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

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

		private String [] line;
		private int index;

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

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

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

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

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

	static long t;

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


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

public class D {

	public D () throws IOException {
		String S = sc.next();
		String E = sc.next();
		int K = sc.nextInt();
		solve(S,E,K);
	}

	int MOD = 1000000007;

	public void solve (String S, String E, int K) {
		if (K == 0){
			if (S.equals(E)) exit(1);
			else exit(0);
		}

		int N = S.length(), sum = 1;
		int [] A = new int [N]; A[0] = 1;
		for (int k = 1; k <= K; ++k) {
			int [] B = new int [N];
			for (int i = 0; i < N; ++i)
				B[i] = (sum - A[i]) % MOD;
			sum = 0;
			for (int i = 0; i < N; ++i)
				sum = (sum + B[i]) % MOD;
			A = B;
		}

		int res = 0;
		for (int i = 0; i < N; ++i) {
			if ((S.substring(i, N) + S.substring(0, i)).equals(E))
					res += A[i];
		}

		exit(res);
	}

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

	static MyScanner sc;
	static long t;

	static void print (Object o) {
		System.out.println(o);
	}

	static void exit (Object o) {
		print(o);
		//print2((millis() - t) / 1000.0);
		System.exit(0);
	}

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

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

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

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

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

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

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

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

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

		private final BufferedReader r;

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

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

		private String [] line;
		private int index;

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


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

public class D {

	public D () throws IOException {
		String S = sc.next();
		String E = sc.next();
		int K = sc.nextInt();
		solve(S,E,K);
	}

	int MOD = 1000000007;
	//BigInteger BMOD = BigInteger.valueOf(MOD);
	int mod(long x) { return (int)((x + MOD*MOD) % MOD); }

	public void solve (String S, String E, int K) {
		if (K == 0){
			if (S.equals(E)) exit(1);
			else exit(0);
		}

		int N = S.length(), sum = 1;
		int [] A = new int [N]; A[0] = 1;
		for (int k = 1; k <= K; ++k) {
			int [] B = new int [N];
			for (int i = 0; i < N; ++i)
				B[i] = mod(sum - A[i]);
			sum = 0;
			for (int i = 0; i < N; ++i)
				sum = mod(sum + B[i]);
			A = B;
		}

		int res = 0;
		for (int i = 0; i < N; ++i) {
			if ((S.substring(i, N) + S.substring(0, i)).equals(E))
					res = mod(res + A[i]);
		}

		exit(res);
	}

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

	static MyScanner sc;
	static long t;

	static void print (Object o) {
		System.out.println(o);
	}

	static void exit (Object o) {
		print(o);
		//print2((millis() - t) / 1000.0);
		System.exit(0);
	}

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

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

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

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

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

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

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

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

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

		private final BufferedReader r;

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

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

		private String [] line;
		private int index;

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


import java.util.Scanner;
public class project{
    public static void main(String[]args){
	Scanner ss = new Scanner(System.in);
	int n =ss.nextInt(), k=ss.nextInt(), cur1=0,cur2=0,cur3=0;
	String s = ss.next();

	int iscan1 = 0;
	for(int i=0;i<k;i++) {
	    if(s.charAt(i)=='Y') cur1++;
	    if(s.charAt(i)=='N') cur2++;
	    if(s.charAt(i)=='?') cur3++;
	}
	for(int i=k;i<=n;i++) {
	    if(cur1==0) {
	        if(i==k || s.charAt(i-k-1)!='N') if(i==n ||s.charAt(i)!='N') iscan1 = 1;
	    }
	    if(s.charAt(i-k)=='Y') cur1--;
	    if(s.charAt(i-k)=='N') cur2--;
	    if(s.charAt(i-k)=='?') cur3--;
	    if(i!=n){
    	    if(s.charAt(i)=='Y') cur1++;
    	    if(s.charAt(i)=='N') cur2++;
    	    if(s.charAt(i)=='?') cur3++;
	    }
	}
	int iscan2 = 0;
	if(k!=n){
    	k++;
    	cur1=0;
    	cur2=0;
    	cur3=0;
    	for(int i=0;i<k;i++) {
    	    if(s.charAt(i)=='Y') cur1++;
    	    if(s.charAt(i)=='N') cur2++;
    	    if(s.charAt(i)=='?') cur3++;
    	}
    	for(int i=k;i<=n;i++) {
    	    if(cur1==0 && cur3==0) {
    	        iscan2 = 1;
    	    }
    	    if(s.charAt(i-k)=='Y') cur1--;
    	    if(s.charAt(i-k)=='N') cur2--;
    	    if(s.charAt(i-k)=='?') cur3--;

    	    if(i!=n){
        	    if(s.charAt(i)=='Y') cur1++;
        	    if(s.charAt(i)=='N') cur2++;
        	    if(s.charAt(i)=='?') cur3++;
    	    }
    	}
	}
	if(iscan1==1 && iscan2==0){
	    System.out.println("YES");
	} else {
	    System.out.println("NO");
	}
    }
}


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

	int n =s.nextInt(), k=s.nextInt();

          String str = s.next();
          str='Y'+str;
          str+='Y';
         char[] x = str.toCharArray();

          int cur =0 ,ans = 0;
          boolean t=false;
          for(int i=1;i<=n;i++)
          {
                    if(t && x[i]=='N')
                    {
                              cur++;
                    }
                    if(!t && x[i]=='N')
                    {
                              t=true;
                              cur++;
                    }
                    if(x[i]!='N')
                    {
                        if (ans < cur)
                        ans = cur;

                              t=false;
                              cur=0;
                    }
          }

          if (ans < cur) ans = cur;
          //cout<<ans<<endl;
          if(ans>k)
          {
                    System.out.println("NO");

          }
          else
          {
          boolean vyv = false;
          for(int i=1;i<=n;i++)
          {
                    //cout<<x<<endl;
                    //cout<<i-1<<"  "<<i+k<<endl;
                    //cout<<x[i-1]<<" "<<x[i+k]<<endl;
                    if((x[i-1]=='Y' || x[i-1]=='?') && (x[i+k]=='Y' || x[i+k]=='?'))
                    {
                              t=true;
                              for(int j=i;j<k+i;j++)
                              {
                                        if(x[j]=='Y')
                                                  t=false;
                              }
                              if(t)
                              {
                                        System.out.println("YES");
                                      vyv = true;
                                      break;
                              }
                    }
          }
          if (!vyv)
          System.out.println("NO");
          }
    }
}


import java.util.*;

public class Sol{
    public static void main(String[] argc){
        Scanner sc = new Scanner(System.in);
        int n, k;
        String s;
        n = sc.nextInt();
        k = sc.nextInt();
        s = sc.next();

        boolean found = false;
        for (int i = 0; i < n; ++i) {
            int st = i;
            int en = i + k - 1;
            if (st -1 >=0 and s[st-1] == 'N') continue;
            if (en +1 <n and s[en +1] == 'N') continue;
            if (en >= n) {
                break;
            }

            boolean ok = true;
            for (int j = st; j <= en; ++j) {
                if (s.charAt(j) == 'Y') {
                    ok = false;
                }
            }
            if (ok) {
                found = true;
                break;
            }
        }

        int maxn = 0;

        for (int i = 0; i < n; ++i) {
            if (s.charAt(i) != 'N') {
                continue;
            }
            int cnt = 1;
            int j = i + 1;
            while (j < n && s.charAt(j) == 'N') {
                ++cnt;
                ++j;
            }

            if (cnt > maxn) {
                maxn = cnt;
            }
        }

        if (found && maxn <= k) {
            System.out.println("YES");
        }
        else {
            System.out.println("NO");
        }
    }
}


import java.util.*;

public class Sol{
    public static void main(String[] argc){
        Scanner sc = new Scanner(System.in);
        int n, k;
        String s;
        n = sc.nextInt();
        k = sc.nextInt();
        s = sc.next();

        boolean found = false;
        for (int i = 0; i < n; ++i) {
            int st = i;
            int en = i + k - 1;
            if (st -1 >=0 and s․charAt(st-1) == 'N') {
                continue;
            }
            if (en +1 <n and s.charAt(en +1) == 'N') {
                continue;
            }
            if (en >= n) {
                break;
            }

            boolean ok = true;
            for (int j = st; j <= en; ++j) {
                if (s.charAt(j) == 'Y') {
                    ok = false;
                }
            }
            if (ok) {
                found = true;
                break;
            }
        }

        int maxn = 0;

        for (int i = 0; i < n; ++i) {
            if (s.charAt(i) != 'N') {
                continue;
            }
            int cnt = 1;
            int j = i + 1;
            while (j < n && s.charAt(j) == 'N') {
                ++cnt;
                ++j;
            }

            if (cnt > maxn) {
                maxn = cnt;
            }
        }

        if (found && maxn <= k) {
            System.out.println("YES");
        }
        else {
            System.out.println("NO");
        }
    }
}


import java.util.*;

public class abc
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n =s c.nextInt();
        int[] arr = new int[n];

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

        Arrays.sort(arr);
        System.out.println(arr[(n-1)/2]);
    }
}


import java.util.Scanner;

public class s{
	public static void main(String args[]){
		Scanner in1 = new Scanner(System.in);
		int n = in1.nextInt();
		int a[] = new int[n];
		int nn[] = new int[n];
		int ii=0;
			while(--n>=0){
				int x = in1.nextInt();
				nn[ii]=x;
				String t = String.valueOf(x);
				int sum=0;
				for(int i = 0 ; i < t.length(); i++){
					sum+=Integer.valueOf(t.charAt(i));
				}
				a[ii]=sum;
				ii++;
			}
		Arrays.sort(a);
		Arrays.sort(nn);
		int x = a.length/2;
		System.out.println(nn[x]);
	}
}


// CoDE deVELOPed uNDEr AcE proDUcTiONS (enJOY!!!!)
import java.util.*;

public class Ace
{
   public static void main(String[] args)
   {
  MathTools m=new MathTools();
       Scanner sc=new Scanner(System.in);
   int n=sc.nextInt();
   int[] ar=new int[n];
   for(int i=0;i<n;i++) ar[i]=sc.nextInt();
   Arrays.sort(ar);
   int b=n/2;
   System.out.print(ar[b]);

}
}

// CoDE deVELOPed uNDEr AcE proDUcTiONS (enJOY!!!!)


import java.util.*;

public class abc
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n =s c.nextInt();
        int[] arr = new int[n];

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

        Arrays.sort(arr);
        System.out.println(arr[(n-1)/2];
    }
}


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

public class C implements Runnable {
	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer st;
	static Random rnd;

	private void solve() throws IOException {
		int numbersCount = nextInt();
		long[] numbers = new long[numbersCount];
		for (int i = 0; i < numbersCount; i++)
			numbers[i] = nextLong();
		Arrays.sort(numbers);
		arraysReverse(numbers);

		rec(0, numbersCount, numbers, new boolean[numbersCount], 0, 0,
				new long[numbersCount], new boolean[numbersCount]);

		out.println(result);
	}

	private void arraysReverse(long[] numbers) {
		int l = 0, r = numbers.length - 1;
		while (l < r) {
			long temp = numbers[l];
			numbers[l] = numbers[r];
			numbers[r] = temp;
			++l;
			--r;
		}
	}

	int result = Integer.MAX_VALUE;

	private void rec(int step, int numbersCount, long[] numbers,
			boolean[] used, int treesNearRoot, int treesCount,
			long[] treesRoots, boolean[] isLeaf) {
		int currentVertexes = getVertexes(treesNearRoot, treesCount,
				treesRoots, isLeaf);

		// out.println(currentVertexes + " " + result + " " + step + " "
		// + treesNearRoot + " " + treesCount + " "
		// + Arrays.toString(treesRoots));

		if (currentVertexes >= result)
			return;

		if (step == numbersCount) {
			result = Math.min(result, currentVertexes);
		} else {
			for (int i = 0; i < numbersCount; i++) {
				if (!used[i]) {
					used[i] = true;
					long number = numbers[i];
					boolean end = false;

					// add tree
					{
						treesRoots[treesCount] = number;
						isLeaf[treesCount] = true;
						rec(step + 1, numbersCount, numbers, used,
								treesNearRoot + 1, treesCount + 1, treesRoots,
								isLeaf);

						if (currentVertexes >= result)
							end = true;
					}

					// add to another tree
					for (int j = 0; j < treesCount && !end; j++) {
						if (treesRoots[j] % number == 0) {
							treesRoots[j] /= number;
							boolean backUpIsLeaf = isLeaf[j];
							isLeaf[j] = false;
							treesRoots[treesCount] = number;
							isLeaf[treesCount] = true;

							rec(step + 1, numbersCount, numbers, used,
									treesNearRoot, treesCount + 1, treesRoots,
									isLeaf);

							treesRoots[j] *= number;
							isLeaf[j] = backUpIsLeaf;

							if (currentVertexes >= result)
								end = true;
						}
					}

					used[i] = false;
				}
			}
		}
	}

	private int getVertexes(int treesNearRoot, int treesCount,
			long[] treesRoots, boolean[] isLeaf) {
		int vertexes = (treesNearRoot > 1 ? 1 : 0);
		for (int i = 0; i < treesCount; i++) {
			int childs = getPrimes(treesRoots[i]);
			int add = (childs <= 1 && isLeaf[i]) ? 1 : (1 + childs);
			vertexes += add;
		}
		return vertexes;
	}

	Map<Long, Integer> cache = new HashMap<Long, Integer>();

	private int getPrimes(long n) {
		if (n == 1)
			return 0;
		Integer cacheValue = cache.get(n);
		if (cacheValue != null)
			return cacheValue;
		int result = 1;
		for (long i = 2; i * i <= n; i++) {
			if (n % i == 0) {
				result = 1 + getPrimes(n / i);
				break;
			}
		}
		cache.put(n, result);
		return result;
	}

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

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			rnd = new Random();

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	private String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String line = in.readLine();

			if (line == null)
				return null;

			st = new StringTokenizer(line);
		}

		return st.nextToken();
	}

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

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

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


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

public class C {

	static final int INF = Integer.MAX_VALUE / 3;
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	static int N = 1_000_000;
	static int ROOT = 1_000;
	static boolean[] isPrime = new boolean[N + 1];
	static List<Integer> primes = new ArrayList<>(78498);
	static {
		Arrays.fill(isPrime, true);
		for (int i = 2; i <= N; i++) {
			if (isPrime[i]) {
				primes.add(i);
				if (i <= ROOT) {
					for (int j = i * i; j <= N; j += i) {
						isPrime[j] = false;
					}
				}
			}
		}
	}

	int n;
	long[] a;

	void solve() throws IOException {
		n = nextInt();
		a = new long[n];

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

		Arrays.sort(a);

		int ans = go(n - 1, new ArrayList<Long>());
		out.println(ans);
	}

	int go(int i, List<Long> vs) {
		if (i == -1) {
			int ret = 0;

			for (long x : vs) {
				int val = sumPrimePowers(x);
				ret += val + 1;
			}

			if (vs.size() > 1)
				ret++;

			return ret;
		}

		int ret = Integer.MAX_VALUE;

		long add = a[i];
		for (int j = 0; j < vs.size(); j++) {
			if (vs.get(j) % add == 0) {
				List<Long> newVs = new ArrayList<>(vs);

				newVs.set(j, vs.get(j) / add);
				if (sumPrimePowers(add) > 1) {
					newVs.add(add);
				} else {
					newVs.add(1L);
				}
				ret = Math.min(ret, go(i - 1, newVs));
			}
		}
		if (sumPrimePowers(add) == 1) {
			vs.add(1L);
		} else {
			vs.add(add);
		}
		ret = Math.min(ret, go(i - 1, vs));
		return ret;
	}

	int sumPrimePowers(long x) {
		int ret = 0;
		for (int i = 0; i < primes.size(); i++) {
			int p = primes.get(i);
			while (x % p == 0) {
				x /= p;
				ret++;
			}
		}
		if (x != 1)
			ret++;
		return ret;
	}

	C() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

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

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

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

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

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

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