    import java.io.BufferedWriter;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.io.OutputStreamWriter;
    import java.io.PrintWriter;
    import java.io.Writer;
    import java.util.Arrays;
    import java.util.InputMismatchException;
    import java.util.*;
    import java.io.*;
    import java.math.*;
    public class Main7{

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

        @Override
                public int hashCode()
                {
                    final int temp = 14;
                    int ans = 1;
                    ans =x*31+y*13;
                    return ans;
                }

                // Equal objects must produce the same
                // hash code as long as they are equal
            @Override
            public boolean equals(Object o)
            {
                if (this == o) {
                    return true;
                }
                if (o == null) {
                    return false;
                }
                if (this.getClass() != o.getClass()) {
                    return false;
                }
                Pair other = (Pair)o;
                if (this.x != other.x || this.y!=other.y) {
                    return false;
                }
                return true;
            }

        }
        static class Pair1
        {
            String x;
            int y;
            int z;

        }
        static class Compare
        {
            static void compare(Pair arr[], int n)
            {
                // Comparator to sort the pair according to second element
            /*    Arrays.sort(arr, new Comparator<Pair>() {
                    @Override public int compare(Pair p1, Pair p2)
                    {
                        if(p1.start>p2.start)
                        {
                            return 1;
                        }
                        else if(p1.start==p2.start)
                        {
                            return 0;
                        }
                        else
                        {
                            return -1;
                        }
                    }
                }); */
            }

        }

        public static long pow(long a, long b)
        {
            long result=1;
            while(b>0)
            {
                if (b % 2 != 0)
                {
                    result=(result*a)%998244353;
                    b--;
                }
                a=(a*a)%998244353;
                b /= 2;
            }
            return result;
        }
        public static long fact(long num)
        {
                    long value=1;
                    int i=0;
                    for(i=2;i<num;i++)
                    {
                        value=((value%mod)*i%mod)%mod;
                    }
                    return value;
                }
                public static long gcd(long a, long b)
                {
                    if (a == 0)
                        return b;
                    return gcd(b%a, a);
                }

        /*        public static long lcm(long a,long b)
                {
                    return a * (b / gcd(a, b));
                }
            */    public static long sum(int h)
                {
                    return (h*(h+1)/2);
                }
                public static void dfs(int parent,boolean[] visited,int[] dp)
                {
                    ArrayList<Integer> arr=new ArrayList<Integer>();
                    arr=graph.get(parent);
                    visited[parent]=true;
                    for(int i=0;i<arr.size();i++)
                    {
                        int num=(int)arr.get(i);
                        if(visited[num]==false)
                        {
                            dfs(num,visited,dp);
                        }
                        dp[parent]=Math.max(dp[num]+1,dp[parent]);
                    }
                }
            //    static int flag1=0;
                static int[] dis;
                static int mod=1000000007;
                static ArrayList<ArrayList<Integer>> graph;

                public static void bfs(int num,int size)
                {
                    boolean[] visited=new boolean[size+1];
                    Queue<Integer> q=new LinkedList<>();
                    q.add(num);
                    ans[num]=1;
                    visited[num]=true;
                    while(!q.isEmpty())
                    {
                        int x=q.poll();
                        ArrayList<Integer> al=graph.get(x);
                        for(int i=0;i<al.size();i++)
                        {
                            int y=al.get(i);
                            if(visited[y]==false)
                            {
                                q.add(y);
                                ans[y]=ans[x]+1;
                                visited[y]=true;
                            }
                        }
                    }
                }
                static int[] ans;

            //    static int[] a;
                public static int[] sort(int[] a)
                {
                    int n=a.length;
                    ArrayList<Integer> ar=new ArrayList<>();
                    for(int i=0;i<a.length;i++)
                    {
                        ar.add(a[i]);
                    }
                    Collections.sort(ar);
                    for(int i=0;i<n;i++)
                    {
                        a[i]=ar.get(i);
                    }
                    return a;
                }
                static public void main(String args[])throws IOException
                {
                    int n1=i();
					int m1=i();
					int[] a=new int[m1];
					int[] b=new int[m1];
					for(int i=0;i<m1;i++)
					{
						a[i]=i()-1;
						b[i]=i()-1;
					}
					int max=0;
					for(int i=6;i>=0;i--)
					{
						for(int j=6;j>=0;j--)
						{
							for(int k=6;k>=0;k--)
							{
								for(int l=6;l>=0;l--)
								{
									for(int m=6;m>=0;m--)
									{
										for(int n=6;n>=0;n--)
										{
											for(int o=6;o>=0;o--)
											{
												int ans=0;
												int[] x=new int[]{i,j,k,l,m,n,o};
												HashMap<ArrayList<Integer>,Integer> hash=new HashMap<>();
												for(int p=0;p<m1;p++)
												{
													int num=a[p];
													int num1=b[p];
													if(x[a[p]]==0 || x[b[p]]==0)
													{
														continue;
													}
													else
													{
														ArrayList<Integer> ar=new ArrayList<>();
														ar.add(x[a[p]]);
														ar.add(x[b[p]]);
														ArrayList<Integer> ar1=new ArrayList<>();
														ar1.add(x[b[p]]);
														ar1.add(x[a[p]]);
														if(hash.containsKey(ar)==false && hash.containsKey(ar1)==false)
														{
															ans++;
															hash.put(ar,1);
															ar.clear();
															ar.add(x[b[p]]);
															ar.add(x[a[p]]);
															hash.put(ar,1);
															if(ans==m1)
															{
																pln(m1+"");
																return;
															}
															if(c++==200000)
															{
																pln(max+"");
																return ;
															}

														}
													}
												}
												max=Math.max(ans,max);
											}
										}
									}

								}
							}
						}
					}
					pln(max+"");
                }

                /**/
                static InputReader in=new InputReader(System.in);
                    static OutputWriter out=new OutputWriter(System.out);
                    public static long l()
                    {
                        String s=in.String();
                        return Long.parseLong(s);
                    }
                    public static void pln(String value)
                    {
                        System.out.println(value);
                    }
                    public static int i()
                    {
                        return in.Int();
                    }
                    public static String s()
                    {
                        return in.String();
                    }
        }

            class InputReader {

                private InputStream stream;
                private byte[] buf = new byte[1024];
                private int curChar;
                private int numChars;
                private SpaceCharFilter filter;

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

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

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

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

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

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

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

            class OutputWriter {
                private final PrintWriter writer;

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

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

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

                public void printLine(Object...objects) {
                    print(objects);
                    writer.println();
                }

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

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

                }

                class IOUtils {

                public static int[] readIntArray(InputReader in, int size) {
                    int[] array = new int[size];
                    for (int i = 0; i < size; i++)
                        array[i] = in.Int();
                    return array;
                }

                }


package codeforces;

import java.util.Scanner;

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

		int n = input.nextInt();
		if(n%2 == 0) System.out.println("white\n1 2");
		else
			System.out.println("black");
	}
}


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

public class Pipeline {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long n = scan.nextLong();
        int k = scan.nextInt();
        int[] a = new int[k];
        for (int i = 0; i < k; i++)
            a[i] = i + 1;
        long av = 1;
        int count = 0;
        while (av < n) {
            boolean found = false;
            for (int i = k - 1; i >= 0; i--)
                if (a[i] > 0 && av + a[i] - 1 <= n) {
                    found = true;
                    av += a[i];
                    av--;
                    a[i] = -1;
                    count++;
                    if(av == n)
                        break;
                }
            if (!found)
                break;
            found = false;
        }
        if (av == n)
            System.out.println(count);
        else
            System.out.println(-1);
    }
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
      while(sc.hasNext()){
          long a=sc.nextLong();int len=sc.nextInt();
          if(a==len){
              System.out.println(1);
              continue;}
          if(sum(2,len,len-1)<a){
              System.out.println(-1);
              continue;
          }
          long arr[]=new long[len];
          for (int i =1; i <arr.length ; i++) {
              arr[i]=i+1;
          }
          int l=1,r=len-1;
          while(l<r){
              int mid=(l+r)/2;
              long sum=sum(arr[ mid],arr[len-1],len-mid);
              if(sum>a){
                  l=mid;
              }else if(sum<a){
                  r=mid;
              }else{
                  l=r=mid;
              }
          }
          System.out.println(len-l);
      }
    }
    static long sum(long a,long b,long n){
        return (a+b)*(n)/2-n+1;
    }
}


import java.util.Scanner;

public class aseel {
public static void main (String args []) {
	Scanner in = new Scanner(System.in);
int [] arr = new int [3];
arr[0]=in.nextInt();
arr[1]=in.nextInt();
arr[2]=in.nextInt();
Arrays.Sort(arr);
if ((arr[2]-(arr[0]+arr[1])>=0)){
System.out.println(arr[2]-(arr[0]+arr[1])+1);
}else {
	System.out.println("0");
}
}
}


import java.util.*;
public class Q1064A
{
    public static void main(String[] args)
    {
        int a[],max=0;
        Scanner sc=new Scanner(System.in);
        a=new int[3];
        for(int i=0;i<3;i++)
        {
            a[i]=sc.nextInt();
        }
        for(int i=0;i<3;i++)
        {
            if(a[i]>a[i+1])
            {
                max=a[i+1];
                a[i+1]=a[i];
                a[i]=max;
            }
        }
        if(a[2]==(a[1]+1[0]))
        {
            System.out.println(0);
        }
        else
        {
            System.out.println((a[2]-(a[1]+a[0])+1));
        }
        sc.close();
    }
}


import java.util.*;

public class Finals {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int s1 = Math.min(a, b);
		int s2 = Math.min(Math.max(a, b), c);
		int s3 = Math.max(Math.max(a, b), c);
		int result;
		if(s1+s2>s3)
			result = 0;
		else
			result = (s3+1)-(s1+s2);
		System.out.println(result);
	}

}
}


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

import java.util.Arrays;

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] arr = br.readLine().split(" ");
        int[] a = new int[3];
        a[0] = Integer.parseInt(arr[0]);
        a[1] = Integer.parseInt(arr[1]);
        a[2] = Integer.parseInt(arr[2]);

        System.out.println(1* totalInc(a));
    }

    public int totalInc(int[] a) {
        Arrays.sort(a);
        if (a[0] + a[1] > a[2]) {
            return 0;
        } else {
            return a[2] - (a[0] + a[1]) + 1;
        }
    }
}


public class Main {
    static long nCk(long n, long k) {
        if (n < k) {
            return 0;
        }
        if (k == 0) {
            return 1;
        }
        if (k == 1) {
            return n;
        }
        long x = n;
        for (int i = 1; i<k; i++) {
            x*= (n-i);
        }
        long y = 1;
        while (k > 0) {
            y *= k;
        }
        return x / y;
    }

    public static void main() {
        Scanner s new Scanner();
        int z = s.nextInt();
        long n = (long) z;
        System.out.println(6 * nCk(n - 3, 0) + 12 * nCk(n - 3, 1) + 8 * nCk(n - 3, 2) + 2 * nCk(n - 3, 3))

    }
}


import java.util.Scanner;

public class Seth {
    static long nCk(long n, long k) {
        if (n < k) {
            return 0;
        }
        if (k == 0) {
            return 1;
        }
        if (k == 1) {
            return n;
        }
        long x = n;
        for (int i = 1; i < k; i++) {
            x *= (n - i);
        }
        long y = 1;
        while (k > 0) {
            y *= k;
        }
        return x / y;
    }

    public static void main() {
        Scanner s = new Scanner(System.in);
        int z = s.nextInt();
        System.out.println(6 * nCk((long) z - 3, 0) + 12 * nCk((long) z - 3, 1) + 8 * nCk((long) z - 3, 2) + 2 * nCk((long) z - 3, 3));

    }
}


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

import static java.lang.Math.*;

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

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

    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 CodeforcesA(), "", 128 * (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 {

        long[] fact = new long[12];
        fact[1] = 1;

        int n = readInt();

        for (int i = 2; i < 10; i++) {
            fact[i] = fact[i - 1] * i;
        }

        int[] primes = new int[] { 2, 3, 5, 7 };

        char[] num = readString().toCharArray();
        ArrayList<Integer> s = new ArrayList<Integer>();
        for (int i = 0; i < num.length; i++) {
            long curFac = fact[num[i] - '0'];
            for (int prime : primes) {
                while (curFac % prime == 0) {
                    curFac /= prime;
                    s.add(prime);
                }
            }
        }

        int a2 = 0, a3 = 0, a5 = 0, a7 = 0;
        for (int x : s) {
            if (x == 2)
                a2++;
            if (x == 3)
                a3++;
            if (x == 5)
                a5++;
            if (x == 7)
                a7++;
        }

        while (a7 > 0) {
            a7--;
            a5--;
            a3 -= 2;
            a2 -= 4;
            out.print(7);
        }

        while (a5 > 0) {
            a5--;
            a3 --;
            a2 -= 3;
            out.print(5);
        }

        while (a3 > 0) {
            a3 --;
            a2 --;
            out.print(3);
        }

        while (a2 > 0) {
            a2 --;
            out.print(2);
        }
    }
}


import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;
import java.io.InputStream;

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

class TaskC {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
		int count = in.readInt();
		int repeats = in.readInt();
		int[] openCost = IOUtils.readIntArray(in, count);
		int[] closeCost = IOUtils.readIntArray(in, count);
		int[][][] answer = new int[count + 1][2 * count + 1][count + 1];
		ArrayUtils.fill(answer, Integer.MAX_VALUE);
		answer[0][count][0] = 0;
		for (int i = 0; i < count; i++) {
			for (int j = 0; j <= 2 * count; j++) {
				for (int k = 0; k < count; k++) {
					if (answer[i][j][k] == Integer.MAX_VALUE)
						continue;
					answer[i + 1][j + 1][k] = Math.min(answer[i + 1][j + 1][k], answer[i][j][k] + openCost[i]);
					answer[i + 1][j - 1][Math.max(k, count - j + 1)] = Math.min(answer[i + 1][j - 1][Math.max(k, count - j + 1)], answer[i][j][k] + closeCost[i]);
				}
			}
		}
		int[][] delta = answer[count];
		int[][] matrix = new int[count * count + 1][count * count + 1];
		ArrayUtils.fill(matrix, Integer.MAX_VALUE / 2);
		for (int i = 0; i < matrix.length; i++) {
			for (int j = Math.max(0, count - i); j <= 2 * count && i + j - count < matrix.length; j++) {
				for (int k = 0; k <= i && k <= count; k++)
					matrix[i][i + j - count] = Math.min(matrix[i][i + j - count], delta[j][k]);
			}
		}
		int[][] result = new int[matrix.length][matrix.length];
		int[][] temp = new int[matrix.length][matrix.length];
		power(repeats, result, temp, matrix);
		out.printLine(result[0][0]);
    }

	private void power(int exponent, int[][] result, int[][] temp, int[][] matrix) {
		if (exponent == 1) {
			for (int i = 0; i < matrix.length; i++)
				System.arraycopy(matrix[i], 0, result[i], 0, matrix.length);
			return;
		}
		if ((exponent & 1) == 0) {
			power(exponent >> 1, temp, result, matrix);
			multiply(result, temp, temp);
		} else {
			power(exponent - 1, temp, result, matrix);
			multiply(result, temp, matrix);
		}
	}

	private void multiply(int[][] a, int[][] b, int[][] c) {
		ArrayUtils.fill(a, Integer.MAX_VALUE / 2);
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a.length; j++) {
				for (int k = 0; k < a.length; k++)
					a[i][k] = Math.min(a[i][k], b[i][j] + c[j][k]);
			}
		}
	}

	}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

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

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

	public int 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 boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

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

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

class OutputWriter {
	private final PrintWriter writer;

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

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

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

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

class IOUtils {

	public static int[] readIntArray(InputReader in, int size) {
		int[] array = new int[size];
		for (int i = 0; i < size; i++)
			array[i] = in.readInt();
		return array;
	}

	}

class ArrayUtils {

	public static void fill(int[][] array, int value) {
		for (int[] row : array)
			Arrays.fill(row, value);
	}

	public static void fill(int[][][] array, int value) {
		for (int[][] subArray : array)
			fill(subArray, value);
	}

	}


import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;
import java.io.InputStream;

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

class TaskC {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
		int count = in.readInt();
		int repeats = in.readInt();
		int[] openCost = IOUtils.readIntArray(in, count);
		int[] closeCost = IOUtils.readIntArray(in, count);
		int[][][] answer = new int[count + 1][2 * count + 1][count + 1];
		ArrayUtils.fill(answer, Integer.MAX_VALUE);
		answer[0][count][0] = 0;
		for (int i = 0; i < count; i++) {
			for (int j = 0; j <= 2 * count; j++) {
				for (int k = 0; k < count; k++) {
					if (answer[i][j][k] == Integer.MAX_VALUE)
						continue;
					answer[i + 1][j + 1][k] = Math.min(answer[i + 1][j + 1][k], answer[i][j][k] + openCost[i]);
					answer[i + 1][j - 1][Math.max(k, count - j + 1)] = Math.min(answer[i + 1][j - 1][Math.max(k, count - j + 1)], answer[i][j][k] + closeCost[i]);
				}
			}
		}
		int[][] delta = answer[count];
		int[][] matrix = new int[2 * count + 1][2 * count + 1];
		ArrayUtils.fill(matrix, Integer.MAX_VALUE / 2);
		for (int i = 0; i < matrix.length; i++) {
			for (int j = Math.max(0, count - i); j <= 2 * count && i + j - count < matrix.length; j++) {
				for (int k = 0; k <= i && k <= count; k++)
					matrix[i][i + j - count] = Math.min(matrix[i][i + j - count], delta[j][k]);
			}
		}
		int[][] result = new int[matrix.length][matrix.length];
		int[][] temp = new int[matrix.length][matrix.length];
		power(repeats, result, temp, matrix);
		out.printLine(result[0][0]);
    }

	private void power(int exponent, int[][] result, int[][] temp, int[][] matrix) {
		if (exponent == 1) {
			for (int i = 0; i < matrix.length; i++)
				System.arraycopy(matrix[i], 0, result[i], 0, matrix.length);
			return;
		}
		if ((exponent & 1) == 0) {
			power(exponent >> 1, temp, result, matrix);
			multiply(result, temp, temp);
		} else {
			power(exponent - 1, temp, result, matrix);
			multiply(result, temp, matrix);
		}
	}

	private void multiply(int[][] a, int[][] b, int[][] c) {
		ArrayUtils.fill(a, Integer.MAX_VALUE / 2);
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a.length; j++) {
				for (int k = 0; k < a.length; k++)
					a[i][k] = Math.min(a[i][k], b[i][j] + c[j][k]);
			}
		}
	}

	}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

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

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

	public int 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 boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

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

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

class OutputWriter {
	private final PrintWriter writer;

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

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

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

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

class IOUtils {

	public static int[] readIntArray(InputReader in, int size) {
		int[] array = new int[size];
		for (int i = 0; i < size; i++)
			array[i] = in.readInt();
		return array;
	}

	}

class ArrayUtils {

	public static void fill(int[][] array, int value) {
		for (int[] row : array)
			Arrays.fill(row, value);
	}

	public static void fill(int[][][] array, int value) {
		for (int[][] subArray : array)
			fill(subArray, value);
	}

	}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class C {
	static int[] openCost, closedCost;
	static int[][][] dp;
	static int inf = 10000000;

	public static int solve(int curCost, int endCost, int remMoves) {
		if (remMoves == openCost.length) {
			if (curCost == endCost) {
				return 0;
			}
			return inf;
		}
		if (dp[curCost][endCost][remMoves] != -1) {
			return dp[curCost][endCost][remMoves];
		}
		int min = Integer.MAX_VALUE;
		if (curCost > 0) {
			if (curCost < 2 * openCost.length) {
				min = Math.min(
						openCost[remMoves]
								+ solve(curCost + 1, endCost, remMoves + 1),
						closedCost[remMoves]
								+ solve(curCost - 1, endCost, remMoves + 1));
			} else {
				min = Math.min(
						min,
						closedCost[remMoves]
								+ solve(curCost - 1, endCost, remMoves + 1));
			}
		} else {
			min = Math.min(
					min,
					openCost[remMoves]
							+ solve(curCost + 1, endCost, remMoves + 1));
		}
		return dp[curCost][endCost][remMoves] = min;
	}

	public static int[][] getOpt(int[][] mat1, int[][] mat2) {
		int[][] res = new int[mat1.length][mat2.length];
		for (int i = 0; i < mat1.length; i++) {
			for (int j = 0; j < mat1.length; j++) {
				res[i][j] = Integer.MAX_VALUE;
				for (int k = 0; k < mat1.length; k++) {
					res[i][j] = Math.min(res[i][j], mat1[i][k] + mat2[k][j]);
				}
			}
		}
		return res;
	}

	public static void main(String[] args) throws Exception {
		int n = nextInt();
		int m = nextInt();
		openCost = new int[n];
		closedCost = new int[n];
		for (int i = 0; i < n; i++) {
			openCost[i] = nextInt();
		}
		for (int i = 0; i < n; i++) {
			closedCost[i] = nextInt();
		}
		dp = new int[2 * n + 1][2 * n + 1][n];
		for (int i = 0; i < dp.length; i++) {
			for (int j = 0; j < dp[0].length; j++) {
				Arrays.fill(dp[i][j], -1);
			}
		}
		int[][] costMatrix = new int[2 * n + 1][2 * n + 1];
		for (int i = 0; i <= 2 * n; i++) {
			for (int j = 0; j <= 2 * n; j++) {
				costMatrix[i][j] = solve(i, j, 0);
			}
		}
//		for(int i=0;i<costMatrix.length;i++){
//			System.out.println(Arrays.toString(costMatrix[i]));
//		}
		int[][] res = new int[2 * n + 1][2 * n + 1];
		for (int i = 0; i < 2 * n + 1; i++) {
			Arrays.fill(res[i], Integer.MAX_VALUE);
		}
		for (int i = 0; i < 2 * n + 1; i++) {
			res[i][i] = 0;
		}
		while (m > 0) {
			if ((m & 1) == 1) {
				res = getOpt(res, costMatrix);
			}
			costMatrix = getOpt(costMatrix, costMatrix);
			m >>= 1;
		}
		System.out.println(res[0][0]);
	}

	static BufferedReader br = new BufferedReader(new InputStreamReader(
			System.in));
	static StringTokenizer tokenizer = new StringTokenizer("");

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

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

	static String next() throws Exception {
		while (true) {
			if (tokenizer.hasMoreTokens()) {
				return tokenizer.nextToken();
			}
			String s = br.readLine();
			if (s == null) {
				return null;
			}
			tokenizer = new StringTokenizer(s);
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
 * 4:41 ~
 *
 */
public class Main {

	public static void main(String[] argv) {
		FastScanner scan = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = scan.nextInt();
		int t = scan.nextInt();
		int dp[][][][] = new int[n+2][4 * 4 + 5][n+1][n+1];
		for(int i = 0; i < n; i++){
			if(i == 0){
				for(int j = 0; j < 4; j++){
					dp[i+1][j][0][0] = 1;
				}
			} else if(i == 1){
				for(int state = 0; state < 4; state++){
					for(int j = 0; j < 4; j++){
						if(state == j) continue;
						dp[i+1][state * 4 + j][0][0] += dp[i][state][0][0];
					}
				}
			} else {
				for(int state = 0; state < 16; state++){
					int first = state / 4;
					int second = state % 4;
					if(first == second) continue;
					for(int c = 0; c <= i/2; c++){
						for(int d = 0; d <= i/2; d++){
							for(int j = 0; j < 4; j++){
								if(second == j) continue;
								if(first < second){
									if(second < j){
										dp[i+1][second * 4 + j][c][d] += dp[i][state][c][d];
									} else if(second > j){
										dp[i+1][second * 4 + j][c+1][d] += dp[i][state][c][d];
									}
								} else if(first > second){
									if(second < j){
										dp[i+1][second * 4 + j][c][d+1] += dp[i][state][c][d];
									} else if(second > j){
										dp[i+1][second * 4 + j][c][d] += dp[i][state][c][d];
									}
								}
							}
						}
					}
				}
			}
		}
		/*
		for(int i = 0; i <= n+1; i++)
			for(int state = 0; state < 16; state++)
				for(int c = 0; c <= i / 2; c++)
					for(int d = 0; d <= i / 2; d++)
						System.out.println(i + ", (" + (state / 4) + "," + (state % 4) + "), " + c + "," + d + "  => " + dp[i][state][c][d]);
		*/
		int ret = 0;
		for(int state = 0; state < 16; state++){
			int first = state / 4;
			int second = state % 4;
			if(first == second) continue;
			ret += dp[n][state][t][t-1];
		}
		out.println(ret);
		out.close();
	}

	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner(InputStream is) {
			try {
				br = new BufferedReader(new InputStreamReader(is));
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

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

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

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

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


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

public class Camels {
    static Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System. in )));

    static int n, t, wise[][][][][];
    static boolean done[][][][][];
    public static void main(String[] args) {
        n = in .nextInt();
        t = in .nextInt();
        wise = new int[n][t + 1][t][4][4];
        done = new boolean[n][t + 1][t][4][4];
        int ans = 0;
        for (int i = 0; i < 4; i++)
            for (int j = 0; j < i; j++) ans += remember(1, 0, 0, i, j);
        System.out.println(ans);
    }

    static int remember(int x, int h, int v, int y, int yprev) {
        if (done[x][h][v][y][yprev]) return wise[x][h][v][y][yprev];
        int ans = 0;
        if (x == n - 2) {
            if (v == t - 1) {
                for (int ynext = 0; ynext < y; ynext++) {
                    if (ynext < y && yprev < y) a{
                        if (h < t) ans++;
                    } else {
                        if (h == t) ans++;
                    }
                }
            }
        } else {
            for (int ynext = 0; ynext < 4; ynext++)
                if (ynext != y) {
                    if (ynext < y && yprev < y) {
                        if (h < t) ans += remember(x + 1, h + 1, v, ynext, y);
                    } else if (ynext > y && yprev > y) {
                        if (v < t - 1) ans += remember(x + 1, h, v + 1, ynext, y);
                    } else ans += remember(x + 1, h, v, ynext, y);
                }
        }
        done[x][h][v][y][yprev] = true;
        return wise[x][h][v][y][yprev] = ans;
    }
}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author codeKNIGHT
 */
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);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
	public void solve(int testNumber, Scanner in, PrintWriter out) {
        int n=in.nextInt(),m=in.nextInt(),k=in.nextInt(),i,j,x,y,max=0;
        String s;
        int a[][][]=new int[n][m][3];
        for(i=0;i<n;i++)
        {
            s=in.next();
            for(j=0;j<m;j++)
            {
                a[i][j][0]=in.nextInt();
                a[i][j][1]=in.nextInt();
                a[i][j][2]=in.nextInt();
            }
        }
        for(i=0;i<n;i++)
        {
            for(j=0;j<n;j++)
            {
                if(i==j)
                    continue;
                items profit[]=new items[m];
                for(x=0;x<m;x++)
                {
                    profit[x]=new items(a[j][x][1]-a[i][x][0],x);
                }
                Arrays.sort(profit);

                int t=k,count=0,number;
                x=0;
                while(t>0&&x<m)
                {
                    number=Math.min(a[i][profit[x].index][2],t);
                    count+=profit[x].p*number;
                    x++;
                    t-=number;
                }
                if(count>max)
                    max=count;

            }
        }
        out.println(max);
	}
    class items implements Comparable<items>
    {
        int index,p;
        public items(int p,int index)
        {
            this.p=p;
            this.index=index;
        }
        public int compareTo(items a)
        {
            if(a.p>this.p)
                return 1;
            return -1;
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;

public class Main {

	public static class Goods{
		int[]buy = null;
		int[]sell = null;
		int[]rem = null;
		public Goods(int[]buyi, int[]selli, int[]remi){
			buy = buyi;
			sell = selli;
			rem = remi;
		}
		public Goods clone(){
			int[]buyi = new int[buy.length];
			int[]selli = new int[buy.length];
			int[]remi = new int[buy.length];
			for(int i = 0; i < buy.length; i++){
				buyi[i] = buy[i];
				selli[i] = sell[i];
				remi[i] = rem[i];
			}
			return new Goods(buyi, selli, remi);
		}
	}

	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[]parts = br.readLine().split("\\s+");
		int n = Integer.parseInt(parts[0]);
		int m = Integer.parseInt(parts[1]);
		int k = Integer.parseInt(parts[2]);

		Map<Integer, Goods> map = new HashMap<Integer, Main.Goods>();
		for(int i = 0; i < n; i++){
			String name = br.readLine();
			int[]buy = new int[m];
			int[]sell = new int[m];
			int[]rem = new int[m];
			for(int j = 0; j < m; j++){
				parts = br.readLine().split("\\s+");
				buy[j] = Integer.parseInt(parts[0]);
				sell[j] = Integer.parseInt(parts[1]);
				rem[j] = Integer.parseInt(parts[2]);
			}
			Goods g = new Goods(buy, sell, rem);
			map.put(i, g);
		}
		int max = 0;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(i == j)continue;
				Set<Integer> used = new HashSet<Integer>();
				int prods = k;
				Goods buyFrom = map.get(i).clone();
				Goods sellTo = map.get(j).clone();
				int profit = 0;
				while(prods>0&&used.size()!=m){
					int maxPrice = Integer.MIN_VALUE;
					int idx = -1;
					for(int l = 0; l < m; l++){
						if(used.contains(l))continue;
						if(maxPrice < sellTo.sell[l]-buyFrom.buy[l]){
							maxPrice = sellTo.sell[l]-buyFrom.buy[l];
							idx = l;
						}
					}
					int numToBuy = Math.min(buyFrom.rem[idx],prods);
					profit += numToBuy*maxPrice;
					buyFrom.rem[idx] -= numToBuy;
					if(buyFrom.rem[idx] == 0){
						used.add(idx);
					}
					prods -= numToBuy;
				}
				if(profit > max)max = profit;
			}
		}
		System.out.println(max);

	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.Comparator;
import java.util.Hashtable;
import java.util.Vector;
import java.util.PriorityQueue;

public class Main {

    /**
     * @param args
     * @throws IOException
     */
    public static class Product{
        public int a;
        public int b;
        public int c;
        Product(int a,int b,int c){
            this.a=a;
            this.b=b;
            this.c=c;
        }
    }
    public static class Profit{
        public int dif;
        public int c;
        Profit(int d,int c){
            this.dif=d;
            this.c=c;
        }
    }
    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        //Scanner in=new Scanner(System.in);
        PrintWriter out=new PrintWriter(System.out);
        String[] cur=in.readLine().split(" ");
        int n=Integer.parseInt(cur[0]);
        int m=Integer.parseInt(cur[1]);
        int k=Integer.parseInt(cur[2]);
        Vector<Vector<Product>> vect=new Vector<Vector<Product>>();
        Vector<String> names=new Vector<String>();
        for(int i=0; i<n; i++){
            names.add(in.readLine());
            vect.add(new Vector<Product>());
            for(int j=0; j<m; j++){
                String[] product=in.readLine().split(" ");
                vect.get(i).add(new Product(Integer.parseInt(product[0]),Integer.parseInt(product[1]),Integer.parseInt(product[2])));
            }
        }
        long maxProfit=0;
        for(int i=0; i<n; i++){
            for(int j=i+1; j<n; j++){
                Vector<Product> f=vect.get(i);
                Vector<Product> s=vect.get(j);
                PriorityQueue<Profit> ch=new PriorityQueue<Profit>(m,new Comparator<Profit>(){
                    public int compare(Profit a,Profit b){
                        if(a.dif>b.dif) return -1;
                        else if(a.dif<b.dif) return 1;
                        return 0;
                    }
                });
                for(int z=0; z<m; z++){
                    ch.add(new Profit(s.get(z).b-f.get(z).a,f.get(z).c));

                }
                int curK=k;
                int curProfit=0;
                while(curK>0 && !ch.isEmpty()){
                    Profit curProf=ch.poll();
                    int step=Math.min(curK,curProf.c);
                    if(curProf.dif>0) curProfit+=step*curProf.dif;
                    else break;
                    curK-=curProf.c;
                }
                if(curProfit>maxProfit) maxProfit=curProfit;
            }
        }
        out.println(maxProfit);
        out.close();
    }

}


import java.util.*;
public class C {
	Scanner sc = new Scanner(System.in);
	class Data {
		int a, b, c;
		Data() {}
		Data(int a, int b, int c) {
			this.a = a; this.b = b; this.c = c;
		}
	}
	class Diff implements Comparable<Diff>{
		int d; int idx;
		Diff() { }
		Diff(int d, int idx) { this.d = d; this.idx = idx; }
		public int compareTo(Diff other) { // 大きい順に並び替える
			if(d > other.d) return -1;
			if(d < other.d) return +1;
			return 0;
		}
	}
	void doIt()
	{
		int n = sc.nextInt(), m = sc.nextInt(), k = sc.nextInt();
		Data [][] data = new Data[n][m];
		for(int i = 0; i < n; i++) {
			String name = sc.next();
			for(int j = 0; j < m; j++) {
				int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
				data[i][j] = new Data(a, b, c);
			}
		}
		int ans = 0;
		for(int from = 0; from < n; from++) {
			for(int to = 0; to < n; to++) {
				if(from==to) continue;
				ArrayList<Diff> diffs = new ArrayList<Diff>();
				for(int i = 0; i < n; i++) {
					int d = data[to][i].b - data[from][i].a;
					if(d > 0) diffs.add(new Diff(d, i));
				}
				Collections.sort(diffs);
				int rem = k, work = 0;
				for(Diff d: diffs) {
					int qty = data[from][d.idx].c;
					if(qty < rem) {
						rem -= qty;
						work += qty * d.d;
					} else {
						work += rem * d.d;
						break;
					}
				}
				ans = Math.max(ans, work);
			}
		}
		System.out.println(ans);
	}
	public static void main(String[] args) {
		new C().doIt();
	}

}


import java.util.*;
public class C181{
	public static void main(String[] args){
		Scanner br = new Scanner(System.in);
		int n = br.nextInt();
		int m = br.nextInt();
		int k = br.nextInt();
		int[][] cost = new int[n][m];
		int[][] sell = new int[n][m];
		int[][] am = new int[n][m];
		for(int i = 0;i<n;i++){
			String name = br.next();
			for(int j = 0;j<m;j++){
				cost[i][j] = br.nextInt();
				sell[i][j] = br.nextInt();
				am[i][j] = br.nextInt();
			}
		}
		int best = 0;
		for(int i = 0;i<n;i++){
			for(int j = 0;j<n;j++){
				if(i == j){
					continue;
				}
				int tk = k;
				int profit = 0;
				boolean bought = true;
				int[] left = new int[m];
				for(int l = 0;l<n;l++){
					left[l] = am[i][l];
				}
				while(tk > 0 && bought){
					bought = false;
					int bp = -1;
					int index = -1;
					for(int something = 0;something<m;something++){
						if(left[something] > 0){
							if(sell[j][something]-cost[i][something] > bp){
								bp = sell[j][something]-cost[i][something];
								index = something;
							}
						}
					}
					if(bp != -1){
						bought = true;
						int tam = Math.min(tk, left[index]);
						tk-=tam;
						left[index]-=tam;
						profit+=(bp*tam);
					}
				}
				best = Math.max(best, profit);
			}
		}
		System.out.println(best);
	}
}


public class Mahmoud {

        public String isEven(double n) {
            if ((n % 2) == 0)
                return "Mahmoud";
            else
                return "Ehab";
        }
    }


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

public class Bun {

    public static int a[]=new int[200];
    public static int b[]=new int[200];
    public static int c[]=new int[200];
    public static int d[]=new int[200];
    public static long dp[][][]=new long[2000][200][200];
    public static int m;
    public static long sol(int index,int dough,int staff){
        if(dough<0||index==m+1){
            return 0;
        }
        if(dp[dough][staff][index]!=-1){
            return dp[dough][staff][index];
        }
        long way1=0;
        if(staff>=b[index]&&dough>=c[index]){
            way1=d[index]+sol(index,dough-c[index],staff-b[index]);
        }
        long way2=sol(index+1,dough,a[index+1]);
        return dp[dough][staff][index]=Math.max(way1, way2);
    }
    public static void main(String[] args) throws IOException {
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
        String s="";
        while((s=in.readLine())!=null){
            String f[]=s.split(" ");
            int dough=Integer.parseInt(f[0]);
             m=Integer.parseInt(f[1]);
            int c0=Integer.parseInt(f[2]);
            int d0=Integer.parseInt(f[3]);
            a[0]=0;
            c[0]=c0;
            d[0]=d0;
            for (int i = 1; i <m+1; i++) {
                f=in.readLine().split(" ");
                a[i]=Integer.parseInt(f[0]);
                b[i]=Integer.parseInt(f[1]);
                c[i]=Integer.parseInt(f[2]);
                d[i]=Integer.parseInt(f[3]);

            }
            for (int i = 0; i <=dough+5; i++) {
                for (int j = 0; j <=105; j++) {
                    for (int j2 = 0; j2 <=105; j2++) {
                        dp[i][j][j2]=-1;
                    }
                }
            }

            long res=sol(0,dough,b[0]);
            out.println(res);

        }
out.close();
    }

}


import java.util.Scanner;

public class Magnets {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int c = 1; // count the number of groups
		char prev = '0';
		boolean isFirst = true;
		for (int i = 0; i < n; i++) {
			String t = in.next();
			// System.out.println(t);
			if (isFirst || t.charAt(0) != prev) isFirst = false;
			else c++;
			prev = t.charAt(1);
		}
		System.out.println(c);
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
    static int factorial(int a){
        int dp[]= new int[a+1];
        Arrays.fill(dp,0);
        int ans=1;
        for (int i=1;i<=a;i++){
            ans=ans*i;
        }
        return dp[a]=ans;
    }
    static int gcd(int a,int b) {
        return b == 0 ? a : gcd(b, a % b);
    }
   public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n1=sc.nextInt();
        int num2=sc.nextInt();
        int a1=factorial(n1);
        int a2=factorial(num2);
       System.out.println(gcd(a1,a2));

        }

        static void sort(int[] a) {
        ArrayList<Integer> l=new ArrayList<>();
        for (int i:a) l.add(i);
        Collections.sort(l);
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }
    static void sortReverse(long[] a) {
        ArrayList<Long> l=new ArrayList<>();
        for (long i:a) l.add(i);
//        Collections.sort.(l);
        Collections.sort(l,Collections.reverseOrder());
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }

    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }

}


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

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

    static class CBinarySearch {
        long MOD = (long) 1e9 + 7;

        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int x = in.nextInt();
            int pos = in.nextInt();

            int less = 0;
            int more = 0;
            int l = 0;
            int r = n;
            while (l < r) {
                int mid = (l + r) / 2;
                if (mid == pos) break;
                if (mid < pos) {
                    l = mid + 1;
                    less++;
                } else {
                    r = mid;
                    more++;
                }
            }
            if (less >= x || more > (n - x)) {
                out.println("0");
                return;
            }
            long ans = A(x - 1, less);
            ans = (ans * A(n - x, more)) % MOD;
            ans = (ans * A(n - less - more - 1, n - less - more - 1)) % MOD;
            out.println(ans);

        }

        private long A(int a, int b) {
            long ans = 1;
            for (int i = 0; i < b; i++) {
                ans = (ans * (a - i)) % MOD;
            }
            return ans;
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

            }
            return st.nextToken();
        }

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

    }
}


import java.uti.*;
public class A1{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long r = sc.nextLong();
        if(r%2==0){
            System.out.println("NO");
        }
        else{
            System.out.print(1+" "+(r-3)/2);
        }
    }
}


import java.util.Scanner;

public class A1 {
	public static long h(long x) {
		return x * x + 2 * x + x + 1;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long r = sc.nextLong();
		long dod = 2;
		long osn = h(1);
		long x = 1;
		long res;
		while (osn <= r) {
			res = osn;
			long i = 1;
			while (res <= r) {
				// System.out.println(res);
				if (res == r) {
					System.out.println(x + " " + i);
					return;
				}
				i++;
				res += dod;
			}
			dod += 2;
			x++;
			osn = h(x);
		}
		System.out.println("NO");
	}
}


import java.util.*;

public class A1{
    public static void main(String[] args){
        Scanner s=new Scanner(System.in);
        long r=s.nextInt();
        long finalx=-1,finaly=-1;
        for(long x=1;x<=(int)1e6;x++){
            long temp=r-x*x-x-1;
            if(temp!=0&&temp%(2*x)==0){
                finalx=x;
                finaly=temp;
                break;
            }
        }
        if(finalx!=-1 && finaly!=-1)System.out.println(finalx+" "+finaly);
        else System.out.println("NO");

    }


import java.util.*;
import java.io.*;
public class hele{
	public static void main(String s[]){
		Scanner sc = new Scanner(System.in);
		long k = sc.nextLong();
		long sqrt = 1000000;
		boolean b=false;
		for(int i=1;i<=sqrt;i++){
			long y = (long)((long)k-(long)(i*i)-(long)i-(long)1)%(long)(2*(long)i);
			if(y==0){
				long df = (long)((k-(long)(i*i)-(long)i-(long)1)/(long)(2*(long)i);
				if(df>0){
				System.out.println(i+" "+df);
				b=true;
				break;}
			}
		}
		if(b==false)
			System.out.println("NO");
	}
}


import java.io.*;
import java.security.KeyPair;
import java.util.*;

public class Main
{
	public static int[][] arr = new int[1][1];
	public static boolean[][] visited = new boolean[1][1];
	public static boolean game = false;
    public static void main(String[] args)
    {
    	Scanner sc = new Scanner(System.in);
    	int currenti = sc.nextInt();
    	int currentj = sc.nextInt();
    	int reachi = sc.nextInt();
    	int reachj = sc.nextInt();
    	if(currenti == reachi && currentj == reachj) {
    		System.out.print(0 + " " );
    	}else if(currenti == reachi || currentj == reachj) {
    		System.out.print(1 + " ");
    	}else {
    		System.out.print(2+ " ");
    	}
    	int evencountcurrent = 0;
    	int oddcountcurrent = 0;
    	if(currenti % 2 ==0 ) {
    		evencountcurrent++;
    	}else {
    		oddcountcurrent++;
    	}
    	if(currentj % 2 == 0) {
    		evencountcurrent++;
    	}else {
    		oddcountcurrent++;
    	}
    	int evencountd = 0;
    	int oddcountd = 0;
    	if(reachi % 2 ==0 ) {
    		evencountd++;
    	}else {
    		oddcountd++;
    	}
    	if(reachj % 2 == 0) {
    		evencountd++;
    	}else {
    		oddcountd++;
    	}
    	if(!(evencountcurrent == evencountd && oddcountd == oddcountcurrent)) {
    		System.out.print(0+ " ");
    	}else if(checkdiagnol(currenti,currentj,reachi,reachj)) {
    		System.out.print(1+ " ");
    	}else {
    		System.out.print(2+ " ");
    	}
    	System.out.println(counter(currenti,currentj,reachi,reachj));
    }
    public static int counter(int ci,int cj, int ri,int rj) {
    	int count = 0;
    	while(ci != ri || rj != cj) {
    		if(ri > ci) {
    			ci++;
    		}else if(ri < ci) {
    			ci--;
    		}
    		if(ri > cj) {
    			cj++;
    		}else if(ri < cj) {
    			cj--;
    		}
    		count++;
    	}
    	return count;

    }
    public static boolean checkdiagnol(int ci,int cj, int ri,int rj) {
    	int cci = ci;
    	int ccj = cj;
    	while(cci >= 0 && ccj >=0) {
    		if(cci == ri && ccj == rj) {
    			return true;
    		}
    		cci--;
    		ccj--;
    	}
    	cci = ci;
        ccj = cj;
    	while(cci < 8 && ccj < 8) {
    		if(cci == ri && ccj == rj) {
    			return true;
    		}
    		cci++;
    		ccj++;
    	}
    	cci = ci;
        ccj = cj;
    	while(cci >=0 && ccj < 8) {
    		if(cci == ri && ccj == rj) {
    			return true;
    		}
    		cci--;
    		ccj++;
    	}
    	cci = ci;
        ccj = cj;
    	while(cci < 8 && ccj >= 0) {
    		if(cci == ri && ccj == rj) {
    			return true;
    		}
    		cci++;
    		ccj--;
    	}
    	return false;

    }
}


package practice;

import util.FastReader;
import java.io.PrintWriter;

public class RookBishopKing {
    public void solve(int testNumber, FastReader in, PrintWriter out) {
        int r1 = in.nextInt();
        int c1 = in.nextInt();
        int r2 = in.nextInt();
        int c2 = in.nextInt();

        // rook
        if (r1 == r2 || c1 == c2) {
            out.print("1 ");
        } else {
            out.print("2 ");
        }

        // bishop
        if ((r1 + r2) % 2 != (c1 + c2) % 2) {
            out.print("0 ");
        } else {
            if (Math.abs(r1 - r2) == Math.abs(c1 - c2)) {
                out.print("1 ");
            } else {
                out.print("2 ");
            }
        }

        // king
        out.print(Math.max(Math.abs(r1-r2), Math.abs(c1-c2)));
    }
}


////package CodeForce;
import java.io.*;
import java.util.*;
/**
 *
 * @author prabhat
 */
public class R455D2A {

    static long[] a;
    static int[] S;
    static long[] sum;
    static int mod=1000000007;
   static int[][] dp;
   static boolean[][] isPalin;
   static int max1=5000+10;
   static int[][] g;
   static int ver;
   static int n;
   static boolean[] visit;
   static LinkedList<Pair> l[];
   static int ans=0;
   static int[] color;
   static LinkedList<Long> list[];
  public static void main(String[] args) throws Exception
   {
   	InputReader in = new InputReader(System.in);
   	PrintWriter pw=new PrintWriter(System.out);
      int n=in.ii();
      int k=n*(n+1)/2;
      if(n%2==0&&k%2==0)pw.println(k-n);
      else if(n!=1&&n%2!=0&&k%2!=0)pw.println(k-n-1);
      else if((n%2==0&&k%2!=0)||(n%2!=0&&k%2==0))pw.println(k-n+1);
      else if(n==1)pw.println(1);
  /*   String s1=in.is().trim();
     String s2=in.is();
    LinkedList<String> l=new LinkedList<>();
      for(int i=0;i<s1.length();i++)
      {
        l.add(s1.substring(0,i+1));
      }
      LinkedList<String> list=new LinkedList<>();
      for(int i=0;i<l.size();i++)
      {
        String s=l.get(i)+s2.charAt(0);
        list.add(s);
      }
      Collections.sort(list);
     // for(String s:list)pw.println(s);
     pw.println(list.get(0));*/
   	 pw.close();
   }
 static int length(long n)
 {
  int cnt=0;
  while(n>0)
  {
   cnt++;
   n>>=1;
  }
  return cnt;
 }
  static  void dfs(int i)
  {
	  if(visit[i])return ;
	  visit[i]=true;
	  for(int o:g[i])
		  if(!visit[o])
			  dfs(o);

  }
  private static class DSU{
		int[] parent;
		int[] rank;
		int cnt;
		public DSU(int n){
			parent=new int[n];
			rank=new int[n];
			for(int i=0;i<n;i++){
				parent[i]=i;
				rank[i]=1;
			}
			cnt=n;
		}
		int find(int i){
	        while(parent[i] !=i){
	        	parent[i]=parent[parent[i]];
	        	i=parent[i];
	        }
	        return i;
	    }
		int Union(int x, int y){
	        int xset = find(x);
	        int yset = find(y);
	        if(xset!=yset)
	        	cnt--;
	        if(rank[xset]<rank[yset]){
	        	parent[xset] = yset;
		        rank[yset]+=rank[xset];
		        rank[xset]=0;
		        return yset;
	        }else{
	        	parent[yset]=xset;
	        	rank[xset]+=rank[yset];
	        	rank[yset]=0;
	        	return xset;
	        }
	    }
	}
  public static int[][] packU(int n, int[] from, int[] to, int max) {

	    int[][] g = new int[n][];
	    int[] p = new int[n];
	    for (int i = 0; i < max; i++) p[from[i]]++;
	    for (int i = 0; i < max; i++) p[to[i]]++;
	    for (int i = 0; i < n; i++) g[i] = new int[p[i]];
	    for (int i = 0; i < max; i++) {
	        g[from[i]][--p[from[i]]] = to[i];
	        g[to[i]][--p[to[i]]] = from[i];
	    }
	    return g;
	}
	public static int[][] parents3(int[][] g, int root) {
	    int n = g.length;
	    int[] par = new int[n];
	    Arrays.fill(par, -1);

	    int[] depth = new int[n];
	    depth[0] = 0;

	    int[] q = new int[n];
	    q[0] = root;
	    for (int p = 0, r = 1; p < r; p++) {
	        int cur = q[p];
	        for (int nex : g[cur]) {
	            if (par[cur] != nex) {
	                q[r++] = nex;
	                par[nex] = cur;
	                depth[nex] = depth[cur] + 1;
	            }
	        }
	    }
	    return new int[][]{par, q, depth};
	}
	public static int lower_bound(int[] nums, int target) {
        int low = 0, high = nums.length - 1;
        while (low < high) {
            int mid = low + (high - low) / 2;
            if (nums[mid] < target)
                low = mid + 1;
            else
                high = mid;
        }
        return nums[low] == target ? low : -1;
    }

    public static int upper_bound(int[] nums, int target) {
        int low = 0, high = nums.length - 1;
        while (low < high) {
            int mid = low + (high + 1 - low) / 2;
            if (nums[mid] > target)
                high = mid - 1;
            else
                low = mid;
        }
        return nums[low] == target ? low : -1;
    }
  public static boolean palin(String s)
	{
	   int i=0;
	   int j=s.length()-1;
	   while(i<j)
	   {
		   if(s.charAt(i)==s.charAt(j))
		   {
			   i++;
			   j--;
		   }
		   else return false;
	   }
	   return true;
	}

    static boolean CountPs(String s,int n)
       {
    	boolean b=false;
    	     char[] S=s.toCharArray();
	       int[][] dp=new int[n][n];
	       boolean[][] p=new boolean[n][n];
	       for(int i=0;i<n;i++)p[i][i]=true;

	       for(int i=0;i<n-1;i++)
	       {
	    	   if(S[i]==S[i+1])
	    	   {
	    		p[i][i+1]=true;
	    		dp[i][i+1]=1;
	    		b=true;
	    	   }
	       }

	       for(int gap=2;gap<n;gap++)
	       {
	    	   for(int i=0;i<n-gap;i++)
	    	   {
	    		   int j=gap+i;
	    		   if(S[i]==S[j]&&p[i+1][j-1]){p[i][j]=true;}

	    		  if(p[i][j])
	    			   dp[i][j]=dp[i][j-1]+dp[i+1][j]+1-dp[i+1][j-1];

	    		   else  dp[i][j]=dp[i][j-1]+dp[i+1][j]-dp[i+1][j-1];

	    		   if(dp[i][j]>=1){b=true;}
	    	   }
	       }

	    return b;
   // return dp[0][n-1];

    }

public static int gcd(int a,int b)
{
	int res=1;
	while(a>0)
	{
		res=a;
		a=b%a;
		b=res;
	}
	return res;
}

public static long pow(long n,long p,long m)
{
	 long  result = 1;
	  if(p==0)
	    return 1;
	if (p==1)
	    return n;
	while(p!=0)
	{
	    if(p%2==1)
	        result *= n;
	    if(result>=m)
	    result%=m;
	    p >>=1;
	    n*=n;
	    if(n>=m)
	    n%=m;
	}
	return result;
}
public static long pow(long n,long p)
{
	long  result = 1;
	  if(p==0)
	    return 1;
	if (p==1)
	    return n;
	while(p!=0)
	{
	    if(p%2==1)
	        result *= n;
	    p >>=1;
	    n*=n;
	}
	return result;

}

static class Edge implements Comparator<Edge> {
	private int u;
	private int v;
	private int w;
	public Edge() {
	}
	public Edge(int u, int v, int w) {
		this.u=u;
		this.v=v;
		this.w=w;
	}
	public int getU() {
		return u;
	}
	public void setU(int u) {
		this.u = u;
	}
	public int getV() {
		return v;
	}
	public void setV(int v) {
		this.v = v;
	}
	public int getW() {
		return w;
	}
	public void setW(int w) {
		this.w = w;
	      }
	public int compareTo(Edge e)
	  {
		return this.getW() - e.getW();
	}
	@Override
	public String toString() {
		return "Edge [u=" + u + ", v=" + v + ", w=" + w + "]";
	}
	@Override
	public int compare(Edge arg0, Edge arg1) {
		// TODO Auto-generated method stub
		return 0;
	}
}

static class Pair implements Comparable<Pair>
{
	int a,b;
	Pair (int a,int b)
	{
		this.a=a;
		this.b=b;
	}

	public int compareTo(Pair o) {
		// TODO Auto-generated method stub
		if(this.a!=o.a)
		return -Integer.compare(this.a,o.a);
		else
			return -Integer.compare(this.b, o.b);
		//return 0;
	}
	public boolean equals(Object o) {
       if (o instanceof Pair) {
           Pair p = (Pair)o;
           return p.a == a && p.b == b;
       }
       return false;
   }
   public int hashCode() {
       return new Integer(a).hashCode() * 31 + new Integer(b).hashCode();
   }
}

static  class InputReader
{
   private InputStream stream;
   private byte[] buf = new byte[1024];

   private SpaceCharFilter filter;
    byte inbuffer[] = new byte[1024];
   int lenbuffer = 0, ptrbuffer = 0;
    final int M = (int) 1e9 + 7;
   int md=(int)(1e7+1);
    int[] SMP=new int[md];
   final double eps = 1e-6;
   final double pi = Math.PI;

	PrintWriter out;
   String check = "";
 InputStream   obj = check.isEmpty() ? System.in : new ByteArrayInputStream(check.getBytes());
   public InputReader(InputStream stream)
   {
       this.stream = stream;
   }

    int readByte() {
	        if (lenbuffer == -1) throw new InputMismatchException();
	        if (ptrbuffer >= lenbuffer) {
	            ptrbuffer = 0;
	            try {
	                lenbuffer = obj.read(inbuffer);
	            } catch (IOException e) {
	                throw new InputMismatchException();
	            }
	        }
	        if (lenbuffer <= 0) return -1;
	        return inbuffer[ptrbuffer++];
   }

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

   String is() {
	        int b = skip();
	        StringBuilder sb = new StringBuilder();
	        while (!(isSpaceChar(b))) // when nextLine, (isSpaceChar(b) && b!=' ')
	        {
	            sb.appendCodePoint(b);
	            b = readByte();
	        }
	        return sb.toString();
   }
   public   int ii() {
	        int num = 0, b;
	        boolean minus = false;
	        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
	        if (b == '-') {
	            minus = true;
	            b = readByte();
	        }
	        while (true) {
	            if (b >= '0' && b <= '9') {
	                num = num * 10 + (b - '0');
	            } else {
	                return minus ? -num : num;
	            }
	            b = readByte();
	        }
   }
 public   long il() {
	        long num = 0;
	        int b;
	        boolean minus = false;
	        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
	        if (b == '-') {
	            minus = true;
	            b = readByte();
	        }
	        while (true) {
	            if (b >= '0' && b <= '9') {
	                num = num * 10 + (b - '0');
	            } else {
	                return minus ? -num : num;
	            }
	            b = readByte();
	        }
   }

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

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

	    float nf() {
	        return Float.parseFloat(is());
	    }

	    double id() {
	        return Double.parseDouble(is());
	    }

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

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

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

	    String[] isa(int n) {
	        String a[] = new String[n];
	        for (int i = 0; i < n; i++) a[i] = is();
	        return a;
	    }

		 long mul(long a, long b) { return a * b % M; }

			long div(long a, long b)
				 {
					return mul(a, pow(b, M - 2));

		           }

	    double[][] idm(int n, int m) {
	        double a[][] = new double[n][m];
	        for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) a[i][j] = id();
	        return a;
	        }

	    int[][] iim(int n, int m) {
	        int a[][] = new int[n][m];
	        for (int i = 0; i < n; i++) for (int j = 0; j <m; j++) a[i][j] = ii();
	        return a;
          }

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

   public interface SpaceCharFilter
   {
       public boolean isSpaceChar(int ch);
   }
   public boolean isEndOfLine(int c) {
       return c == '\n' || c == '\r' || c == -1;
   }
}

}


import com.sun.xml.internal.stream.Entity;
import java.util.Scanner;

public class Codeforces909B {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        System.out.println((n-1)*2);

    }
}


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

public class Solution {

    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = nextInt(),result=0;
        for(int i=N ; 0<i ; i-=2){result += i ;}
        System.out.print(result);

    }
}


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

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

/**
 *
 * @author Andy Phan
 */
public class m {
    public static void main(String[] args) {
        FS in = new FS(System.in);
        PrintWriter out = new PrintWriter(System.out);

        System.out.println((((in.nextInt()%360+360+44)%360)%359)/90);

        out.close();
    }

    static class FS {

        BufferedReader in;
        StringTokenizer token;

        public FS(InputStream str) {
            in = new BufferedReader(new InputStreamReader(str));
        }

        public String next() {
            if (token == null || !token.hasMoreElements()) {
                try {
                    token = new StringTokenizer(in.readLine());
                } catch (IOException ex) {
                }
                return next();
            }
            return token.nextToken();
        }

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


import java.util.*;
public class CodeForces
{

    public static void main(String[] args)
	{

            Scanner in = new Scanner(System.in);
            long angle = in.nextLong();
            if(angle < 0 ) angle = 360 - (Math.abs(angle)%360);
            else angle = angle%360;

            if(angle == 0 || angle == 360) System.out.println(0);
            else if( angle <= 45 ) System.out.println(0);
            else if( angle <= 135) System.out.println(1);
            else if( angle <= 225) System.out.println(2);
            else if( angle <= 315) System.out.println(3);
            else if( angle < 360)  System.out.println(4);
        }

}


import java.util.Scanner;

public class M {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		Long n = in.nextLong();
		n = n%360;

		if(n<0){
			n=360+n;
		}
		System.out.println(Math.round(n/90.0));
	}

}


import java.util.*;
import java.io.*;
import java.math.BigInteger;
/*
3
24

1 1 5 5
 */
public class a
{
	public static void main(String[] arg) throws IOException
	{
		new a();
	}
	public a() throws IOException
	{
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		double angle = (in.nextInt()%360+360)%360;
		angle = angle+44;
		angle %= 359;
		if(angle <= 89) out.println(0);
		else if(angle <= 179) out.println(1);
		else if(angle <= 269) out.println(2);
		else if(angle <= 358) out.println(3);
		in.close(); out.close();
	}

	public long pow(long base, long exp)
	{
		if(exp == 0) return 1;
		if((exp&1) == 1) return base*pow(base, exp-1)%100000;
		long ret = pow(base, exp/2)%100000;
		return ret*ret%100000;
	}
	public long choose(long n, long k)
	{
		if(k == 0)
			return 1;
		return choose(n, k-1)*(n-k+1)/k;
	}
	long gcd(long a, long b)
	{
		return b == 0 ? a:gcd(b, a%b);
	}
	class FastScanner
	{
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(InputStream in)
		{
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}
		public String next() throws IOException
		{
			while(!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 double nextDouble() throws IOException
		{
			return Double.parseDouble(next());
		}
		public void close() throws IOException
		{
			br.close();
		}
	}
}


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

public class Main {

	static Scanner sc = new Scanner(System.in);

	static long x;

	public static void main(String[] args) {
		x = sc.nextLong();

		x = x % 360;

		if (x >= 0 && x <= 45) {System.out.println(0); return;}
		if (x > 45 && x <= 135) {System.out.println(1); return;}
		if (x > 135 && x <= 225) {System.out.println(2); return;}
		if (x > 225 && x < 315) {System.out.println(3); return;}
		if (x >= 315) {System.out.println(0); return;}

		if (x <= 0 && x >= -45) {System.out.println(0); return;}
		if (x < -45 && x > -135) {System.out.println(3); return;}
		if (x <= -135 && x > -225) {System.out.println(2); return;}
		if (x <= -225 && x > - 315) {System.out.println(1); return;}
		if (x <= -315 && x > 0) {System.out.println(0); return;}
	}

}


import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Candidate {
    public static void main(String[] args) throws Exception {
        FastReader sc=new FastReader();
        int n=sc.nextInt();
        int x=1,y=1,p=1,q=n;
        boolean z=true;
        boolean a=true;
        LinkedList<Point> ll=new LinkedList<>();
        while(a){
            if(z){
                if(Math.abs(q-y)==1){
                    ll.add(new Point(x,y+1));
                    System.out.println("white");
                    System.out.println(ll.getFirst().x+" "+ll.getFirst().y);
                    return;
                }
                else{
                    z=false;
                    y=y+1;
                    ll.add(new Point(x,y));
                }
            }
            else{
                if(Math.abs(q-y)==1){
                    System.out.println("black");
                    return;
                }
                else{
                    z=true;
                    q=q-1;
                }
            }
        }
    }
}
class FastReader {
    BufferedReader br;
    StringTokenizer st;

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

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

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

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

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

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


    import java.util.Scanner;

    public class Solution{

        public static void main(String args[]){
            Scanner scn = new Scanner(System.in);
            long n = scn.nextLong();
            StringBuilder sb = new StringBuilder();
            if((n%2 == 0){
                sb.append("white");
                sb.append("\n");
                sb.append("1 2");
                System.out.println(sb.toString());
                return;
            }
            sb.append("black");
            System.out.println(sb.toString());
        }
    }


import java.util.Scanner;
public class Main{
    public static void main(String[] args){
    Scanner input = new Scanner(System.in);
    int n = input.nextInt();
    while(n>=1&&n<=100){
    if(n%2==0){
        System.out.println("YES");
    }
    else{
        System.out.println("NO");
    }
    }
    }
}


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

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

/* Name of the class has to be "Main" only if the class is public. */
 public class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
	Scanner n=new Scanner(System.in);
	int a=n.nextInt();
	while(a>=1 || a<=100){
	if(a%2==0)
	System.out.print("Yes");
	else
	System.out.print("No");
	}
	}
}


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

/**
 * Created by saksham on 10-08-2016.
 * 370A
 */
public class RookBishopAndKing {
    public static void main(String []args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine(), " ");
        int x1 = Integer.parseInt(st.nextToken());
        int y1 = Integer.parseInt(st.nextToken());
        int x2 = Integer.parseInt(st.nextToken());
        int y2 = Integer.parseInt(st.nextToken());
        //Rook
        if(x1 == x2 || y1 == y2) {
            System.out.print(1 + " ");
        } else {
            System.out.print(2 + " ");
        }
        int diffX = x1 - x2;
        if(diffX < 0) diffX = -diffX;
        int diffY = y1 - y2;
        if(diffY < 0) diffY = -diffY;
        //bishop
        if((diffX-diffY) == 0) {
            System.out.print(1 + " ");
        } else if((diffX-diffY)%2 == 0) {
            System.out.print(2 + " ");
        } else {
            System.out.print(0 + " ");
        }
        //king
        if((diffX-diffY) == 0 || y1 == y2) {
            System.out.print(diffX + " ");
        } else if(x1 == x2) {
            System.out.print(diffY + " ");
        } else {
            int steps = 0;
            while(x1 != x2 && y1 != y2) {
                if(x1 < x2 && y1 < y2) {
                    x1++;
                    y1++;
                    steps++;
                } else if(x1 > x2 && y1 < y2) {
                    x1--;
                    y1++;
                    steps++;
                } else if(x1 < x2 && y1 < y2) {
                    x1--;
                    y1--;
                    steps++;
                } else if(x1 < x2 && y1 > y2) {
                    x1++;
                    y1--;
                    steps++;
                }

            }
            if(x1 == x2) {
                diffY = y1 - y2;
                if(diffY < 0) diffY = -diffY;
                System.out.print((steps+diffY) + " ");
            } else if(y1 == y2) {
                diffX = x1 - x2;
                if(diffX < 0) diffX = -diffX;
                System.out.print((steps+diffX) + " ");
            }
        }
    }
}


package com.company;

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

/**
 *
 * @author ramilagger
 *
 */
public class Main {

    public final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public final PrintWriter pw = new PrintWriter(System.out);
    public StringTokenizer st;
    int n,m;

    public void solve() throws IOException {
        int[] a = new int[100001];
        int n = nextInt();
        int cnt = 1;
        a[cnt] = 1;

        for (int i = 1; i < n; i++) {
            a[++cnt] = 1;
            while (cnt - 1 >= 0 && a[cnt] == a[cnt - 1]) {
                a[cnt - 1] = a[cnt] + 1;
                a[cnt] = 0;
                cnt--;
            }
        }
        for (int i = 1; i <= cnt; i++) {
            pw.print(a[i] + " ");
        }
    }

    public void run() throws IOException {

        this.solve();
        pw.close();

    }

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

    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 double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

}


import java.util.Scanner;

/**
 * 1/29/16
 **/
public class A {

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

        int[] a = new int[100000];
        int temp = n;
        for(int i =0;i < n; i++) {
            a[i] = temp%2;
            temp = temp/2;
        }

        for(int i =n; i >= 0; i--) {
            if(a[i] == 1) {
                System.out.print(i+1 + " ");
            }
        }

    }
}


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

public class Force_c1_q1 {

    public static void main(String[] args) throws IOException {
        BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(scan.readLine());
	for(int p=0;p<t;p++){
	}
    }

}


import java.util.Scanner;

public class WunderFundRound2016_1 {

	public static void main(String[] args) {
		int[] powers = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536};
		Scanner sc = new Scanner(System.in);
		while (true){
		int n = sc.nextInt();
//		boolean found = false;
		int i=0;
		while (i<17){
			if (n==powers[i]){
//				found = true;
				System.out.println(log(n+1,2));
				return;
			}
			i++;
		}
		i = 0;
		int r = log(n, 2);
		int result = n - (int)Math.pow((double)2,(double)(r-1));
		System.out.print(r+" ");
		while (result != 1){
			n = result;
			while (i<17){
				if (n==powers[i]){
//					found = true;
					System.out.println(log(n+1,2));
					return;
				}
				i++;
			}
			i = 0;
			r = log(n,2 );
			result = n - (int)Math.pow((double)2,(double)(r-1));
			System.out.print(r+" ");
		}
		System.out.print(1);
	}
	}

//	static void printResult(int n , int r){
//		int result = n - (int)Math.pow((double)2,(double)(r-1));
//
//		while (result != 1){
//			System.out.println(r);
//			r = log(result, 2);
//			result = result - (int)Math.pow((double)2,(double)(r-1));
//			printResult(result, log(result, 2));
//		}
//
//	}
	static int log(int x, int base)
	{
		return (int)Math.ceil((Math.log(x) / Math.log(base)));
	}

}


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

public class Qing {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = Integer.parseInt(ns());
		char[] instructions = ns().toCharArray();
		int count = 0;
		for(int len = 1; len <= n ; len ++ ){
			for(int i = 0 ; i + len <= n; i++){
				int[] num = new int[4];
				for(int j = 0; j < len ; j++){
					num[charToInt(instructions[i + j])] ++;
				}
				if(num[0] == num[1] && num[2] == num[3]) count ++;
			}
		}
		out.print(count);
		out.flush();
	}

	public int charToInt(char c){
		if(c == 'U') return 1;
		if(c == 'D') return 2;
		if(c == 'L') return 3;
		if(c == 'R') return 4;
		return 0;
 	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

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

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

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

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

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}

		return n == p ? buf : Arrays.copyOf(buf, p);
	}

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

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

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


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

import java.util.Scanner;

/**
 *
 * @author OmarNasr
 */
public class Acm {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws java.lang.Exception {
        // your code goes here
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String s = in.next();
        int x = 0, y = 0, count = 0;

        for (int i = 0; i < n; i++) {
            for (int j = i; j < n; j++) {
                x = 0;
                y = 0;
                for (char c : s.substring(i, j + 1).toCharArray()) {
                    if (c == 'U') {
                        y++;
                    } else if (c == 'D') {
                        y--;
                    } else if (c == 'R') {
                        x++;
                    } else {
                        x--;
                    }
                }
                if (x == 0 && y == 0) {
                    count++;
                }
            }

        }
        System.out.println(count);
    }

}


import java.util.*;
import java.Math.*;

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

        int x1 = sc.nextInt();
        int x2 = sc.nextInt();
        int x3 = sc.nextInt();

        int avg = (x1+x2+x3)/3;

        int distance = Math.abs(x1-avg) + Math.abs(x2-avg) + Math.abs(x3-avg);

        System.out.println(distance);
    }
}


//package codeForcesTry;

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

public class B509_AmrPins implements Closeable {
	BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter writer = new PrintWriter(System.out);
    StringTokenizer stringTokenizer;

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

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

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

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }
    public void solve()throws IOException {
    	int r,x,y,x1,y1;
    	r=nextInt();x=nextInt();y=nextInt();x1=nextInt();y1=nextInt();
    	long xy=(x-x1)*(x-x1)+(y-y1)*(y-y1);
    	double dist=Math.sqrt(xy);

    	int i=0;

    	while(true){
    		if(2*r*i>=dist)
    			break;
    			i++;
    	}
    	if(dist==0){
    		i=0;
    	}
    	writer.println(i);
    }
    public static void main(String args[]) throws IOException{
    	try(B509_AmrPins c=new B509_AmrPins()){
    	c.solve();
    	}
    }
    public void close() throws IOException {
        reader.close();
        writer.close();
    }

}