package codeforces;

import java.util.Scanner;

public class Q1 {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();

		int i = 1;

		int x = 1;

		if(N==1)
			System.out.print(N);
		else{
			while (N >= x){
				//System.out.println(x);
				N-=x;
				x+=i+1;
				i++;
			}
			i--;
			System.out.print(i);

		}
	}

}


import java.util.*;
public class Next
{
	public static void main(String args[])
	{
		int s=0,l=0,a=0;
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		while(true)
		{
			l=0;
			a++;
			l=(a*(a+1))/2;
			s=s+l;
			if(n/s==1)
			{
				System.out.print(a);
				break;
			}
		}
	}
}


import java.util.*;
public class Next
{
	public static void main(String args[])
	{
		int s=0,l=0,a=0;
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		while(true)
		{
			l=0;
			a++;
			for(int i=1;i<=a;i++)
		   {
			 l=l+i;
		   }
			s=s+l;
			if(n/s==1)
			{
				System.out.print(a);
				break;
			}
		}
	}
}


import java.util.Scanner;

public class JavaApplication191 {

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

        int sum=0;
        int i = 1;
        int height = 1;
         boolean flag = false;
         boolean decrease=false;
        while (true)
        {

            for ( ;i<=height;i++)
            {

                for (int j =i ; j>=0;j--)
                {
                    sum+=j;
                    if (sum==input)
                    {
                        if(j-1>0)decrease=true;
                        flag=true;
                        break;
                    }

                }
             if (flag)break;
            }
            if (flag)break;
            height++;
        }
        if (decrease){height=height-1;}
        System.out.println(height);

}
}


package CodeForce;

import java.io.IOException;
import java.util.Scanner;

public class Game {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		String[] nm = str.split(" ");
		int n1 = Integer.parseInt(nm[0]);
		int n2 = Integer.parseInt(nm[1]);
		int k1 = Integer.parseInt(nm[2]);
		int k2 = Integer.parseInt(nm[3]);
		while (true ){
			n1 --;
			if (n1 == 0){
				System.out.println("Second");
				break;
			}
			n2 --;
			if (n2 == 0){
				System.out.println("First");
				break;
			}
		}
	}
}


package net.crew4ok.olimp;

import java.util.Scanner;

public class Main {

    private static String calc(int n1, int n2, int k1, int k2) {
        if (n1 > n2) {
            return "First";
        } else if (n2 > n1) {
            return "Second";
        } else {
            return "Second";
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n1 = scanner.nextInt();
        int n2 = scanner.nextInt();
        int k1 = scanner.nextInt();
        int k2 = scanner.nextInt();

        System.out.print(calc(n1, n2, k1, k2));
    }
}


package javaapplication1;

import java.util.Scanner;

public class Game {
    public static void main(String []args){
    Scanner sc = new Scanner(System.in);
    int n1 = sc.nextInt();
    int n2 = sc.nextInt();
    int k1 = sc.nextInt();
    int k2 = sc.nextInt();
    while(n1!=0||n2!=0){
     n1--;
     if(n1==0){
         System.out.println("Second");
         break;
     }
     n2--;
     if(n2==0){
         System.out.println("First");
         break;
        }
    }
    }
}


package wow;

import java.util.Scanner;

public class wow {

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

		Scanner scan = new Scanner(System.in);
		int firstBallMove = scan.nextInt();
		int secBallMove = scan.nextInt();
		int firstBall = scan.nextInt();
		int secBall = scan.nextInt();

		while(firstBall >0 && secBall > 0)
		{
			firstBall -= firstBallMove;
			if(firstBall <= 0)
			{
				System.out.println("First");
				break;
			}
			secBall -= secBallMove;
			if(secBall <= 0)
			{
				System.out.println("Second");
				break;
			}
		}
	}

}


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

public class Round157B {

	public static long mod = (long)1e9+7;

	public static void solve() {
		long m = s.nextLong();
		M = Long.toString(m);
		long[] sums = new long[10];
		for(int i = 1; i <= 9; i++) {
			dp = new long[10][i + 1][2];
			for(int j = 0; j < 10; j++) {
				for(int k = 0; k <= i; k++) {
					for(int l = 0; l < 2; l++) {
						dp[j][k][l] = -1;
					}
				}
			}
			sums[i] = Recur(0, 0, 1);
		}
		long[] suffix_sum = new long[10];
		suffix_sum[9] = sums[9];
		for(int i = 8; i >= 0; i--) {
			suffix_sum[i] = suffix_sum[i + 1] + sums[i];
		}
		sums[0] = m - suffix_sum[0];
		suffix_sum[0] = m;
		long ans = 0;
//		for(int i = 1; i < 10; i++) {
//			long me = sums[i];
//			long other = m - suffix_sum[i];
//			if(other < 6) {
//				continue;
//			}else {
//				long tempans = 1;
//				for(long j = other; j >= other - 5; j--) {
//					tempans = (tempans * j)%mod;
//				}
//				tempans = (tempans * me)%mod;
//				ans = ans + tempans;
//				if(ans >= mod) ans -= mod;
//			}
//		}
		long[][] dp2 = new long[10][10];
		for(int i = 0; i < 10; i++) {
			dp2[i][0] = 1;
			long val = sums[i];
			long tempans = 1;
			for(int j = 1; j < 10; j++) {
				tempans = (val * tempans)%mod;
				dp2[i][j] = tempans;
				val--;
			}
		}
		for(int first = 1; first < 10; first++) {
//			int vals = 0;
			int[] count = new int[10];
			for(int second = 0; second < first; second++) {
				for(int third = 0; second + third < first; third++) {
					for(int fourth = 0; second + third + fourth < first; fourth++) {
						for(int fifth = 0; second + third + fourth + fifth < first; fifth++) {
							for(int sixth = 0; second + third + fourth + fifth + sixth < first; sixth++) {
								for(int seventh = 0; second + third + fourth + fifth + sixth + seventh < first; seventh++) {
//									vals++;
									count[second]++;
									count[third]++;
									count[fourth]++;
									count[sixth]++;
									count[fifth]++;
									count[seventh]++;
									long tempans = sums[first];
									for(int i = 0; i < first; i++) {
										tempans = tempans * dp2[i][count[i]];
										tempans %= mod;
									}
									ans += tempans;
									if(ans >= mod) ans -= mod;
									count[second]--;
									count[third]--;
									count[fourth]--;
									count[sixth]--;
									count[fifth]--;
									count[seventh]--;
								}
							}
						}
					}
				}
			}
//			out.println(vals);
		}
		out.println(ans);
	}

	public static long[][][] dp;
	public static String M;

	public static long Recur(int pos, int count, int f) {
		if(pos == M.length()) {
			if(count == 0) {
				return 0;
			}
			if(count == dp[0].length - 1) {
				return 1;
			}else {
				return 0;
			}
		}
		if(dp[pos][count][f] != -1) {
			return dp[pos][count][f];
		}
		int lmtS = 0, lmtE;
		if(f == 1) {
			lmtE = M.charAt(pos) - '0';
		}else {
			lmtE = 9;
		}
		long ans = 0;
		for(int i = lmtS; i <= lmtE; i++) {
			int new_count = count + ((i == 4 || i == 7) ? 1 : 0);
			int newf = (f == 1 && i == lmtE ? 1 : 0);
			ans += Recur(pos + 1, new_count, newf);
		}
		return dp[pos][count][f] = ans;
	}

	public static void main(String[] args) {
		out = new PrintWriter(new BufferedOutputStream(System.out));
		s = new FastReader();
		solve();
		out.close();
	}

	public static class Triplet {
		long gcd;
		long x;
		long y;

		Triplet(long gcd, long x, long y) {
			this.gcd = gcd;
			this.x = x;
			this.y = y;
		}
	}

	public static Triplet ExtendedEuclideanAlgo(long a, long b) {
		if (a == 0) {
			return new Triplet(b, 0, 1);
		}
		Triplet ans = ExtendedEuclideanAlgo(b % a, a);
		long x = ans.y - (b / a) * ans.x;
		long y = ans.x;
		return new Triplet(ans.gcd, x, y);
	}

	public static long ModInverse(long a, long m) {
		Triplet ans = ExtendedEuclideanAlgo(a, m);
		if (ans.gcd != 1) {
			//System.out.println("Multiplicative inverse doesnot exist");
			return -1;
		} else {
			//m is added to handle negative x
			long result = (ans.x % m + m) % m;
			return result;
		}
	}

	public static FastReader s;
	public static PrintWriter out;

	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;

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

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

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

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

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

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

}


import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Set;
import java.util.SortedSet;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import javax.net.ssl.SSLContext;

public class Main
{
	/********************************************** a list of common variables **********************************************/
	private MyScanner scan = new MyScanner();
	private PrintWriter out = new PrintWriter(System.out);
	private final double PI = Math.acos(-1.0);
	private final double EPS = 1e-6;
	private final int SIZEN = (int)(1e5);
	private final int MOD = (int)(1e9 + 7);
	private final long MODH = 10000000007L, BASE = 10007;
	private final int[] DX = {0, 1, 0, -1}, DY = {-1, 0, 1, 0};
	private ArrayList<Integer>[] edge;
	private int bits;
	private long ans;
	private int[] d, lucky;
	private int[][] dp;

	public int getCount(int p, int x, boolean rightEqual)
	{
		if(-1 == p) return 0 == x ? 1 : 0;
		if(!rightEqual && dp[p][x] != -1) return dp[p][x];
		int n = rightEqual ? d[p] : 9;
		int sum = 0;
		for(int i = 0;i <= n;++i)
		{
			sum += getCount(p - 1, x - (4 == i|| 7 == i ? 1 : 0), rightEqual && (i == d[p]));
		}
		if(!rightEqual) dp[p][x] = sum;
		return sum;
	}

	public void dfs(int step, int sum, int cur, long tmp)
	{
		if(sum >= cur) return;
		if(step == 6)
		{
			ans = (ans + tmp) % MOD;
			return;
		}
		for(int i = 0;i < cur;++i)
		{
			if(lucky[i] > 0)
			{
				--lucky[i];
				dfs(step + 1, sum + i, cur, tmp * (lucky[i] + 1) % MOD);
				++lucky[i];
			}
		}
	}

	public void foo()
	{
		int n = scan.nextInt();
		d = new int[11];
		bits = 0;
		while(n > 0)
		{
			d[bits++] = n % 10;
			n /= 10;
		}
		lucky = new int[bits + 1];
		dp = new int[bits + 1][bits + 1];
		for(int i = 0;i <= bits;++i) Arrays.fill(dp[i], -1);
		for(int i = 0;i <= bits;++i)
		{
			lucky[i] = getCount(bits - 1, i, true);
		}
		--lucky[0];
		ans = 0;
		for(int i = 1;i <= bits;++i)
		{
			dfs(0, 0, i, lucky[i]);
		}
		out.println(ans);
  	}

	public static void main(String[] args)
	{
		Main m = new Main();
		m.foo();
		m.out.close();
	}

	class Point
	{
		private int x;
		private int y;
		public Point(int aX, int aY)
		{
			x = aX;
			y = aY;
		}
	}

	/********************************************** a list of common algorithms **********************************************/
	/**
	 * 1---Get greatest common divisor
	 * @param a :	first number
	 * @param b :	second number
	 * @return		greatest common divisor
	 */
	public long gcd(long a, long b)
	{
		return 0 == b ? a : gcd(b, a % b);
	}

	/**
	 * 2---Get the distance from a point to a line
	 * @param x1	the x coordinate of one endpoint of the line
	 * @param y1	the y coordinate of one endpoint of the line
	 * @param x2	the x coordinate of the other endpoint of the line
	 * @param y2	the y coordinate of the other endpoint of the line
	 * @param x		the x coordinate of the point
	 * @param y		the x coordinate of the point
	 * @return		the distance from a point to a line
	 */
	public double getDist(long x1, long y1, long x2, long y2, long x, long y)
	{
		long a = y2 - y1;
		long b = x1 - x2;
		long c = y1 * (x2 - x1) - x1 * (y2 - y1);
		return Math.abs(a * x + b * y + c) / Math.sqrt(a * a + b * b);
	}

	/**
	 * 3---Get the distance from one point to a segment (not a line)
	 * @param x1	the x coordinate of one endpoint of the segment
	 * @param y1	the y coordinate of one endpoint of the segment
	 * @param x2	the x coordinate of the other endpoint of the segment
	 * @param y2	the y coordinate of the other endpoint of the segment
	 * @param x		the x coordinate of the point
	 * @param y		the y coordinate of the point
	 * @return		the distance from one point to a segment (not a line)
	 */
	public double ptToSeg(long x1, long y1, long x2, long y2, long x, long y)
	{
		double cross = (x2 - x1) * (x - x1) + (y2 - y1) * (y - y1);
		if(cross <= 0)
		{
			return (x - x1) * (x - x1) + (y - y1) * (y - y1);
		}
		double d = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
		if(cross >= d)
		{
			return (x - x2) * (x - x2) + (y - y2) * (y - y2);
		}
		double r = cross / d;
		double px = x1 + (x2 - x1) * r;
		double py = y1 + (y2 - y1) * r;
		return (x - px) * (x - px) + (y - py) * (y - py);
	}

	/**
	 * 4---KMP match, i.e. kmpMatch("abcd", "bcd") = 1, kmpMatch("abcd", "bfcd") = -1.
	 * @param t:	String to match.
	 * @param p:	String to be matched.
	 * @return		if can match, first index; otherwise -1.
	 */
	public int kmpMatch(char[] t, char[] p)
	{
		int n = t.length;
		int m = p.length;
		int[] next = new int[m + 1];
		next[0] = -1;
		int j = -1;
		for(int i = 1;i < m;++i)
		{
			while(j >= 0 && p[i] != p[j + 1])
			{
				j = next[j];
			}
			if(p[i] == p[j + 1])
			{
				++j;
			}
			next[i] = j;
		}
		j = -1;
		for(int i = 0;i < n;++i)
		{
			while(j >= 0 && t[i] != p[j + 1])
			{
				j = next[j];
			}
			if(t[i] == p[j + 1])
			{
				++j;
			}
			if(j == m - 1)
			{
				return i - m + 1;
			}
		}
		return -1;
	}

	/**
	 * 5---Get the hash code of a String
	 * @param	s:	input string
	 * @return	hash code
	 */
	public long hash(String s)
	{
		long key = 0, t = 1;
		for(int i = 0;i < s.length();++i)
		{
			key = (key + s.charAt(i) * t) % MODH;
			t = t * BASE % MODH;
		}
		return key;
	}

	/**
	 * 6---Get x ^ n % MOD quickly.
	 * @param	x:	base
	 * @param 	n:	times
	 * @return	x ^ n % MOD
	 */
	public long quickMod(long x, long n)
	{
		long ans = 1;
		while(n > 0)
		{
			if(1 == n % 2)
			{
				ans = ans * x % MOD;
 			}
			x = x * x % MOD;
			n >>= 1;
		}
		return ans;
	}

	/**
	 * 7---judge if a point is located inside a polygon
	 * @param x0	the x coordinate of the point
	 * @param y0	the y coordinate of the point
	 * @return true if it is inside the polygon, otherwise false
	 */
	/*public boolean contains(double x0, double y0)
	{
		int cross = 0;
		for(int i = 0;i < n;++i)
		{
			double s = x[i + 1] == x[i] ? 100000000 : (double)(y[i + 1] - y[i]) / (x[i + 1] - x[i]);
			boolean b1 = x[i] <= x0 && x0 < x[i + 1];
			boolean b2 = x[i + 1] <= x0 && x0 < x[i];
			boolean b3 = y0 < s * (x0 - x[i]) + y[i];
			if((b1 || b2) && b3) ++cross;
		}
		return cross % 2 != 0;
	}*/

	/**
	 * 8---judge if a point is located on the segment
	 * @param	x1	the x coordinate of one point of the segment
	 * @param	y1	the y coordinate of one point of the segment
	 * @param 	x2	the x coordinate of another point of the segment
	 * @param 	y2	the y coordinate of another point of the segment
	 * @param	x	the x coordinate of the point
	 * @param 	y	the y coordinate of the point
	 * @return	true if it is located on the segment, otherwise false
	 */
	public boolean isOnSeg(long x1, long y1, long x2, long y2, long x, long y)
	{
		return (x - x1) * (y2 - y1) == (x2 - x1) * (y - y1) &&
				x >= Math.min(x1, x2) && x <= Math.max(x1, x2) &&
				y >= Math.min(y1, y2) && y <= Math.max(y1, y2);
	}

	/**
	 * 9---get the cross product
	 * @param 	p1	point A
	 * @param 	p2	point B
	 * @param 	p	point O
	 * @return	cross product of OA x OB
	 */
	public long cross(Point p1, Point p2, Point p)
	{
		return (long)(p1.x - p.x) * (p2.y - p.y) - (long)(p2.x - p.x) * (p1.y - p.y);
	}

	class MyScanner
	{
	    private byte[] buf = new byte[1024];
	    private int curChar;
	    private int numChars;
	    BufferedInputStream bis = new BufferedInputStream(System.in);

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

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

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

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

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

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


package com.cn;
import java.util.Scanner;
public class Test {

    static int MOD = 1000000007;
    static int N = 10;

    int digit[] = new int[11];
    int f[][][] = new int[11][11][2];
    int cnt[] = new int[11];
    long  ans;

    void sol(int m) {
        for (int i = 10; i -- > 0; m /= 10) digit[i] = m % 10;

        f[0][0][1] = 1;
        for (int i = 1; i < 10; i ++)
            for (int j = 0; j <= i; j ++)
                for (int d = 0; d < 10; d ++) {
                    f[i][j + (d == 4 || d == 7 ? 1 : 0)][0] += f[i - 1][j][0];
                    if (d == digit[i]) f[i][j + (d == 4 || d == 7 ? 1 : 0)][1] += f[i - 1][j][1];
                    if (d < digit[i]) f[i][j + (d == 4 || d == 7 ? 1 : 0)][0] += f[i - 1][j][1];
                }

        for (int i = 0; i < 10; i ++) cnt[i] = f[9][i][0] + f[9][i][1];
        cnt[0] --;

        //for (int i = 0; i < 10; i ++) System.out.println(cnt[i]);
        for (int i = 1; i < 10; i ++)
            if (cnt[i] > 0) {
                cnt[i] --;
                dfs(0, i, cnt[i] + 1);
                cnt[i] ++;
            }
        System.out.println(ans % MOD);
    }

    void dfs(int dep, int left, long res) {
        if (dep >= 6) {
            ans += res;
            return;
        }
        for (int i = 0; i < left; i ++)
            if (cnt[i] > 0) {
                cnt[i] --;
                dfs(dep + 1, left - i, res * (cnt[i] + 1) % MOD);
                cnt[i] ++;
            }
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNext()) new Test().sol(in.nextInt());
    }
}


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

public class Main {
    static final long MOD = 1000000007L;

    static int[][] dp = new int[10][9];

    static {
        dp[0][0] = 1;
        for (int i = 1; i < dp.length; i++) {
            dp[i][0] += 8 * dp[i - 1][0];
            for (int j = 1; j < 9; j++) {
                dp[i][j] += dp[i - 1][j - 1] * 2 + dp[i - 1][j] * 8;
            }
        }
    }

    static int[] toArray(int m) {
        int temp = m / 10;
        int c = 1;
        while (temp > 0) {
            temp /= 10;
            c++;
        }
        int[] res = new int[c];
        for (int i = 0; i < c; i++) {
            res[i] = m % 10;
            m /= 10;
        }
        return res;
    }

    static void increase(int index, int multi, int shift) {
        for (int i = 0; i + shift < 9; i++) {
            count[i + shift] += multi * dp[index][i];
        }
    }

    static long C(int up, int down) {
        if (up < down) {
            return 0;
        }
        long res = 1;
        int c2 = 0;
        int c3 = 0;
        int c5 = 0;
        for (int i = 2; i <= down; i++) {
            int temp = i;
            while (temp % 2 == 0) {
                c2++;
                temp /= 2;
            }

            while (temp % 3 == 0) {
                c3++;
                temp /= 3;
            }

            while (temp % 5 == 0) {
                c5++;
                temp /= 5;
            }
        }

        for (int i = up; i > up - down; i--) {
            int temp = i;
            while (temp % 2 == 0 && c2 > 0) {
                c2--;
                temp /= 2;
            }
            while (temp % 3 == 0 && c3 > 0) {
                c3--;
                temp /= 3;
            }
            while (temp % 5 == 0 && c5 > 0) {
                c5--;
                temp /= 5;
            }
            res *= temp;
            res %= MOD;
        }
        return res;
    }

    static void search(int index, int left) {
        if (index == 1 && left == 0) {
            int aa = 1;
        }
        if (count[index] == 0) {
            return;
        }
        if (left == 0) {
            int require = 0;
            for (int i = 0; i < 9; i++) {
                require += i * use[i];
            }
            require++;
            if (require < 9) {
                long base = 1;
                for (int i = 0; i < 9; i++) {
                    if (use[i] > 0) {
                        base *= C(count[i], use[i]);
                        base %= MOD;
                    }
                }
                base *= 720;
                base %= MOD;

                for (int i = require; i < 9; i++) {
                    if (count[i] == 0) {
                        break;
                    }
                    res += base * count[i];
                    res %= MOD;
                }
            }
            return;
        }
        if (index == 9) {
            return;
        }

        for (int i = 0; i <= left; i++) {
            use[index] = i;
            search(index + 1, left - i);
            use[index] = 0;
        }
    }

    static int[] count;
    static int[] use;
    static long res;
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int m = scan.nextInt();
        count = new int[9];

        int[] digits = toArray(m);
        int shift = 0;
        for (int i = digits.length - 1; i >= 0; i--) {
            if (digits[i] <= 4) {
                increase(i, digits[i], 0 + shift);
            }
            else if (digits[i] <= 7) {
                increase(i, digits[i] - 1, 0 + shift);
                increase(i, 1, 1 + shift);
            }
            else {
                increase(i, digits[i] - 2, 0 + shift);
                increase(i, 2, 1 + shift);
            }
            if (digits[i] == 4 || digits[i] == 7) {
                shift++;
            }
        }
        count[shift]++;
        count[0]--;
        /*
        int[] check = new int[9];
        for (int i = 1; i <= m; i++) {
            int c = 0;
            int temp = i;
            while (temp > 0) {
                if (temp % 10 == 4 || temp % 10 == 7) {
                    c++;
                }
                temp /= 10;
            }
            check[c]++;
        }
        System.out.println(Arrays.toString(check));
        System.out.println(Arrays.toString(count));
        System.out.println(Arrays.equals(check, count));*/
        res = 0;
        use = new int[9];
        search(0, 6);
        System.out.println(res);
    }
}


package div2.round421;

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

/**
 * Created by Viki on 6/27/2017.
 */
public class A {

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

        int day = 0;
        int currentPage = 0;

        while (currentPage < allPages) {
            if (day > 0) {
                currentPage -= lastDayPages;
            }
            currentPage += Math.min(firstDayPages + day * dayAddPages, maxDayPages);
            day++;
        }

        System.out.println(day);
    }
}


/*
 * 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 seifnew;

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

/**
 *
 * @author seif
 */
public class Seifnew {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws FileNotFoundException {
    File f=new File("seifnew.txt");
    Scanner sc=new Scanner(f);
    int c=sc.nextInt();
    int v0=sc.nextInt();
    int v1=sc.nextInt();
    int a=sc.nextInt();
    int l=sc.nextInt();

    int days=0;
    do{
    days++;
    c=c-v0;
    v0=v0+a;
    if (v0>=v1){
        v0=v1;}
    if (c > 0){
       c=c+l;
    }
    }while (c>0);
        System.out.print(days);

    }

}


package codeforces;

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

/**
 * Built using CHelper plug-in Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		int c, v0, v1, a, l;
		c = in.nextInt();
		v0 = in.nextInt();
		v1 = in.nextInt();
		a = in.nextInt();
		l = in.nextInt();
		int read = v0;
		int speed = v0;
		int count = 1;
		while (read < c) {
			count++;
			if (speed + a <= v1) {
				speed += a;
			}
			read += speed - l;
		}
		out.print(count);
	}

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

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

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

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

	}
}


/*
 * 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.
 */

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

/**
 *
 * @author seif
 */
public class Seifnew {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws FileNotFoundException {
    File f=new File("seifnew.txt");
    Scanner sc=new Scanner(f);
    int c=sc.nextInt();
    int v0=sc.nextInt();
    int v1=sc.nextInt();
    int a=sc.nextInt();
    int l=sc.nextInt();

    int days=0;
    do{
    days++;
    c=c-v0;
    v0=v0+a;
    if (v0>=v1){
        v0=v1;}
    if (c > 0){
       c=c+l;
    }
    }while (c>0);
        System.out.print(days);

    }

}


package codeforces272;

import java.util.Scanner;

public class DreamoonSums {
    public static final long MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextInt();
        long b = sc.nextInt();
        long sum = 0;
        long tmp = (1L * a * b + b + 2) % MOD;
        tmp = (tmp * a / 2) % MOD;

        System.out.println("tmp=" + tmp);
        for (long r = 1; r <= b - 1; r++) {
            // ar(ab+b+2)/2
            sum += r * tmp;
            sum %= MOD;
        }
        System.out.println(sum);
    }
}


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

public class Main {

    public static void main(String[] args) {
        InputStream inputstream = System.in;
        OutputStream outputstream = System.out;
        InputReader in = new InputReader(inputstream);
        PrintWriter out = new PrintWriter(outputstream);
      //  int T;
        //   T = Integer.parseInt(in.readString());
        //     for (int i = 1; i <= T; i++) {
        Task solver = new Task();
        solver.solve(1, in, out);
        //    }
        out.close();
    }
}

class Task {

    final int MOD = 1_000_000_007;

    public void solve(int testno, InputReader in, PrintWriter out) {
        int a = in.readInt();
        int b = in.readInt();

        int ans = (((((2*a + (((((((long)a) % MOD) * b)) % MOD) * (a + 1)) % MOD) % MOD) *(long) b) % MOD) * ((b - 1))) % MOD;
        out.println(ans/4);

    }

}

class InputReader {

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

    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 String readString() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

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

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

    public float readFloat() {
        return Float.parseFloat(readString());
    }

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


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

public class A {

	static final int MOD = 1000000007;

	static void solve() throws IOException {
		int a = nextInt();
		int b = nextInt();
		int sumMod = (int) ((long) b * (b - 1) / 2);
		int sumA = (int) ((long) a * (a + 1) / 2);
		int ans = (int) ((long) sumMod * a % MOD);
		ans = (int) ((ans + (long) sumA * sumMod % MOD * b) % MOD);
		out.println(ans);
	}

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

	public static void main(String[] args) throws IOException {
		InputStream input = System.in;
		PrintStream output = System.out;
		File file = new File("a.in");
		if (file.exists() && file.canRead()) {
			input = new FileInputStream(file);
			output = new PrintStream("a.out");
		}
		br = new BufferedReader(new InputStreamReader(input));
		out = new PrintWriter(output);
		solve();
		out.close();
		br.close();
	}

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

	static String next() throws IOException {
		return hasNext() ? st.nextToken() : null;
	}

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

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

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


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

public class Main {

	public static class pair implements Comparable<pair>
	{
		int a;
		int b;
		public pair(int pa, int pb)
		{
			a = pa; b= pb;
		}
		@Override
		public int compareTo(pair o) {
			if(this.a < o.a)
				return -1;
			if(this.a > o.a)
				return 1;
			return Integer.compare(o.b, this.b);
		}
	}

	//int n = Integer.parseInt(in.readLine());
	//int n = Integer.parseInt(spl[0]);
	//String[] spl = in.readLine().split(" ");

	public static void main (String[] args) throws Exception
	{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] spl = in.readLine().split(" ");
		int a = Integer.parseInt(spl[0]);
		int b  = Integer.parseInt(spl[1]);
		long mod = 1000000007;
		long pp = (b*(b-1))/2;
		long ans = 0;
		pp%=mod;
		for (int k = 1; k <= a; k++) {
			long cur = k*b+1;
			cur%=mod;
			ans+=pp*cur;
			ans%=mod;
		}
		System.out.println(ans);
	}

}


import java.util.*;
public class JavaApplication73 {

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

        int n=Sc.nextInt();
        int m=Sc.nextInt();
        long k=Sc.nextInt();
        long x=1,y=1;
        int t=0;

        if(k<=n-1)
        {
            System.out.println((x+k)+" "+1);
            System.exit(0);
        }
        x=n;
        y=1;
       // c+=n-1;
        k-=n-1;
        if(k<=m-1)
        {
           y=y+k;
           System.out.println(x+" "+y);
           System.exit(0);
        }
        k-=m-1;
        y=y+m-1;
        //System.out.println("*"+x+" "+y);
        t=0;
        while(k>m-1)
        {
            if(t==0)
            {
                //System.out.println("dvnmdsv");
                x-=1;
                y-=m-2;
                t=1;
               // System.out.println("??"+x+" "+y+" "+t);
            }
            else
            {
                x-=1;
                y+=m-2;
                t=0;
                //System.out.println("@@"+x+" "+y+" "+t);
            }
           //4 System.out.println("#"+x+" "+y+" "+t);
            k-=m-1;
        }

        if(k==0)
        {
           System.out.println(x+" "+y);
           System.exit(0);
        }

       //System.out.println(x+" "+y);
        if(t==0)
        {
          x-=1;
          k--;
          while(k!=0)
          {
              y--;
              k--;
          }

        }
        else
        {
            x-=1;
            k--;
          while(k!=0)
          {
              y++;
              k--;
          }

        }

        System.out.println(x+" "+y);
    }

}


import java.util.Scanner ;
public class lara
{
    public static void main (String [] args)
    {
        Scanner sc = new Scanner(System.in) ;
        int [] k = new int [3] ;
        for (int i = 0 ; i < 3 ; i++)
        {
            k[i] = sc.nextInt() ;
        }
        int o = 1 ;
        int p = 1 ;
        int J = 0 ;
        while(J < k[2] && J < (k[0] + (k[1] - 1)))
        {
            if(o < k[0])
            {
                o++ ;
                J++ ;
            }
            else if(o == k[0] && p < k[1])
            {
                p++ ;
                J++ ;
            }
            else if(o == k[0] && p == k[1])
            {
                o-- ;
                J++ ;
            }
        }
        while(J < k[2])
        {
            if(o%2 != 0)
            {
                if(p == 2)
                {
                    o-- ;
                    J++ ;
                }
                else
                {
                p-- ;
                J++ ;
                }
            }
            else if(o%2 == 0)
            {
                if(p == k[1])
                {
                    o-- ;
                    J++ ;
                }
                else
                {
                p++ ;
                J++ ;
                }
            }
        }
        System.out.println(o + " " + p) ;
        sc.close() ;
    }
}


import java.io.*;
import java.util.*;
/*
 * 	Heart beats fast
 * 		Colors and promises
 * 			How to be brave
 * 				How can I love when I am afraid to fall...
 */
public class Main
{
	public static void main(String[] args)
	{
		long n=ni(),m=ni();
		long k=nl();
		if(k<n)
		{
			pr((k+1)+" "+1);
		}
		else if(k<n+m-1)
		{
			pr(n+" "+(k-n+2));
		}
		else if(k==n+m-1)
		{
			pr((n-1)+" "+m);
		}
		else
		{
			long te=k-n-m+1;
			n--;
			m--;
			pr((n-te/m)+" "+(m+1-te%m));
		}
		System.out.print(output);
	}

	///////////////////////////////////////////
	///////////////////////////////////////////
	///template from here
	static final long mod=1000000007;
	static final double eps=1e-8;
	static final long inf=100000000000000000L;
	static Reader in=new Reader();
	static StringBuilder output=new StringBuilder();
	static Random rn=new Random();
	//output functions////////////////
	static void pr(Object a){output.append(a+"\n");}
	static void pr(){output.append("\n");}
	static void p(Object a){output.append(a);}
	static void pra(int[]a){for(int i:a)output.append(i+" ");output.append("\n");}
	static void pra(long[]a){for(long i:a)output.append(i+" ");output.append("\n");}
	static void pra(String[]a){for(String i:a)output.append(i+" ");output.append("\n");}
	static void pra(double[]a){for(double i:a)output.append(i+" ");output.append("\n");}
	static void sop(Object a){System.out.println(a);}
	static void flush(){System.out.println(output);output=new StringBuilder();}
	//////////////////////////////////
	//input functions/////////////////
	static int ni(){return in.nextInt();}
	static long nl(){return Long.parseLong(in.next());}
	static String ns(){return in.next();}
	static double nd(){return Double.parseDouble(in.next());}
	static int[] nia(int n){int a[]=new int[n];for(int i=0; i<n; i++)a[i]=ni();return a;}
	static int[] pnia(int n){int a[]=new int[n+1];for(int i=1; i<=n; i++)a[i]=ni();return a;}
	static long[] nla(int n){long a[]=new long[n];for(int i=0; i<n; i++)a[i]=nl();return a;}
	static String[] nsa(int n){String a[]=new String[n];for(int i=0; i<n; i++)a[i]=ns();return a;}
	static double[] nda(int n){double a[]=new double[n];for(int i=0; i<n; i++)a[i]=nd();return a;}
	//////////////////////////////////
	//some utility functions
	static void psort(Integer[][] a)
	{
		Arrays.sort(a, new Comparator<Integer[]>()
		{
			@Override
			public int compare(Integer[]a,Integer[]b)
			{
				if(a[0]>b[0])
					return 1;
				else if(b[0]>a[1])
					return -1;
				return 0;
			}
		});
	}
	static String pr(String a, long b)
	{
		String c="";
		while(b>0)
		{
			if(b%2==1)
				c=c.concat(a);
			a=a.concat(a);
			b>>=1;
		}
		return c;
	}
	static long powm(long a, long b, long m)
	{
		long an=1;
		long c=a;
		while(b>0)
		{
			if(b%2==1)
				an=(an*c)%m;
			c=(c*c)%m;
			b>>=1;
		}
		return an;
	}
	static int gcd(int a, int b)
	{
		if(b==0)
			return a;
		else
			return gcd(b, a%b);
	}
	/////////////////////////
	static class Reader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public Reader() {
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
        	return Long.parseLong(next());
        }
        public double nextDouble() {
        	return Double.parseDouble(next());
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.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
 *
 * @author mostafa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ProblemBLaraCroftAndTheNewGame solver = new ProblemBLaraCroftAndTheNewGame();
        solver.solve(1, in, out);
        out.close();
    }

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

            long X = 1, Y = 1;
            if (k < n) {
                Y += k;
            } else if (k <= (n + m - 2)) {
                Y = n;
                k -= (n - 1);
                X += k;
            } else {
                k -= (n + m - 2);
                long peroid = 2 + 2 * (m - 2);

                long numOfPeriod = k / peroid;

                long steps = k % peroid;

                Y = n - 2 * numOfPeriod;
                X = m;

                if (steps == 1) {
                    Y--;
                } else if (steps > 1 && steps < m) {
                    Y--;
                    steps--;
                    X -= steps;
                } else if (steps == m) {
                    Y--;
                    X -= (m - 2);
                    Y--;
                } else {
                    Y -= 1;
                    X -= (m - 2);
                    Y -= 1;
                    steps -= 2 * Y;
                    steps -= (m - 2);
                    X += (steps);
                }
            }
            out.print(Y + " " + X);
        }

    }

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

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

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

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

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

    }
}


/*
 * 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 javaapplication2;

import java.util.Scanner;

/**
 *
 * @author Admi
 */
public class JavaApplication2 {

    /**
     * @param args the command line arguments
     */
     public static void main(String[] args) {
        int k,l,s,i,m;
        s=(int) (Math.pow(2, 31)-1);

        Scanner reader=new Scanner(System.in);

        do{
           k=reader.nextInt();
           l=reader.nextInt();
        }while(k<2&&l>s);
        i=1;
        do{
          m=(int) (Math.pow(k, i));
          if(m==l) {i--;System.out.println("YES");System.out.print(i);}
          if(m>l){System.out.print("NO");}
          i++;
        }while(m<l);

    }
}


import java.util.*;
 public class Main{
     public static void main(String[]args){
         Scanner in = new Scanner(System.in);
         int n = in.nextInt();
         int m = in.nextInt();
         int a[] = new int[100];
         for(int i=1;i<200;i++){
             a[i] = (int)Math.pow(n,i);
         }

             if(bin(a, m, 0, 99)>0){
                 if(a[bin(a, m, 0, 99)] == m){
                     System.out.println("YES");
                     System.out.println(bin(a, m, 0,99)-1);
                 }
             }else{
                 System.out.println("NO");
             }

     }
     public static int bin(int a[],int key,int left,int right){
         if(left > right){
             return -1;
         }else{
             int mid = (left+right)/2;
             if(a[mid] == key){
                 return mid;
             }
             if(a[mid] > key){
                 return bin(a, key, left, mid-1);
             }else{
                 return  bin(a, key, mid+1, right);
             }
         }
     }
 }


import java.util.Scanner;

public class Solution {

	public static final Scanner input = new Scanner(System.in);

	public static void main(String[] args) {
		final int n = input.nextInt();
		final int[] soldiers = new int[n];

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

		int minIndex = 0;
		int maxIndex = n - 1;

		for (int i = 1, j = n - 2; i < n; i++, j--) {
			if (soldiers[i] <= soldiers[minIndex]) {
				minIndex = i;
			}

			if (soldiers[j] >= soldiers[maxIndex]) {
				maxIndex = j;
			}
		}

        int result = 0;
        if (soldiers[maxIndex] != soldiers[0]) {
            result += maxIndex;
        }

        if (soldiers[minIndex] != soldiers[n - 1]) {
            result += n - 1 - minIndex;
        }

        if (minIndex < maxIndex) {
            result--;
        }

        System.out.print(result);
	}
}


package tasks;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long k = in.nextLong();
        long l = in.nextLong();
        long potential = 1;
        long i;

        for (i = 0; ; i++) {
            potential *= k;
            if(potential >= l)
                break;
        }
        if(potential == l){
            System.out.println("YES \n" + i);
        } else {
            System.out.println("NO");
        }
//        dsf
//        System.out.println(potential + " " + i);
    }
}


import java.util.*;
public class Code {
    public  static  void main(String... arg){
        Scanner sc = new Scanner(System.in);
        int  n , k;
        n = sc.nextInt();
        k = sc.nextInt();
        int ans =0;
        for(int i=1; i<= n;i++) {
            String s = String.valueOf(i);
            String s1 = new StringBuffer(s).reverse().toString();
            s = s + s1;
            //System.out.println(s);
            int y = Integer.parseInt(s);
            ans = (ans + y)%k;

        }
        System.out.println(ans);
    }
}


import java.util.Scanner;

public class chthollysRequest {

	public static long calcSum(long k)
	{
		long num=1;
		long sum=0;
		String zcy="";

		while(num<=k)
		{
			StringBuilder rev=new StringBuilder();
			zcy=""+num;
			rev.append(zcy);
			rev=rev.reverse();
			zcy=num+""+rev;
			sum=sum+(Integer.parseInt(zcy));
			//System.out.println(zcy);
			num++;
		}

		return sum;
	}

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

		Scanner s=new Scanner(System.in);
		long k=s.nextInt();
		long p=s.nextInt();

		long sumans=calcSum(k);
		//System.out.println(sumans);
		System.out.println(sumans%p);

	}

}


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

public class Solution {
	public static void main (String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt(), p = scanner.nextInt(), result = 0, cur = 0;
		for (int i = 0, j = 1; i < n; i++) {
		    String st = "";
		    st += String.valueOf(j);
		    StringBuilder stb = new StringBuilder();
		    stb.append(st);
		    stb.reverse();
		    st += stb;
		    cur = Integer.parseInt(st);
		    cur %= p;
		    result += cur;
		    result %= p;
		    j++;
		}
		System.out.printf("%d", result);
	}
}


import java.util.*;

public class A887 {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String zcy = "123456789";
        int k = in.nextInt();
        int p = in.nextInt();
        int sum = 0;

        for(int i = 0;i<k;i++){
            sum += Integer.parseInt(zcy.substring(i,i+1)+zcy.substring(i,i+1));
        }

        sum = sum % p;

        System.out.print(sum);

    }
}


import java.util.*;

public class Solution {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        String out = "";
        char[] s = in.next().toCharArray();
        int[] a = new int[26];
        Arrays.sort(s);

        for (int i = 0; i < n; i++)
            a[s[i] - 'a']++;
            out = "YES";
        for (int i = 0; i < 26; i++)
            if (a[i] > k)
                out = "NO";

        System.out.println(out);
    }
}


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

public class Godsend {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader ( new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		String linea = in.readLine();
		StringTokenizer toks = new StringTokenizer(linea);
		int n=Integer.parseInt(toks.nextToken());
		int k=Integer.parseInt(toks.nextToken());
		 linea=in.readLine();
		HashMap<Character,Integer>globos= new HashMap<Character,Integer>();
		for (int i = 0; i < linea.length(); i++) {
			if(globos.containsKey(linea.charAt(i))){
				globos.put(linea.charAt(i), globos.get(linea.charAt(i))+1);
			}else{
				globos.put(linea.charAt(i), 1);
			}
		}
		Set<Character>llaves=globos.keySet();
		boolean puede=true;
		for (Character l : llaves) {
			int la=globos.get(l);
			if(la%k!=0&&la>k){
				puede=false;
				break;
			}
		}
		out.println(puede?"YES":"NO");
		out.close();
	}
}


import java.util.Scanner;

public class blah {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();scan.nextLine();
		String s = scan.next();
		int count=0;
		for (int y=0; y<s.length();y++){

			for(int i=0;i<s.length()-1;i++){
				char c = s.charAt(y);
				if (s.charAt(i) == s.charAt(i+1)){
					count++;
				}
				i++;
			}

			y++;
		}
		if(n<=k){
			System.out.println("YES");
		}
		else if (count%2 == 0) {
			System.out.println("YES");
		}

		else{
			System.out.println("NO");
		}

	}

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
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
 *
 * @author a1M
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            boolean result = true;
            int k = in.nextInt();
            String s = in.next();
            char[] a = s.toCharArray();

            if (n != 0) {
                Arrays.sort(a);
                char inicio = a[0];
                int count = 1;
                for (int i = 1; i < a.length; i++) {
                    if (a[i] == inicio) {
                        count++;
                        inicio = a[i];
                    } else {
                        if (count > k) {
                            result = false;
                            break;
                        }
                        count = 1;
                        inicio = a[i];
                    }
                }

                if (result)
                    out.print("YES");
                else
                    out.print("NO");
            } else
                out.print("YES");

        }

    }

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

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

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

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

    }
}


package div2.r253.taskB;

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

public class Main {
        public static void main(String[] args) {
            BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
            String s;
            int i;

            try {
                s = r.readLine();
                i = Integer.parseInt(r.readLine());
            }
            catch (IOException e) {
                System.out.println("couldn't read. " + e);
                return;
            }

            if (i>=s.length()) {
                System.out.println(((i+s.length())/2)*2);
                return;
            }

            int max = 0;
            for (int j = 0; j <= s.length()-i; j++) {
                //System.out.println("etap1 " + s + s.substring(j, j + i));
                int m = maxTandemLength(s + s.substring(j, j + i));
                if (m>max) max = m;
            }
            System.out.println(max);
            // write your code here
        }

    private static int maxTandemLength(String str) {
        if (str.length() <= 1) return 0;
        for (int candidateLength = (str.length() / 2) * 2; candidateLength>0; candidateLength-=2) {
            //System.out.println("etap2 " + candidateLength);
            for (int i = 0; i <= str.length() - candidateLength; i++) {
                String tandemCandidate = str.substring(i, i + candidateLength);
                //System.out.println("etap3 " + tandemCandidate);
                if (isTandem(tandemCandidate)) return candidateLength;
            }
        }
        return 1;
    }

    private static boolean isTandem(String tandemCandidate) {
        int half = tandemCandidate.length()/2;
        return tandemCandidate.substring(0, half).equals(tandemCandidate.substring(half));
    }

}


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

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();  // number of sellers
    int v = sc.nextInt();  // amount of money Valera has
    List<Integer> goodVendors = new ArrayList<Integer>(n);

    for (int i = 1; i <= n; ++i) {
      int numItemsSold = sc.nextInt();
      boolean isGoodVendor = false;
      for (int j = 0; j < numItemsSold; ++j) {
        if (sc.nextInt() < v && !isGoodVendor) {
          isGoodVendor = true;
          goodVendors.add(i);
        }
      }
    }

    System.out.println(goodVendors.size());
    for (int i = 0; i < goodVendors.size() - 1; ++i) {
      System.out.print(goodVendors.get(i) + " ");
    }
    if (goodVendors.size() != 0) {
      System.out.println(goodVendors.get(goodVendors.size() - 1));
    }
  }
}


import java.util.HashSet;
import java.util.Scanner;

public class B {

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

		char[] ch = str.toCharArray();
		int len = str.length() + k;
		int l = 0;

		HashSet<Character> chr = new HashSet<>();
		for (int i = 0; i < ch.length; i++) {
			chr.add(ch[i]);
		}

		if(chr.size()==ch.length && k<=ch.length) {
//			System.out.println("sds"+chr.size());
			l = k*2;
		}
		if(chr.size()==ch.length && k>ch.length) {
			l = ch.length*2;
		}

		for (int i = 0; i < len/2; i++) {
			int d = i;
			while(str.indexOf(ch[i], d+1)!=-1) {

				int t = str.indexOf(ch[i], d+1);
				d = t+1;
				if(t + t-i <= len) {
//					System.out.println("i: "+i+" t: "+t );
					boolean r = true;
					for (int j = i; j < t && r == true && t+j < str.length(); j++) {
						if(ch[j]!=ch[j+t-i])
							r = false;
					}
					if(r == true && l<(t-i)*2) {
						l = (t-i)*2;
					}
				}

			}
		}
		System.out.println(l);
	}

}


import java.util.*;
public class B {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int k = sc.nextInt();

        for(int i=0; i<s.length(); ++i) {
            String tmp = s.substring(i);
            int n = tmp.length() + k;
            if(n%2==1) continue;
            int cnt = n/2;
            String s1 = s.substring(i, i+cnt);
            String s2 = s.substring(i+cnt);
            if(s1.startsWith(s2)) {
                System.out.println(cnt*2);
                return;
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class OldC {

	public static void solve(FastScanner fs) {
		BigInteger numCandies=new BigInteger(""+fs.nextLong());
		BigInteger numPeople=new BigInteger(""+fs.nextLong());
		BigInteger maxCandiesPerSwipe=new BigInteger(""+fs.nextLong());
		BigInteger maxCandieTakes=new BigInteger(""+fs.nextInt());
		BigInteger best=maxCandiesPerSwipe;

		for (BigInteger candyTakes=new BigInteger("2"); candyTakes.compareTo(maxCandieTakes)<=0;
				candyTakes=candyTakes.add(BigInteger.ONE)) {
			BigInteger first=maxCandiesPerSwipe;
			BigInteger second=numCandies.divide(candyTakes.multiply(numPeople).subtract(numPeople).add(BigInteger.ONE));
			BigInteger min=first.compareTo(second)<0?first:second;
			if (best.compareTo(candyTakes.multiply(min))<0)
				best=candyTakes.multiply(min);
		}
		System.out.println(best);

	}

	public static void main(String[] args) throws NumberFormatException, IOException {
		FastScanner scanner = new FastScanner(System.in);
		solve(scanner);
	}

	private static class FastScanner {
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(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;
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++)
				a[i]=nextInt();
			return a;
		}
		long[] readLongArray(int n) {
			long[] a=new long[n];
			for (int i=0; i<n; i++)
				a[i]=nextLong();
			return a;
		}
	}
}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	static PrintWriter pr = new PrintWriter(System.out);

	public static void main(String args[]) throws IOException{
		//FileReader in = new FileReader("C:/test.txt");
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		Scanner sc = new Scanner(System.in);

		long n = sc.nextLong();
		long k = sc.nextLong();
		long M = sc.nextLong();
		long D = sc.nextLong();
		long ans=0;
		for(long d=1; d<=D ; d++){
			long maxx = n/((d-1)*k+1);
			if(maxx==0)
				break;
			maxx = Math.min(M, maxx);

			ans = Math.max(ans, maxx*d);
		}
		pr.println(ans);
		pr.close();

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

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

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

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

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

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

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

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

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

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

		public int[] nextIntArray1(int n) throws IOException {
			int[] a = new int[n + 1];
			for (int i = 1; i <= n; i++)
				a[i] = nextInt();
			return a;
		}

		public int[] shuffle(int[] a, int n) {
			int[] b = new int[n];
			for (int i = 0; i < n; i++)
				b[i] = a[i];
			Random r = new Random();
			for (int i = 0; i < n; i++) {
				int j = i + r.nextInt(n - i);
				int t = b[i];
				b[i] = b[j];
				b[j] = t;
			}
			return b;
		}

		public int[] nextIntArraySorted(int n) throws IOException {
			int[] a = nextIntArray(n);
			a = shuffle(a, n);
			Arrays.sort(a);
			return a;
		}

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

		public long[] nextLongArray1(int n) throws IOException {
			long[] a = new long[n + 1];
			for (int i = 1; i <= n; i++)
				a[i] = nextLong();
			return a;
		}

		public long[] nextLongArraySorted(int n) throws IOException {
			long[] a = nextLongArray(n);
			Random r = new Random();
			for (int i = 0; i < n; i++) {
				int j = i + r.nextInt(n - i);
				long t = a[i];
				a[i] = a[j];
				a[j] = t;
			}
			Arrays.sort(a);
			return a;
		}
	}

	//
}


import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.math.BigInteger;
import java.util.*;

public class C3 {

	public static void main(String[] args) {
		JS in = new JS();
		BI N = new BI(in.nextLong());
		BI K = new BI(in.nextLong());
		BI M = new BI(in.nextLong());
		BI D = new BI(in.nextLong());

		BI giv = (K.mult(D)).add(1);
		BI lo = N.div(giv);
		if(N.mod(giv).equals(0)) lo.addI(1);
		BI minGive = N.div(M);
		if(N.mod(M).equals(0)) minGive.addI(1);

		BI minCyc = minGive.div(K);
		if(!minGive.mod(K).equals(0)) minCyc .addI(1);

		BI best = new BI(0);
		if(minCyc.compareTo(D) > 0) minCyc = D.add(0);
		//System.out.println(minCyc+" "+D+"   lo: "+lo);

		for(BI cycs = minCyc.sub(1); cycs.compareTo(D) <= 0; cycs.addI(1)) {
			BI nums = K.mult(cycs.sub(1));
			nums.addI(1);
			//System.out.println("Nums: "+nums);

			BI give = N.div(nums);
			if(give.compareTo(lo) < 0) continue;
			if(give.compareTo(M) > 0) give = M.add(0);
			BI rr = give.mult(cycs);
			if(best.compareTo(rr) < 0) best = rr;
		}
		System.out.println(best);
	}

	static class BI{
		BigInteger val;
		BigInteger zero = BigInteger.ZERO;
		BigInteger one = BigInteger.ONE;
		//CONSTRUCTORS
		public BI(BigInteger v) {
			val = v;
		}
		public BI(long v) {
			val = BigInteger.valueOf(v);
		}

		//ADDITION
		public BI add(long v) {
			if(v==0) return new BI(val);
			if(v==1) return new BI(val.add(one));
			return new BI(val.add(BigInteger.valueOf(v)));
		}
		public BI add(BI v) {
			return new BI(val.add(v.val));
		}
		public void addI(long v) {
			if(v==0);
			else if(v==1) val=val.add(one);
			else val = val.add(BigInteger.valueOf(v));
		}
		public void addI(BI v) {
			val = val.add(v.val);
		}
		//SUBTRACTION
		public BI sub(long v) {
			if(v==0) return new BI(val);
			if(v==1) return new BI(val.subtract(one));
			return new BI(val.subtract(BigInteger.valueOf(v)));
		}
		public BI sub(BI v) {
			return new BI(val.subtract(v.val));
		}
		public void subI(long v) {
			if(v==0);
			else if(v==1) val=val.subtract(one);
			else val = val.subtract(BigInteger.valueOf(v));
		}
		public void subI(BI v) {
			val = val.subtract(v.val);
		}
		//MULTIPLICATION
		public BI mult(long v) {
			if(v==0) return new BI(zero);
			if(v==1) return new BI(val);
			return new BI(val.multiply(BigInteger.valueOf(v)));
		}
		public BI mult(BI v) {
			return new BI(val.multiply(v.val));
		}
		public void multI(long v) {
			if(v==0) val = zero;
			else if(v==1);
			else val = val.multiply(BigInteger.valueOf(v));
		}
		public void multI(BI v) {
			val = val.multiply(v.val);
		}
		//DIVISION
		public BI div(long v) {
			if(v==1) return new BI(val);
			return new BI(val.divide(BigInteger.valueOf(v)));
		}
		public BI div(BI v) {
			return new BI(val.divide(v.val));
		}
		public void divI(long v) {
			if(v!=1)val = val.divide(BigInteger.valueOf(v));
		}
		public void divI(BI v) {
			val = val.divide(v.val);
		}
		//MOD
		public BI mod(long v) {
			return new BI(val.mod(BigInteger.valueOf(v)));
		}
		public BI mod(BI v) {
			return new BI(val.mod(v.val));
		}
		public void modI(long v) {
			val = val.mod(BigInteger.valueOf(v));
		}
		public void modI(BI v) {
			val = val.mod(v.val);
		}
		//COMPARE
		public int compareTo(long v) {
			return val.compareTo(BigInteger.valueOf(v));
		}
		public int compareTo(BI v) {
			return val.compareTo(v.val);
		}
		public boolean equals(long v) {
			return val.equals(BigInteger.valueOf(v));
		}
		public boolean equals(BI v) {
			return val.equals(v.val);
		}
		@Override
		public String toString() {
			return val.toString();
		}
	}

	static class JS{
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public JS() {
			in = new BufferedInputStream(System.in, BS);
		}

		public JS(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
	}

}


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

public class C {

	public static void solve(FastScanner fs) {
		long numCandies=fs.nextLong();
		long numPeople=fs.nextLong();
		long maxCandiesPerSwipe=fs.nextLong();
		long maxCandieTakes=fs.nextInt();
		long best=maxCandiesPerSwipe;

		for (int candyTakes=2; candyTakes<=maxCandieTakes; candyTakes++) {
			best=Math.max(best, candyTakes*(Math.min(maxCandiesPerSwipe, numCandies/(candyTakes*numPeople-numPeople+1))));
		}
		System.out.println(best);

	}

	public static void main(String[] args) throws NumberFormatException, IOException {
		FastScanner scanner = new FastScanner(System.in);
		solve(scanner);
	}

	private static class FastScanner {
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(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;
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++)
				a[i]=nextInt();
			return a;
		}
		long[] readLongArray(int n) {
			long[] a=new long[n];
			for (int i=0; i<n; i++)
				a[i]=nextLong();
			return a;
		}
	}
}


import java.util.Scanner;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

public class Main {

    public static void main(String[] args)
    {

        Scanner input = new Scanner(System.in);
        Set<Integer> set = new HashSet<Integer>();
        int N ;
        N= input.nextInt();
        int[]a=new int [N];
        for(int i=0;i<N;i++){
          a[i]= input.nextInt();
          if(a[i]>0){
            set.add(a[i]);
          }
        }
        int count=0;
        for(Integer c:set){
            count++;
        }
        System.out.println(count);

    }
}


//package main_package;
import java.util.*;

public class diploma {

	public static void main(String[] args) {

		Scanner scan =  new Scanner(System.in);
		int N  = scan.nextInt();

		HashMap<Integer, Boolean> answer = new HashMap<>();

		for(int i=0; i<N; i++) {
			int curr = scan.nextInt();
			if(!answer.containsKey(curr) && curr > 0) {
				answer.put(curr, true);
			}
		}

		System.out.println(answer.size());

	}

}


import java.util.Scanner;

public class Olympiad{

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

        int[] scores = new int[601];

        for (int i = 0; i < n; i++) {
            int m = sc.nextInt();
            if (m != 0) {
                scores[m] = 1;
            }
        }

        int sum = 0;
        for (int i = 0; i < 601; i++) {
            sum += scores[i];
        }

        System.out.println(sum);

    }
}


import java.util.*;

public class Main {

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

    public static void main(String[] args) {
        Task solver = new Task();
        solver.olympiad(scan.nextInt());
    }

    static class Task {
        public void olympiad(int n) {
            int in;
            HashSet<Integer> hashSet = new HashSet<>(600);
            int size=0, j=0;
            int [] ar = new int[n];
            for(int i = 0; i < n; i++) {
                in = scan.nextInt();
                if(in != 0) hashSet.add(in);
                if(size+1 == hashSet.size()){
                    ar[j++] = in;
                    size = hashSet.size();
                }
            }
            System.out.printf("%d", hashSet.size());
        }
    }
}


import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import static java.lang.Math.*;

public class Solution55A {

        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()){
                        tok = new StringTokenizer(in.readLine());
                }
                return tok.nextToken();
        }

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

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

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

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

        public void run(){
                try{
                        long t1 = System.currentTimeMillis();
                        init();
                        solve();
                        out.close();
                        long t2 = System.currentTimeMillis();
                        System.err.println("Time = "+(t2-t1));
                }catch (Exception e){
                        e.printStackTrace(System.err);
                        System.exit(-1);
                }
        }

        static class Utils {

                private Utils() {}

                public static void mergeSort(int[] a) {
                        mergeSort(a, 0, a.length - 1);
                }

                private static void mergeSort(int[] a, int leftIndex, int rightIndex) {
                        final int MAGIC_VALUE = 50;
                        if (leftIndex < rightIndex) {
                                if (rightIndex - leftIndex <= MAGIC_VALUE) {
                                        insertionSort(a, leftIndex, rightIndex);
                                } else {
                                        int middleIndex = (leftIndex + rightIndex) / 2;
                                        mergeSort(a, leftIndex, middleIndex);
                                        mergeSort(a, middleIndex + 1, rightIndex);
                                        merge(a, leftIndex, middleIndex, rightIndex);
                                }
                        }
                }

                private static void merge(int[] a, int leftIndex, int middleIndex, int rightIndex) {
                        int length1 = middleIndex - leftIndex + 1;
                        int length2 = rightIndex - middleIndex;
                        int[] leftArray = new int[length1];
                        int[] rightArray = new int[length2];
                        System.arraycopy(a, leftIndex, leftArray, 0, length1);
                        System.arraycopy(a, middleIndex + 1, rightArray, 0, length2);
                        for (int k = leftIndex, i = 0, j = 0; k <= rightIndex; k++) {
                                if (i == length1) {
                                        a[k] = rightArray[j++];
                                } else if (j == length2) {
                                        a[k] = leftArray[i++];
                                } else {
                                        a[k] = leftArray[i] <= rightArray[j] ? leftArray[i++] : rightArray[j++];
                                }
                        }
                }

                private static void insertionSort(int[] a, int leftIndex, int rightIndex) {
                        for (int i = leftIndex + 1; i <= rightIndex; i++) {
                                int current = a[i];
                                int j = i - 1;
                                while (j >= leftIndex && a[j] > current) {
                                        a[j + 1] = a[j];
                                        j--;
                                }
                                a[j + 1] = current;
                        }
                }
        }

        void solve() throws IOException{
        	int n = readInt();
        	int[] a = new int[n];
        	int k = 1;
        	int i = 0;
        	Arrays.fill(a,-1);
        	do{
        		if(a[i] == k){
        			break;
        		}
        		if(a[i] == -1)a[i] = k;
        		if(i + k < n){
        			i = i + k;
        		}
        		else
        			i = i + k - n;
        		k = (k + 1) % n;
        	}while(true);
        	for(int j = 0; j < n; j++){
        		if(a[j] == -1){
        			out.println("NO");
        			return;
        		}
        	}
        	out.println("YES");
        }

        static double distance(long x1, long y1, long x2, long y2){
        	return Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
        }

        static long gcd(long a, long b){
        	while(a != b){
        		if(a < b) a -=b;
        		else b -= a;
        	}
        	return a;
        }

        static long lcm(long a, long b){
        	return a * b /gcd(a, b);
        }
}


import java.util.Scanner;

public class Main{

    public static void main(String a[]){
        Scanner cin=new Scanner(System.in);
        int n=cin.nextInt();
        boolean vis[]=new boolean[n];
        int c=0,cont=1;
        while(true){
            if(!vis[c])
                vis[c]=true;
            c+=cont++;
            c%=n;
            if(cont>n*n*n)
                break;
        }
        boolean flag=true;
        for(boolean b:vis){
            if(!b){
                flag=false;
                break;
            }
        }
        if(flag)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}


import java.util.*;

public class Main
{
    public static void main(String[] arqs)
    {
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        boolean[] visited = new boolean[n];
        visited[0] = true;
        ArrayList<Integer> v = new ArrayList<Integer>();
        v.add(0+1*n);
        int jump = 1;
        int at = 0;

        while(true)
        {
            at += jump;
            at %= n;
            jump++;
            jump %= n;
            visited[at] = true;
            if(v.contains(at + jump*n)) break;
        }

        for(boolean i : visited)
        {
            if(!i)
            {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}


/* package codechef; // 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 Codechef
{
	public static void main (String[] args)
	{
		// your code goes here
		Scanner scan=new Scanner(System.in);
		int n,i=1,k=0,p=1;
		boolean flag=true;
		int[] a=new int[1000];
		n=scan.nextInt();
		while(i<=n)
		    {
		        if(!(i==n-1))
		          p*=i;
		        ++i;
		    }
		i=0;
		while(k<=p)
		{
		    i+=k;
		    if(i>=n)
                        {
                         while(!(i<n))
		             i=i-n;
                        }
            ++a[i];
		    ++k;
		}
		for(i=0;i<n;++i)
		    if(a[i]==0)
		        {
		         flag=false;
		         break;
		        }
		if(flag)
		    System.out.println("YES");
		else
		    System.out.println("NO");
	}
}


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

public class Main {

    public static void main(String[] args) {

        FastReader in=new FastReader();

        String s=in.next();

        StringBuilder sb=new StringBuilder(s);

        int r;

        r=(s.charAt(0) == 'h') ? 4 : 3;

        sb.insert(r,"://");

        int start=sb.indexOf("ru");
        int l=sb.lastIndexOf("ru");

        for(int y=0;y+1<=sb.length();y++){
            if(sb.charAt(y) == 'r' && sb.charAt(y+1)== 'u'){

                if(y!=l && y!=start){
                start=y;
                break;
                }

                else
                start=l;
            }
        }

        sb.insert(start,".");
        sb.insert(start+3,"/");

        if(sb.charAt(sb.length()-1) == '/'){
            sb.deleteCharAt(sb.length()-1);
        }

        System.out.println(sb);
    }

}

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

public class InternetAddress {

    public static void main(String[] args) {
        String address;

        int endValue = 3;
        Scanner sc = new Scanner(System.in);
        address = sc.nextLine();
        int group = 0;

        if (address.substring(0, 4).equalsIgnoreCase("http")) {

            endValue = 4;
        }

        String correctAddress;
        correctAddress = address.substring(0, endValue);
        correctAddress += "://";
        Pattern addressPattern = Pattern.compile("ru");
        Matcher addressMatcher = addressPattern.matcher(address);

        if (addressMatcher.find()) {
            if (addressMatcher.start() == 3 || addressMatcher.start() == 4) {
                addressMatcher.find();
            }
            correctAddress += address.substring(endValue, addressMatcher.start());
            correctAddress += ("." + address.substring(addressMatcher.start(), addressMatcher.end()));
            if (address.length() > addressMatcher.end()) {
                correctAddress += ("/" + address.substring(addressMatcher.end()));
            }
            System.out.println(correctAddress);
        }
    }
}


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

public class Temp {
	static int imax = Integer.MAX_VALUE, imin = Integer.MIN_VALUE;
	static long lmax = Long.MAX_VALUE, lmin = Long.MIN_VALUE;
	static long mod = (long) 1e9 + 7;

	public static void main(String[] args) throws java.lang.Exception {
//		File file=new File("C:\\Users\\EagleEye\\Desktop\\input.txt");
//		File file1=new File("C:\\Users\\EagleEye\\Desktop\\output.txt");
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		// int test=in.ni();
		int test = 1;
		int i = 0, j = 0;
		while (test-- > 0) {
//			int n = in.ni();
//			char str[]=in.ncs();
			String str=in.ns();
			StringBuilder bdr=new StringBuilder();
			if(str.startsWith("http")){
				bdr.append("http://");
				int last=0;
				for(i=4;i<str.length();i++){
					if(str.charAt(i)=='r'&&str.charAt(i+1)=='u'){
						last=i;
					}
				}
				bdr.append(str.substring(4,last)+"."+"ru");
				if(last+2<str.length()){
					bdr.append("/"+str.substring(last+2));
				}
			}else{
				bdr.append("ftp://");
				int last=0;
				for(i=3;i<str.length();i++){
					if(str.charAt(i)=='r'&&str.charAt(i+1)=='u'){
						last=i;
					}
				}
				bdr.append(str.substring(3,last)+"."+"ru");
				if(last+2<str.length()){
					bdr.append("/"+str.substring(last+2));
				}
			}
			out.println(bdr.toString());
		}
		out.close();
	}

	static class Pair {
		int x, y;

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

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

	static void print(int arr[], int len) {
		for (int i = 0; i < len; i++)
			System.out.print(arr[i] + " ");
		System.out.println();
	}

	static class InputReader {

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

		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 ni() {
			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 & 15;
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

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

		public String ns() {
			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 char[] ncs(){
			return ns().toCharArray();
		}
		public String nLine() {
			int c = read();
			// while (c != '\n' && c != '\r' && c != '\t' && c != -1)
			// c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (c != '\n' && c != '\r' && c != '\t' && c != -1);
			return res.toString();
		}

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

	}

}


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

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

class TaskA {
	public void solve(int testNumber, InputReader in, OutputWriter out) {
        int n=in.nextInt(),i;
        int a=0,b=0,limita=0,limitb=0;
        for(i=0;i<n;i++)
        {
            int t=in.nextInt(),x=in.nextInt(),y=in.nextInt();
            if(t==1)
            {
                limita+=10;
                a+=x;

            }
            else
            {
                limitb+=10;
                b+=x;
            }
        }
        if(2*a>=limita)
            out.printLine("LIVE");
        else out.printLine("DEAD");
        if(2*b>=limitb)
            out.printLine("LIVE");
        else out.printLine("DEAD");
	}
}

class InputReader
{
    BufferedReader in;
    StringTokenizer tokenizer=null;

    public InputReader(InputStream inputStream)
    {
        in=new BufferedReader(new InputStreamReader(inputStream));
    }
    public String next()
    {
        try{
            while (tokenizer==null||!tokenizer.hasMoreTokens())
            {
                tokenizer=new StringTokenizer(in.readLine());
            }
            return tokenizer.nextToken();
        }
        catch (IOException e)
        {
            return null;
        }
    }
    public int nextInt()
    {
        return Integer.parseInt(next());
    }

}

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


import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	int n;
	int [] arr;
	public static void main(String[] args) throws Exception {
        new Main();
    }

	public Main() throws Exception{
		Scanner sc = new Scanner(System.in);
//		Scanner sc = new Scanner(new FileReader("input"));

		n = sc.nextInt();
		arr = new int[n];

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

		if (canDevideInOdd(arr)){
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

        sc.close();
	}

	boolean canDevideInOdd(int[] arr1){

		if (arr1.length == 0){
			return false;
		}
		if ( arr1[0]%2==0 ){
			return false;
		}

		if (arr1[0] % 2 == 1 && arr1.length % 2 == 1 && arr1[arr1.length - 1] % 2 == 1){
			return true;
		}

		for (int i=0;i<arr1.length;i++){
			if (arr1[i]%2 == 1 && (i + 1)% 2 == 1){
				int [] arr2 = new int[arr1.length - i - 1];
				for (int j=i + 1;j<arr1.length;j++){
					arr2[j - (i + 1)] = arr1[j];
				}
				if (canDevideInEven(arr2)){

					return true;
				}

			}

		}
		return false;
	}

	boolean canDevideInEven(int[] arr1){

		if (arr1.length == 0){
			return true;
		}
		if ( arr1[0]%2==0 ){
			return false;
		}
		for (int i=0;i<arr1.length;i++){
			if (arr1[i]%2 == 1 && (i + 1) % 2 == 1){
				int [] arr2 = new int[arr1.length - i - 1];
				for (int j=i + 1;j<arr1.length;j++){
					arr2[j - (i + 1)] = arr1[j];
				}
//				printArr(arr2);
				if (canDevideInOdd(arr2)){
					return true;
				}

			}

		}

		return false;
	}

	void printArr(int[] arr){
		System.out.println();
		for(int i=0;i<arr.length;i++){
			System.out.print(arr[i] + " ");
		}
		System.out.println();

	}

}


import java.util.Scanner;

public class OddsAndEnds {
    static int [] arr;
    static boolean done = false;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int len = scan.nextInt();
        arr = new int[len];
        for (int i = 0; i < len; i++) {
            arr[i] = scan.nextInt();
        }
        partition(new int[len], len, len, 0);
        if (done) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
        scan.close();
    }

    private static void checkAnswer(int[] p, int n) {
        int begin = 0;
        for (int i = 0; i < n; i++) {
            if (arr[begin] % 2 == 0) {
                return;
            }
            if (arr[begin + p[i] - 1] % 2 == 0) {
                return;
            }
            begin += p[i];
        }

        done = true;
    }

    private static void partition(int[] p, int n, int m, int i) {
        if (n == 0) {
            if (i % 2 != 0) {
                checkAnswer(p, i);
            }
        }
        else {
            for (int k = m; k > 0; k--) {
                if (done) {
                    return;
                }

                if (k % 2 != 0) {
                    p[i] = k;
                    partition(p, n - k, n - k, i + 1);
                }
            }
        }
    }

}


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

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

	private void solve() throws Exception {
		reader = new BufferedReader(new InputStreamReader(System.in));

		n = Integer.parseInt(reader.readLine());
		a = new int[n];
		st = new StringTokenizer(reader.readLine());

		for (int i = 0; i < n; ++i) {
			a[i] = Integer.parseInt(st.nextToken());
		}

		reader.close();

		if (func(0, false)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	private BufferedReader reader;
	private StringTokenizer st;
	private int n;
	private int[] a;

	private boolean func(int indx, boolean flag) {

		if (indx >= n) {
			return flag;
		}

		if (a[indx] % 2 == 0 || a[n - 1] % 2 == 0) {
			return false;
		}

		if (!flag && (n - indx) % 2 == 1) {
			return true;
		}

		for (int j = indx; j < n; j += 2) {
			if (a[j] % 2 == 0) {
				continue;
			}

			if (func(j + 1, !flag)) {
				return true;
			}
		}

		return false;
	}
}


import java.util.*;

public class Solution24 {

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

		int length = scan.nextInt();
		int[] arr = new int[length];

		for(int i = 0; i < length; i++){
			arr[i] = scan.nextInt();
		}

		boolean flag = true;
		if(length % 2 == 0)	flag = false;
		if(arr[0]%2 == 0 || arr[length-1]%2 == 0)	flag = false;
		Vector<Integer> even = new Vector<Integer>();
		Vector<Integer> odd = new Vector<Integer>();

		int numOdd = 0;
		int count = 0;

		if(flag){
			for(int i = 0; i < length; i++){
				if(arr[i]%2 == 0){
					count++;
				}
				else{
					numOdd++;
					if(count != 0){
						even.add(count);
					}
					count = 0;
				}
			}

		}

		for(int i = 0; i < even.size(); i++){
			if(even.elementAt(i) % 2 == 0){
				flag = false;
				break;
			}
		}

		if(flag){
			int evenDiv = even.size();
			int total = evenDiv;

			int singles = numOdd - 2*evenDiv;

			if(singles < 0){
				flag = false;
			}
			else if((total + singles)%2 == 0){
				flag = false;
			}
		}

		System.out.println(flag?"Yes":"No");

		scan.close();
	}
}


// @author Sanzhar
import java.io.*;
import java.util.*;
import java.awt.Point;

public class Template {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer st;

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

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

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

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

    public void run() throws Exception {
        //in = new BufferedReader(new FileReader("input.txt"));
        //out = new PrintWriter(new FileWriter("output.txt"));
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.flush();
        out.close();
        in.close();
    }

    public void solve() throws Exception {
        int n = nextInt();
        if (n == 2) {
            out.println(0);
            return;
        }
        long d[] = {0, 1, 0, 3, 0, 15, 0, 133, 0, 2025, 0, 37851, 0, 1030367, 0, 36362925};
        long mod = 1000000007;
        long ans = 1;
        for (long i = 1; i <= n; i++) {
            ans *= i;
            ans %= mod;
        }
        ans = (ans * d[n]) % mod;
        out.println(ans);
    }

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