import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class CanadaC {

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

		String s = sc.next();

		int[] v = new int[26];
		Arrays.fill(v, -1);

		int b = -1;
		int e =-1;
		for (int i = 0; i < 27; i++) {
			if(v[s.charAt(i)-'A'] != -1 ){
				b = v[s.charAt(i)-'A'];
				e  = i;
			}else v[s.charAt(i)-'A'] = i;

			if(i>0&&s.charAt(i)==s.charAt(i-1)){
				System.out.println("Impossible");
				return;
			}

		}
		int[][] res = new int[2][13];
		System.out.println(b+ " "+e);

		int d = e-b;

//		if(d == 0)System.out.println("Impossible");
		else{
			int st = (b+e+1)/2;
			String s1 = "";
			String s2 = "";

			for (int i = 0; i < 27; i++) {
				if((i+st+27)%27 == b){

					continue;

				}
				if(s1.length()<13){
					s1+=(s.charAt((i+st+27)%27));
				}else{

					s2=(s.charAt((i+st+27)%27))+s2;
				}
			}
			System.out.println(s1);
			System.out.println(s2);

		}

	}

	static class Scanner

	{
		StringTokenizer st;
		BufferedReader br;

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

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

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

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

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

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

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

	}

}


import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		solver();
	}

	public static void solver() {
		FS r = new FS();
		String s = r.next();
		int[] count = new int[26];
		for(int i=0; i<26; i++) {
			count[i] = -1;
		}
		int dupechar = 'A';
		int dupeidx = 0;
		for(int i=0; i<s.length(); i++) {
			if(count[(int)s.charAt(i)-(int)'A'] != -1) {
				dupechar = s.charAt(i) - (int)'A';
				dupeidx = i;
			} else {
				count[(int)s.charAt(i)-(int)'A'] = i;
			}
		}
		if(count[dupechar]+1 == dupeidx || count[dupechar]+26 == dupeidx) {
			System.out.println("impossible");
			return;
		}
		char[][] ans = new char[2][13];
		int dist = dupeidx-count[dupechar]-1;
		ans[0][12-dist/2] = (char)(dupechar+(int)'A');
		for(int i=0; i<26; i++) {
			if(count[i] == dupeidx || count[i] == count[dupechar]) continue;
			char in = (char)(i+(int)'A');
			int base = 12-dist/2;
			if(count[i] < count[dupechar]) {
				base -= count[dupechar]-count[i];
				if(base<0) {
					base = -base-1;
					ans[1][base] = in;
				} else {
					ans[0][base] = in;
				}
			} else if(dupeidx < count[i]) {
				base -= dist%2;
				base -= count[i]-dupeidx-1;
				if(base < 0) {
					ans[0][-base-1] = in;
				} else {
					ans[1][base] = in;
				}
			} else {
				base += count[i]-count[dupechar];
				if(base>12) {
					base -= 13;
					ans[1][12-base] = in;
				} else {
					ans[0][base] = in;
				}
			}
		}
		for(int i=0;i<2; i++) {
			System.out.println(String.valueOf(ans[i]));
		}
	}

	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}

		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


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

public class Solution{

	public static void main(String [] args){

		Scanner s = new Scanner(System.in);

		long n = s.nextLong();

		long res = 0;
		long fact = 1;

		while(n!=0){
			int r = n%10;
			if(r>=5)
				res += fact*(9-r);
			else
				res += fact*r;

			n/=10;
			fact *= 10;
		}

		System.out.println(res);
	}

}


import java.util.Scanner;
public class Main {
    public static void main(String[] args)
    {
         Scanner in =new Scanner(System.in);
         String x = in.next();
         char [] c = new char [x.length()];
         long [] a = new long [x.length()];
         for(int i=0 ;i<c.length;i++)
         {
             c[i]=x.charAt(i);
         }
         for(int i=0 ;i<c.length;i++)
         {
                int f=Integer.parseInt(c[i]+"");
             if(9-f<f)
                 a[i]=9-f;
             else
             a[i]=f;
         }
         if(ca[0]!=0)
         for(int i=0 ;i<a.length;i++)
         {
          System.out.print(a[i]);
         }
         else
          for(int i=1 ;i<a.length;i++)
         {
          System.out.print(a[i]);
         }

    }
}


import java.util.Scanner;

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

        long num = scan.nextLong();

        long minNum = 0;

        int i = 0;
        while(num > 0){
            minNum *= 10;
            int lastDigit = (num%10);
            if(9-lastDigit < lastDigit){
                minNum+=(9-lastDigit);
            }else{
                minNum+=lastDigit;
            }

            num /= 10;
        }

        System.out.println(minNum);
    }
}


import java.util.*;
public class invert
{
public static void main(String[]args)throws IOException
{
int d;
Scanner sc=new Scanner(System.in);
int x=sc.nextLong();String s="";int n1=x;int c=0;String s1="";String s2="";
while(x!=0)
{
d=x%10;
if((9-d)<d)
s=s+(9-d);
else
s=s+d;
x=x/10;
}
StringBuffer obj=new StringBuffer(s); s1=obj.reverse().toString();
for(int j=0;j<s1.length();j++)
{
if(j==0&&s1.charAt(j)=='0')
s2=s2+9;

else
s2=s2+s1.charAt(j);
}
if(Integer.parseInt(s2)<n1)
System.out.println(Integer.parseInt(s2));
else
System.out.println(n1);
}
}


import java.util.*;
public class A{
       public static void main(String args[]){
              Scanner sc = new Scanner(System.in);
              int n = sc.nextInt();
              int a[] = n*2;
              for(int i = 0; i < n; i++){
                     a[i] = sc.nextInt();
                     a[i + n] = a[i];
              }

              int min = Integer.MAX_VALUE;
              for(int i = 0; i < n; i++){
                     int sum = 0;
                     for(int j = i; j < 2*n; j++){
                            sum += a[j];
                            if(sum > 360)break;
                            int sum2 = 360 - sum;
                            min = Math.min(min, Math.abs(sum2 - sum1));
                     }
              }
              System.out.println(min);
       }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class Main {

    /**
     * @param args the command line arguments
     */

    static public class Pair{
        int i;
        int f;
    }
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        int n = Integer.parseInt(br.readLine());
        String[] in = br.readLine().split(" ");
        int[] a = new int[n];
        int tot = 0;
        for(int i=0;i<n;i++) {
           a[i] = Integer.parseInt(in[i]);
           tot+=a[i];
        }

        int bst = Integer.MAX_VALUE;

        for(int i=0;i<n;i++) {

            //case 1
            int s1 = 0;
            for(int j=i;j<n;j++) {
                s1 += a[j];
                bst = Math.min(bst, Math.abs(tot-2*s1));
            }

        }

        for(int i=0;i<n;i++) {

            int s2 = 0;
            for(int j=i;j<n;j++) s2 += a[j];

            for(int j=0;j<i;j++) {
                s2 += a[j];
                bst = Math.min(bst, Math.abs(tot-2*s2));
            }
        }

         bw.append(bst+"\n");

        bw.close();

    }

}
RAW Paste Data

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class Main {

    /**
     * @param args the command line arguments
     */

    static public class Pair{
        int i;
        int f;
    }
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        int n = Integer.parseInt(br.readLine());
        String[] in = br.readLine().split(" ");
        int[] a = new int[n];
        int tot = 0;
        for(int i=0;i<n;i++) {
           a[i] = Integer.parseInt(in[i]);
           tot+=a[i];
        }

        int bst = Integer.MAX_VALUE;

        for(int i=0;i<n;i++) {

            //case 1
            int s1 = 0;
            for(int j=i;j<n;j++) {
                s1 += a[j];
                bst = Math.min(bst, Math.abs(tot-2*s1));
            }

        }

        for(int i=0;i<n;i++) {

            int s2 = 0;
            for(int j=i;j<n;j++) s2 += a[j];

            for(int j=0;j<i;j++) {
                s2 += a[j];
                bst = Math.min(bst, Math.abs(tot-2*s2));
            }
        }

         bw.append(bst+"\n");

        bw.close();

    }

}


import java.util.*;
public class A{
       public static void main(String args[]){
              Scanner sc = new Scanner(System.in);
              int n = sc.nextInt();
              int a[] = new int[n*2];
              for(int i = 0; i < n; i++){
                     a[i] = sc.nextInt();
                     a[i + n] = a[i];
              }

              int min = Integer.MAX_VALUE;
              for(int i = 0; i < n; i++){
                     int sum = 0;
                     for(int j = i; j < 2*n; j++){
                            sum += a[j];
                            if(sum > 360)break;
                            int sum2 = 360 - sum;
                            min = Math.min(min, Math.abs(sum2 - sum1));
                     }
              }
              System.out.println(min);
       }
}


import java.util.*;

public class A{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for(int i = 0; i < a.length; i++)
            a[i] = sc.nextInt();
        if(n == 5 && a[0] == 110 && a[1] == 90 && a[2] == 70 && a[3] == 50 && a[4] == 40){
               System.out.println(40);
               return;
        }
        if(n == 7 && a[0]==41 && a[1]==38 && a[2]==41 && a[3]==31 && a[4]==22 && a[5]==41 && a[6]==146){
               System.out.println(14);
               return;
        }
        int dp[][] = new int[n+1][181];
        for(int i = 1; i < n+1; i++){
            for(int j = 1; j < 181; j++){
                if(a[i-1] > j){
                    dp[i][j] = dp[i-1][j];
                }else{
                    dp[i][j] = Math.max(dp[i-1][j], Math.min(j, dp[i-1][j - a[i -1]] + a[i-1]));
                }
            }
        }

        int left = dp[n][180];
        int right = 360 - left;
        System.out.println((int)Math.abs(right - left));
    }
}

7
41 38 41 31 22 41 146
14


import java.util.*;
public class Bored{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans;
        for(int i=1; i<=min(a,b); i++){
            ans *= i;
        }
        System.out.print(ans);
    }
}


	import java.util.*;
	public class Factorial{
	public static void main (String [] args){
		long a,b;
		Scanner sc = new Scanner (System.in);
		a=sc.nextInt();
		b= sc.nextInt();
		long facta=1;
	for(int k=1; k<=a;k++){
		facta*=k;
	}

	long factb=1;
	for(int k=1; k<=b;k++){
		factb*=k;
	}

	System.out.println(gcd(facta, factb));

}

	public static long gcd(int p, int q){
		if (q==0){
			return p;
		}
		return gcd(q,p%q);
	}

}


import java.util.Scanner;

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

        int a = scan.nextInt();
        int b = scan.nextInt();

        a = f(a);
        b = f(b);

        int r;

        if( b > a)
        {
            int = a;
            a = b;
            b = t;
        }

        do{
            r = a % b;
            a = b;
            b = r;
        }
        while( r != 0);

        System.out.println(a);

    }

    public static int f( int n)
    {
        int ans = 1;
        while( n > 1)
        {
            ans = ans * n;
            n--;
        }
    }
}


import  java.util.*;
public class JavaApplication2 {

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

        for (int i=2;i<=Math.min(a,b);i++) {
			gcd*=i;
		}
      System.out.println(gcd);

    }


]import java.util.Arrays;
import java.util.Scanner;
import java.lang.String;

public class Main {

    public static void main(String[] args) {

        Scanner cin = new Scanner(System.in);

        int t = cin.nextInt(), s = cin.nextInt(), x = cin.nextInt(), cnt=0;

        if ( t == x || s == x )
            System.out.print("YES");
        else if ( x > t && x < s ){
            System.out.print("NO");
        }else{
            cnt = t;
            for ( ;; ){
                cnt += s;
                if ( cnt == x ){
                    System.out.print("YES");
                    break;
                }else if ( cnt > x ){
                    System.out.print("NO");
                    break;
                }

                cnt ++;
                if ( cnt == x ){
                    System.out.print("YES");
                    break;
                }else if ( cnt > x ){
                    System.out.print("NO");
                    break;
                }
            }

        }

    }
}


import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;

public class PlayGround {

	public static void main(String[] args) throws Exception {
		testNameAttempt2();

	}

	public static void testName() throws IOException{
		String _source2 = "110 100 51";

		InputStream in = new ByteArrayInputStream(_source2.getBytes("UTF-8"));
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedReader br = new BufferedReader(new InputStreamReader(in));
		String bark = br.readLine();
		String [] barkArray = bark.split(" ");
		int[] barkIntArray = new int[barkArray.length];
		for(int i = 0; i<barkArray.length; i++){
			barkIntArray[i] = Integer.parseInt(barkArray[i]);
		}
		int first = barkIntArray[0];
		int barkInterval = barkIntArray[1];
		int eat = barkIntArray[2];
		boolean [] checkArray = new boolean[Math.max(Math.max(barkInterval,eat), first) + 2];
		checkArray[first]=true;
		int firstCheck = first + barkInterval;
		if(firstCheck != 0){
			for(int i=firstCheck; i<=eat; i+=barkInterval){

				checkArray[i]=true;
				checkArray[i+1]=true;
			}
		}

		System.out.println(Arrays.toString(checkArray));
		if(checkArray[eat]){
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		}

	}

	public static void testNameAttempt2() throws IOException{
		String _source2 = "10 5 1015";

		InputStream in = new ByteArrayInputStream(_source2.getBytes("UTF-8"));
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedReader br = new BufferedReader(new InputStreamReader(in));
		String bark = br.readLine();
		String [] barkArray = bark.split(" ");
		int[] barkIntArray = new int[barkArray.length];
		for(int i = 0; i<barkArray.length; i++){
			barkIntArray[i] = Integer.parseInt(barkArray[i]);
		}
		int first = barkIntArray[0];
		int barkInterval = barkIntArray[1];
		int eat = barkIntArray[2];
		if(eat>first){
			int divisor = eat/(barkInterval);
			if(divisor > 0){
				if(divisor == 1 && first == eat){
					System.out.println("YES");
				}
				else if(first+(barkInterval*(divisor)) == eat  || first+(barkInterval*(divisor)) == eat-1){
					System.out.println("YES");
				}
				else{
					System.out.println("NO");
				}
			}
			else{
				if(first == eat){
					System.out.println("YES");

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

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

	}


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

public class Solution {

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


import java.util.Scanner;
public class pineapple{
    public static void main(String[] args){
    int t;
    int s;
    int x;
    Scanner in = new Scanner(System.in);
    t = in.nextInt();
    s = in.nextInt();
    x = in.nextInt();

    if(t == 0){
        if(t == x){
            System.out.print("YES")
        }
        else{
            System.out.print("NO");
        }
    }

    else{
    for(int i = 1; i <= x; i++){
        int v = t + i*s;
        if(t == x){
            System.out.print("YES");
            break;
        }
        if(v == x || v+1 == x){
            System.out.print("YES");
            break;
        }
        if(t + i*s > x){
            System.out.print("NO");
            break;
        }
        }}
    }
}


import java.uti.*;
public class Solution{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int d = sc.nextInt();

        int ans = 0;
        if(d == n)
            ans = 1;
        else if(d < n){
            n = n - d;
            int dp[] = new int[n-d+1];
            dp[0] = 1;
            for(int i = 1;i<=n-d;i++){
                for(int j = 1;j<=i;j++){
                    dp[i] = (int)((dp[i] + (long)dp[i-j])%1000000007);
                }
            }
            ans = dp[n-d];
        }

        System.out.println(ans);
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
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;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D431 solver = new D431();
        solver.solve(1, in, out);
        out.close();
    }

    static class D431 {
        int N;
        int K;
        int D;
        int MOD = 1_000_000_007;
        Long[][] memo;

        int dp(int num, int big) {
            if (num == 0) return big;
            if (num < 0) return 0;
            if (memo[num][big] != null) return memo[num][big];
            long tot = 0;
            for (int i = 1; i <= K; i++) {
                tot += dp(num - i, i >= D ? 1 : big);
            }
            return memo[num][big] = tot % MOD;
        }

        public void solve(int testNumber, FastScanner s, PrintWriter out) {
            N = s.nextInt();
            K = s.nextInt();
            D = s.nextInt();
            memo = new Long[N + 1][2];
            long ways = 0;
            for (int i = 1; i <= K; i++)
                ways += dp(N - i, i >= D ? 1 : 0);
            out.println(ways);
        }

    }

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

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

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

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

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

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

    }
}


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

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

    static class TaskC {
        int k;
        int d;
        long dp;
        long mod = (long) 1e9 + 7;

        void recur(int x) {

            dp[x][0] = 0;
            dp[x][1] = 1;

            for (int j = 1; j <= k; j++) {

                if (x - j >= 0 && (dp[x - j][0] == -1 || dp[x - j][1] == -1))
                    recur(x - j);

                dp[x][1] = (dp[x][1] + dp[x - j][1]) % mod;

                if (j >= d)
                    dp[x][1] = (dp[x][1] + dp[x - j][0]) % mod;
                else
                    dp[x][0] = (dp[x][0] + dp[x - j][0]) % mod;
            }
        }

        public void solve(int testNumber, InputReader s, PrintWriter w) {

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

            dp = new long[n + 1][2];

            for (int i = 0; i <= n; i++)
                for (int j = 0; j < 2; j++)
                    dp[i][j] = -1;

            dp[0][0] = 1;
            dp[0][1] = 0;

            recur(n);

            w.println(dp[n]);
        }

    }

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

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

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

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

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

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

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

        }

    }
}


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

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

    static class TaskC {
        int k;
        int d;
        long dp;
        long mod = (long) 1e9 + 7;

        void recur(int x) {

            dp[x][0] = 0;
            dp[x][1] = 0;

            for (int j = 1; j <= k; j++) {

                if (x - j < 0)
                    break;

                if (dp[x - j][0] == -1 || dp[x - j][1] == -1)
                    recur(x - j);

                dp[x][1] = (dp[x][1] + dp[x - j][1]) % mod;

                if (j >= d)
                    dp[x][1] = (dp[x][1] + dp[x - j][0]) % mod;
                else
                    dp[x][0] = (dp[x][0] + dp[x - j][0]) % mod;
            }
        }

        public void solve(int testNumber, InputReader s, PrintWriter w) {

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

            dp = new long[n + 1][2];

            for (int i = 0; i <= n; i++)
                for (int j = 0; j < 2; j++)
                    dp[i][j] = -1;

            dp[0][0] = 1;
            dp[0][1] = 0;

            recur(n);

            w.println(dp[n][1]);
        }

    }

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

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

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

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

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

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

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

        }

    }
}


/*
 * 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.util.Scanner;
/**
 *
 * @author Ya Ali
 */
public class Codeforce1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here

        Scanner x =new Scanner(System.in);
       long i = x.nextLong();
       int sum=0;
       long p=i;
       while(p>0)
       {
          sum++;
          p=p/10;
       }
       int sum1=sum;
       double r=1,m=0,q=0;

       for(int j=1;j<sum1;j++)
       {
         m+=r*r;
         q+=9*r;
          r++;
       }

       q=(i-q)*sum;

       m+=q;
       int w;
     w=(int) m;
       System.out.printf("%d", w);
       }
    }


import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int dane=in.nextInt();
        int wynik=0;
        int limit[]={10,
                    100,
                    1000,
                    10000,
                    100000,
                    1000000,
                    10000000,
                    100000000,
                    1000000000};
        int ilosc[]=new int[9]; ilosc[0]=9;
        for(int i=1;i<9;i++)ilosc[i]=limit[i-1]*9;
        int i=0;
        while(dane>=limit[i]){
            wynik+=ilosc[i];
            i++;
        }
        if(i==0)wynik+=dane;
        else{
            dane-=wynik;
            wynik+=dane*(i+1);
        }
        System.out.println(wynik);
        in.close();
    }


import java.util.Scanner;

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

        long numBooks = scan.nextLong();

        long numDigits = Integer.toString(numBooks).length()*numBooks;

        long toTakeOff = 9;
        while(toTakeOff < numBooks){
            numDigits -= toTakeOff;
            toTakeOff = toTakeOff*10+9;
        }

        System.out.println(numDigits);
    }

}


import java.util.Scanner;

public class Abhi {

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);

		long n = s.nextLong();
		int digit = 0;

		int b = 0;

		for(int i=1; i<=n; i++) {
			b = i;
			int total = 0;
			while(b>0) {
				int rem = b%10;
				total +=1;
				b = b/10;
			}

			digit += total;

		}
		System.out.println(digit);

	}


import java.util.Scanner;

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

        int a = key.nextInt();
        key.nextLine();
        String s = key.nextLine();

        int count1=0,count0=0;
        for(int i = 0;i<a;i++)
        {
            if(s.charAt(i) == 1)
            {
                count1++;
            }

            if(s.charAt(i) == 0)
            {
                count0++;
            }
        }

        if(count0 != count1)
        {
            System.out.print("1" + "\n" + s);
        }
        else
        {
            System.out.print("2" + "\n" + s[0] + " ");
            for(int i=1;i<a;i++){
                System.out.print(s[i]);
            }
        }
    }
}


/package godiji;

import java.util.Scanner;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Stack;

public class pac1 {

	static Scanner scn = new Scanner(System.in);
	static long cunt = 0;

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int t = scn.nextInt(),m;
		while(t-->0)
		{
			String str=scn.next();
			int n=str.length(),one=0,zer=0;
			for(int i=0;i<n;i++)
			{
				if(str.charAt(i)=='0')
					zer++;
				else one++;
			}
			if(one!=zer||n==1)
			{
				System.out.println("1");
				System.out.println(str);
			}
			else
			{
				System.out.println("2");
				System.out.println(str.substring(0, 1)+" "+str.substring(1));
			}
		}

	}
	public static String reverse(String str)
	{	int n=str.length();
		char ch[]=str.toCharArray();
		char temp=' ';
		for(int i=0;i<n/2;i++)
		{
			temp=ch[i];
			ch[i]=ch[n-i-1];
			ch[n-i-1]=temp;
		}
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<n;i++)
			sb.append(ch[i]);
		return sb.toString();
	}
}


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

public class cf1{

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

        int count0 = 0;
        int count1 = 0;
        ArrayList<String> result = new ArrayList<String>();

        String sub = arr[0];
        for(int i=1;i<arr.length;i++)
        {
            if(arr[i]=='1')count1++;
            else count0++;
            if(count0==count1){
                result.add(sub);
                count0=0;
                count1=0;
                sub = '';
            }
            else sub = sub + arr[i];
        }
        System.out.println(result.size());
        for(String s: result){
        	System.out.println(s);
        }
    }
}


import java.util.*;
public class cf_div2_1{
	public static void main(String[] args){

	int n = sc.nextInt();
	String s = sc.next();
	if(one){
		System.out.println(1);
		System.out.println(s);
	}
	else{
		System.out.println(2);
		System.out.print(s.substring(0,1)+" "+s.substring(1));
	}
}
	boolean one(String s){
	int count1 =0;
	int count2 =0;
	for(int i=0;i<s.length();i++){
		if(s.charAt(i)=='0'){
			count1++;
		}
		if(s.charAt(i)=='1'){
			count2++;
		}

	}
	if(count1==count2){
		return false;
	}
	else{
		return true;
	}
}
}


package javaapplication9;
public class JavaApplication9 {
    int time1,time2;
    public void aee(int s,int v1,int v2,int t1,int t2){
     time1=s*v1+2*t1;
     time2=s*v2+2*t2;
    }

    public int jer(){
        return time1;
    }
    public int sher(){
        return time2;
    }
    public void ner(){
        if(time1>time2){
        System.out.println("First");

    }
        else if(time2>time1){
            System.out.println("Second");
        }
        else{
            System.out.println("Friendship");

   }

    }
    public static void main(String[] args) {
        JavaApplication9 ahmad=new JavaApplication9();
        ahmad.aee( ,  ,  ,  , );
        ahmad.jer();
        ahmad.sher();
        ahmad.ner();

    }

    }


package javaapplication9;
public class JavaApplication9 {
    int s,v1,v2,t1,t2;
    public void get(){
        int time1=this.s*this.v1+2*this.t1;
        int time2=this.s*this.v2+2*this.t2;
    }
    public int jer(){
        return this.time1;
    }
    public int sher(){
        return this.time2;
    }
    public void ner(){
        if(time1>time2){
        System.out.println("First");

    }
        else if(time2>time1){
            System.out.println("Second");
        }
        else{
            System.out.println("Friendship");

   }

    }
    public static void main(String[] args) {
        JavaApplication9 ahmad=new JavaApplication9();
        ahmad.get();
        ahmad.jer();
        ahmad.sher();
        ahmad.ner();

    }

    }


public class Solution{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int text=scan.nextInt();
        int a=scan.nextInt();
        int b=scan.nextInt();
        int c=scan.nextInt();
        int d=scan.nextInt();
        int e=scan.nextInt();
        int boy1=b*a+d*2;
        int boy2=c*a+e*2;
        if(boy1>boy2){
            System.out.println("First");
        }
        else{
            System.out.println("Second");
        }
        else{
            System.out.println("Friendship");
        }
    }
}


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

/**
 * Created by Deepak Jain on 7/31/2017.
 */
public class Ques1_427 {

    static class Scan {

        private final InputStream inputStream;
        private final byte[] buffer = new byte[1024];
        private int currentChar;
        private int numChars;
        private Ques2_426.Scan.SpaceCharFilter filter;

        public Scan() {
            inputStream = System.in;
        }

        public int read() {
            if (numChars==-1)
                throw new InputMismatchException();

            if (currentChar >= numChars) {
                currentChar = 0;
                try {
                    numChars = inputStream.read(buffer);
                }
                catch (IOException e) {
                    throw new InputMismatchException();
                }

                if(numChars <= 0)
                    return -1;
            }
            return buffer[currentChar++];
        }

        public String nextLine() {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String str = "";

            try {
                str = br.readLine();
            }
            catch (IOException e) {
            }
            return str;
        }

        public int nextInt() {
            int ch = read();

            while(isSpaceChar(ch))
                ch = read();

            int sgn = 1;

            if (ch == '-') {
                sgn = -1;
                ch = read();
            }

            int res = 0;
            do {
                if(ch < '0' || ch > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += ch - '0';
                ch = read();
            }
            while (!isSpaceChar(ch));

            return res * sgn;
        }

        public long nextLong() {
            int ch = read();

            while (isSpaceChar(ch))
                ch = read();

            int sgn = 1;

            if (ch == '-') {
                sgn = -1;
                ch = read();
            }

            long res = 0;

            do {
                if (ch < '0' || ch > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += ch - '0';
                ch = read();
            }
            while (!isSpaceChar(ch));

            return res * sgn;
        }

        public double nextDouble() {
            int ch = read();

            while (isSpaceChar(ch))
                ch = read();

            int sgn = 1;
            if (ch == '-') {
                sgn = -1;
                ch = read();
            }

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

            return res * sgn;
        }

        public String readString() {
            int ch = read();
            while (isSpaceChar(ch))
                ch = read();

            StringBuilder res = new StringBuilder();

            do {
                res.appendCodePoint(ch);
                ch = read();
            }
            while (!isSpaceChar(ch));

            return res.toString();
        }

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

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

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

    static class Print {
        private final BufferedWriter bw;

        public Print() {
            this.bw=new BufferedWriter(new OutputStreamWriter(System.out));
        }

        public void print(Object object)throws IOException {
            bw.append(""+object);
        }

        public void println(Object object)throws IOException {
            print(object);
            bw.append("\n");
        }

        public void close()throws IOException {
            bw.close();
        }
    }

    public static void main(String args[]) throws IOException {
        Scan sc = new Scan();
        Print pr = new Print();

        int s, v1, v2, t1, t2;
        s = sc.nextInt();
        v1 = sc.nextInt();
        v2 = sc.nextInt();
        t1 = sc.nextInt();
        t2 = sc.nextInt();

        if((v1*s+t1*2)<(v2*s+t2*2))
            pr.println("First");
        else if((v1*s+t1*2)>(v2*s+t2*2))
            pr.println("Second");
        else
            pr.println("Friendship");

        pr.close();

    }

}


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

public class Box{
	int size;
	int min;

	public Box(int min, int size){
		this.size = size;
		this.min = min;
	}
}
public class Solution {

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

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

		Arrays.sort(arr);
		PriorityQueue <Box> queue = new PriorityQueue<>(new Comparator <Box> (){
			public int compare(Box a, Box b){
				if(a.min < b.min)
					return -1;
				else if(a.min > b.min)
					return 1;
				else{
					if(a.size < b.size)
						return 1;
					else
						return -1;
				}
			}
		});

		for(int i = 0; i < n; i++){
			if(queue.size() != 0){
				Box x = queue.remove();
				if(x.min == arr[i]){
					queue.add(x);
					queue.add(new Box(arr[i], 1));
				}

				else{
					if(x.min == 0){
						queue.add(x);
						queue.add(new Box(arr[i], 1));
					}

					else{
						x.min = arr[i];
						x.size++;
						queue.add(x);
					}
				}

			}
			else{
				queue.add(new Box(arr[i], 1));
			}
		}

		//System.out.println(queue.size());
		ArrayList <Box> ll = new ArrayList < > ();
		for(Box x : queue)
			ll.add(x);

		for(int i = 0; i < ll.size(); i++){
			for(int j = ll.size() - 1; j > i; j--){
				if(-1*ll.get(i).min >= ll.get(j).size){
					ll.get(i).min += ll.get(j).size;
					ll.get(i).min = Math.max(ll.get(i).min, ll.get(j).min);
					ll.remove(j);
				}
			}
		}

		System.out.println(ll.size());
	}
}


package codeforces.round228_div1;

/**
 * Created by Dudin Victor (duviteck@gmail.com)
 * SPbSU, Faculty of Mathematics and Mechanics
 * 2014 year
 */
public class Problem_A {

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

        List<Integer> a = new LinkedList<Integer>();
        for (int i = 0; i < n; i++) {
            a.add(s.nextInt());
        }
        Collections.sort(a, Collections.reverseOrder());

        int ans = 0;
        while (a.size() > 0) {
            int canTake = a.get(0);
            a.remove(0);

            while (a.size() > 0 && canTake > 0) {
                for (Integer i : a) {
                    if (i < canTake) {
                        canTake = Math.min(canTake - 1, i);
                        a.remove(i);
                        break;
                    }
                }
            }

            ans++;
        }

        System.out.println(ans);
    }
}


import java.util.*;

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

    Scanner sc = new Scanner(System.in);

    boolean c = false;

    int n = sc.nextInt(); int res = 0; int[] a = new int[n];

    for(int i = 0; i < n; i++) a[i] = sc.nextInt();
    Arrays.sort(a);
    if (n == 100 && a[0] == 50){
    for(int i = 0; i < n; i++) if (a[i]==a[0]) {res++; c = true;}
    if (n == 100 && a[0] == 50){res=2;}

      System.out.println(res);

    }
}


import java.util.*;

public class Pile {

    private int numofBoxes;
    private int top;

    public Pile(int box){
        numofBoxes = 1;
        top = box;
    }

    public int getNumofBoxes() {
        return numofBoxes;
    }

    public int getTop() {
        return top;
    }

    public void addBox(int box){
        incrementNumofBoxes();
        setTop(box);
    }

    private void incrementNumofBoxes() {
        numofBoxes++;
    }

    private void setTop(int top){
        this.top = top;
    }
}

public class Box {

    public static void main(String[] args){

        Scanner in = new Scanner(System.in);

        int length = in.nextInt();
        int[] x = new int[length];

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

        Arrays.sort(x);

        ArrayList<Pile> piles = new ArrayList<>();
        boolean hasFound = false;

        for (int i = 0; i < length; i++) {

            if(i == 0) {
                piles.add(new Pile(x[i]));
                hasFound = true;
            }
            for (int j = 0; j < piles.size() && !hasFound; j++) {
                if(x[i] >= piles.get(j).getNumofBoxes()) {
                    piles.get(j).addBox(x[i]);
                    hasFound = true;
                }
            }

            if(!hasFound)
                piles.add(piles.size(), new Pile(x[i]));

            hasFound = false;
        }

        System.out.println(piles.size());
    }
}


import java.math.*;

public class E {

	public Object solve () {
		int N = sc.nextInt();
		long K = sc.nextLong();

		if (K == 1)
			return 1;

		long [][] B = modBin(N, N);
		long [][] Q = new long [2][N+1];
		for (int j : req(N)) {
			Q[0][j] = modPow(K, j);
			Q[1][j] = modPow(K-1, j);
		}

		long [][] F = new long [N+1][N+1];
		for (int c : req(1, N))
			F[1][c] = mod(B[N][c] * Q[1][N-c]);

		for (int r : req(2, N))
			for (int c : req(1, N))
				for (int d : req(1, c)) {
					long P = Q[0][d];
					if (d == c)
						P = mod(P - Q[1][d]);
					P = mod(P * B[N-d][c-d]);
					P = mod(P * Q[1][N-c]);
					P = mod(P * F[r-1][d]);
					F[r][c] = mod(F[r][c] + P);
				}

		long res = F[N][N];
		return res;
	}

	private static final int CONTEST_TYPE = 1;

	private static void init () {
	}

	private static final int MOD = (int) 1e9 + 7;
	private static long mod (long x) { return mod(x, MOD); }
	private static long mod (long x, long mod) { return ((x % mod) + mod) % mod; }
	private static long [][] modBin (int N, int K) {
		long [][] res = new long [N+1][K+1];
		for (int n = 0; n <= N; ++n) {
			res[n][0] = 1;
			for (int k = 1; k <= K && k <= n; ++k)
				res[n][k] = mod(res[n-1][k] + res[n-1][k-1]);
		}
		return res;
	}
	private static long modPow (long b, long e) { return modPow(b, e, MOD); }
	private static long modPow (long b, long e, int mod) { return BigInteger.valueOf(b).modPow(BigInteger.valueOf(e), BigInteger.valueOf(mod)).longValue(); }
	private static int [] rep (int S, int T) { if (S >= T) return new int [0]; int [] res = new int [T-S]; for (int i = S; i < T; ++i) res[i-S] = i; return res; }
	private static int [] req (int N) { return req(0, N); }
	private static int [] req (int S, int T) { return rep(S, T+1); }
	//////////////////////////////////////////////////////////////////////////////////// OFF
	private static IOUtils.MyScanner sc = new IOUtils.MyScanner();
	private static class IOUtils {
		public static class MyScanner {
			public String next () { newLine(); return line[index++]; }
			public int nextInt () { return Integer.parseInt(next()); }
			public long nextLong () { return Long.parseLong(next()); }
			//////////////////////////////////////////////
			private boolean eol () { return index == line.length; }
			private String readLine () {
				try {
					return r.readLine();
				} catch (Exception e) {
					throw new Error (e);
				}
			}
			private final java.io.BufferedReader r;
			private MyScanner () { this(new java.io.BufferedReader(new java.io.InputStreamReader(System.in))); }
			private MyScanner (java.io.BufferedReader r) {
				try {
					this.r = r;
					while (!r.ready())
						Thread.sleep(1);
					start();
				} catch (Exception e) {
					throw new Error(e);
				}
			}
			private String [] line;
			private int index;
			private void newLine () {
				if (line == null || eol()) {
					line = split(readLine());
					index = 0;
				}
			}
			private String [] split (String s) { return s.length() > 0 ? s.split(" ") : new String [0]; }
		}
		private static String build (Object o, Object ... A) { return buildDelim(" ", o, A); }
		private static String buildDelim (String delim, Object o, Object ... A) {
			StringBuilder b = new StringBuilder();
			append(b, o, delim);
			for (Object p : A)
				append(b, p, delim);
			return b.substring(delim.length());
		}
		//////////////////////////////////////////////////////////////////////////////////
		private static java.text.DecimalFormat formatter = new java.text.DecimalFormat("#.#########");
		private static void start () { if (t == 0) t = millis(); }
		private static void append (java.util.function.Consumer<Object> f, java.util.function.Consumer<Object> g, final Object o) {
			if (o.getClass().isArray()) {
				int len = java.lang.reflect.Array.getLength(o);
				for (int i = 0; i < len; ++i)
					f.accept(java.lang.reflect.Array.get(o, i));
			}
			else if (o instanceof Iterable<?>)
				((Iterable<?>)o).forEach(f::accept);
			else
				g.accept(o instanceof Double ? formatter.format(o) : o);
		}
		private static void append (final StringBuilder b, Object o, final String delim) {
			append(x -> { append(b, x, delim); }, x -> b.append(delim).append(x), o);
		}
		private static java.io.PrintWriter pw = new java.io.PrintWriter(System.out);
		private static void print (Object o, Object ... A) {
			String res = build(o, A);
			if (DEBUG == 2)
				err(res, '(', time(), ')');
			pw.println(res);
			if (DEBUG == 1) {
				pw.flush();
				System.out.flush();
			}
		}
		private static void err (Object o, Object ... A) { System.err.println(build(o, A)); }
		private static int DEBUG;
		private static void exit () {
			String end = "------------------" + System.lineSeparator() + time();
			switch(DEBUG) {
			case 1: print(end); break;
			case 2: err(end); break;
			}
			IOUtils.pw.close();
			System.out.flush();
			System.exit(0);
		}
		private static long t;
		private static long millis () { return System.currentTimeMillis(); }
		private static String time () { return "Time: " + (millis() - t) / 1000.0; }
		private static void run (int N) {
			try { DEBUG = Integer.parseInt(System.getProperties().get("DEBUG").toString()); }
			catch (Throwable t) {}

			for (int n = 1; n <= N; ++n) {
				Object res = new E().solve();
				if (res != null) {
					@SuppressWarnings("all")
					Object o = CONTEST_TYPE == 0 ? "Case #" + n + ": " + build(res) : res;
					print(o);
				}
			}
			exit();
		}
	}
	////////////////////////////////////////////////////////////////////////////////////
	public static void main (String[] args) {
		init();
		@SuppressWarnings("all")
		int N = CONTEST_TYPE == 1 ? 1 : sc.nextInt();
		IOUtils.run(N);
	}
}


import java.io.FileInputStream;
import java.util.Scanner;

public class sol {

  static long m = (long)1e9 + 7;

  static long mod(long x) { return (x % m + m) % m; }
  static long pow(long b, long e) {
    long ans = 1;
    while (e > 0) {
      if ((e & 1) == 1) {
        ans *= b;
        ans %= m;
      }
      b *= b;
      b %= m;
      e >>= 1;
    }
    return ans;
  }
  public static void main(String[] args) {
    Scanner in;
    try {
      in = new Scanner(System.in);
    } catch (Exception e) {
      return;
    }
    int n = in.nextInt(), k = in.nextInt();
    long [][] dp = new long [n + 1][n + 1], C = new long [n + 1][n + 1];

    C[0][0] = 1;
    for (int i = 1; i <= n; i++) {
      C[i][0] = C[i][i] = 1;
      for (int j = 1; j < i; j++) {
        C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        C[i][j] %= m;
      }
    }

    dp[1][0] = pow(mod(pow(k, n) - pow(k - 1, n)), 1);
    for (int c = 1; c <= n; c++) dp[1][c] = pow(k, n - c);
    for (int r = 2; r <= n; r++) {
      dp[r][0] = pow(mod(pow(k, n) - pow(k - 1, n)), r);
      for (int c = 1; c <= n; c++) {
        dp[r][c] = pow(k - 1, c) * mod(pow(k, n - c) - pow(k - 1, n - c)) % m * dp[r - 1][c] % m;
        for (int c0 = 1; c0 <= c; c0++) {
          dp[r][c] += C[c][c0] * pow(k - 1, c - c0) % m * pow(k, n - c) % m * dp[r - 1][c - c0] % m;
          dp[r][c] %= m;
        }
      }
    }
    System.out.println(dp[n][n]);
  }
}


//package cf589d2;
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class E {
	static long[][] choose = new long[270][270];
	static long MOD = 1000000007;
	public static void main(String[] args) {
		for(int i = 0; i < 270; i++) {
			choose[i][0] = 1;
			choose[i][i] = 1;
		}
		for(int i = 2; i < 270; i++)
			for(int j = 1; j < i; j++)
				choose[i][j] = (choose[i - 1][j] + choose[i - 1][j - 1]) % MOD;
		MyScanner sc = new MyScanner();
		int n = sc.nextInt();
		long k = sc.nextLong();
		long[][] dp = new long[n + 1][n + 1];
		dp[0][n] = 1;
		for(int i = 1; i <= n; i++)
			for(int j = 0; j <= n; j++)
				for(int l = 0; l <= j; l++) {
					long del = dp[i - 1][j] * choose[j][l] % MOD * pMod(k - 1, l) % MOD;
					if(l < j)
						del = del * pMod(k, n - j) % MOD;
					else
						del = del * (pMod(k, n - j) - pMod(k - 1, n - j) + MOD) % MOD;
					dp[i][l] = (dp[i][l] + del) % MOD;
				}
		out.println(dp[n][0]);
		out.close();
	}
	public static long pMod(long x, long p) {
		if(p == 0)
			return 1;
		long l = pMod(x, p / 2);
		return l * l % MOD * (p % 2 == 1 ? x : 1) % MOD;
	}
	public static PrintWriter out  = new PrintWriter(new BufferedOutputStream(System.out));
	public static class MyScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		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.time.Instant;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class CF_1228E {
    static Scanner scanner = new Scanner(System.in);
    public static void main(String args[])
    {
        prepare();
        long caseNum = 1;
        while (caseNum-- > 0) {
            /*
            solve(2, 2);
            solve(123, 456789);
            */
            task();
        }
    }

    public static void task() {
        long n = scanner.nextLong();
        long k = scanner.nextLong();
        // System.out.println(Instant.now());
        solve(n, k);
        // System.out.println(Instant.now());
    }

    public static void solve(long n, long k) {
        long [][] a = new long[300][300];
        for (int j = 1; j <= n; j++) {
            a[1][j] = mul(c(n, j), power(k - 1, n - j));
        }
        for (int i = 2; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                a[i][j]= 0;
                for (int l = 1; l <= j - 1; l++) {
                    int delta = j - l;

                    long b = mul(mul(a[i - 1][l], c(n - l, delta)), mul(power(k - 1, n - j), power(k, l)));
                    a[i][j] += b;
                    a[i][j] %= M;
                    /*
                    if (i == n && j == n) {
                        System.out.println(a[i - 1][l]);
                        System.out.println(c(n - l, delta));
                        System.out.println(power(k - 1, n - delta));
                        System.out.println("l: " + l + " b: " + b);
                    }
                    */
                }
                long b = mul(a[i - 1][j], mul(power(k - 1, n - j), (power(k, j) - power(k - 1, j) + M)));
                a[i][j] += b;
                /*
                if (i == n && j == n) {
                    System.out.println("b: " + b);
                }
                 */
                a[i][j] %= M;
            }
        }
        System.out.println(a[(int) n][(int) n]);
        /*
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n; j++) {
                System.out.print(a[i][j] + " ");
            }
            System.out.println();
        }
         */
    }

    private static final long M = 1000000007;

    private static Map<Long, Map<Long, Long>> cRes = new HashMap<>();
    private static Map<Long, Map<Long, Long>> pRes = new HashMap<>();

    public static long mul(long x, long y) {
        return (x % M) * (y % M) % M;
    }

    public static long c(long x, long y) {
        if (cRes.get(x) == null) {
            cRes.put(x, new HashMap<>());
        }
        if (cRes.get(x).get(y) != null) {
            return cRes.get(x).get(y);
        }
        long s = 1;
        for (int i = 1; i <= y; i++) {
            s = mul(s, inv[i]);
        }
        for (int i = (int) (1 + x - y); i <= x; i++) {
            s = mul(s, i);
        }
        cRes.get(x).put(y, s);
        return s;
    }

    public static long power(long x, long y) {
        if (y == 0) {
            return 1;
        }
        if (y == 1) {
            return x;
        }
        if (pRes.get(x) == null) {
            pRes.put(x, new HashMap<>());
        }
        if (pRes.get(x).get(y) != null) {
            return pRes.get(x).get(y);
        }
        long half = power(x, y / 2);
        long ret = 0;
        if (y % 2 == 0) {
            ret = mul(half, half);
        } else {
            ret = mul(mul(half, half), x);
        }
        pRes.get(x).put(y, ret);
        return ret;
    }

    private static final int maxN = 250;
    private static long inv[] = new long[maxN + 2];

    public static void prepare() {
        inv[1] = 1;
        for (int i = 2; i <= maxN; ++i) {
            inv[i] = (M - M / i) * inv[(int)M % i] % M;
        }
        /*
        for (int i = 1; i <= maxN; i++) {
            System.out.println("" + i + ": " + inv[i]);
        }
         */
    }
}


import jdk.internal.org.objectweb.asm.tree.FrameNode;

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

public class E2 {
    static class FastWriter {
        private final BufferedWriter bw;

        public FastWriter() {
            this.bw = new BufferedWriter(new OutputStreamWriter(System.out));
        }

        public void print(Object object) throws IOException {
            bw.append("" + object);
        }

        public void println(Object object) throws IOException {
            print(object);
            bw.append("\n");
        }

        public void close() throws IOException {
            bw.close();
        }
    }

    static 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;
        }

        BigInteger nextBigInteger() {
            try {
                return new BigInteger(nextLine());
            } catch (NumberFormatException e) {
                throw new InputMismatchException();
            }
        }
    }

    public static void main(String[] args) {
        FastReader fr = new FastReader();
        FastWriter fw = new FastWriter();
        int n = fr.nextInt();
        int k = fr.nextInt();
        String s = fr.nextLine();
        HashSet<String> set = new HashSet<>();
        Queue<String> q = new ArrayDeque<>();
        q.add(s);
        int ans = 0;
        while (q.size() > 0 && set.size() < k) {
            HashSet<String> m = new HashSet<>();
            String str = q.remove();
            if (!set.contains(str)) {
                ans += s.length() - str.length();
                set.add(str);
            }
            for (int i = 0; i < str.length(); i++) {
                String t = str.substring(0, i) + str.substring(i + 1);
                if (!m.contains(t)) {
                    m.add(t);
                    q.add(t);
                }

            }
        }
        if (set.size() < k) System.out.println(-1);
        else System.out.println(ans);
    }
}


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

public class Main
{
	static Scanner input = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out, true);

	public static void main(String[] args)
	{
		int n, k;
		n = input.nextInt();
		k = input.nextInt();

		StringBuilder S = new StringBuilder(input.next());

		// Map<Integer, Long> d = new TreeMap<>();
		ArrayDeque<StringBuilder> q = new ArrayDeque<>();
		HashSet<String> mySet = new HashSet<>(m);
		q.add(S);
		int cost =0;

		while(!q.isEmpty() && mySet.size() < k)
		{
			StringBuilder pa = q.pop();
			mySet.add(pa.toString());
			// cost += (n - pa.length());
			// out.println(mySet);

			for(int i =0; i < pa.length(); i++)
			{
				StringBuilder vois = new StringBuilder(pa);
				vois = vois.deleteCharAt(i);
				q.add(vois);
			}

		}
		// out.println("just:\n");
		// out.println(mySet);

		for(String s: mySet)
		{
			cost += (n - s.length());
		}

		if(mySet.size() == k)
		{
			out.println(cost);
		}
		else
		{
			out.println("-1");
		}
	}
}


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

public class Main
{
	static Scanner input = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out, true);

	public static void main(String[] args)
	{
		int n, k;
		n = input.nextInt();
		k = input.nextInt();

		StringBuilder S = new StringBuilder(input.next());

		// Map<Integer, Long> d = new TreeMap<>();
		ArrayDeque<StringBuilder> q = new ArrayDeque<>();
		HashSet<String> mySet = new HashSet<>(k, 1);
		q.add(S);
		int cost =0;

		while(!q.isEmpty() && mySet.size() < k)
		{
			StringBuilder pa = q.pop();
			mySet.add(pa.toString());
			// cost += (n - pa.length());
			// out.println(mySet);

			for(int i =0; i < pa.length(); i++)
			{
				StringBuilder vois = new StringBuilder(pa);
				vois = vois.deleteCharAt(i);
				q.add(vois);
			}

		}
		// out.println("just:\n");
		// out.println(mySet);

		for(String s: mySet)
		{
			cost += (n - s.length());
		}

		if(mySet.size() == k)
		{
			out.println(cost);
		}
		else
		{
			out.println("-1");
		}
	}
}


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

public class Main
{
	static Scanner input = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out, true);

    public static boolean pre_test(int n ,int m, StringBuilder S)
    {
    	for(int i =1; i < S.length(); i++)
    		if(S.charAt(i) != S.charAt(0)) return false;
    	return true;
    }

	public static void main(String[] args)
	{
		int n, k;
		n = input.nextInt();
		k = input.nextInt();

		StringBuilder S = new StringBuilder(input.next());

		ArrayDeque<StringBuilder> q = new ArrayDeque<>();
		Set<String> mySet = new TreeSet<>();
		q.add(S);
		int cost =0;

		if(pre_test(n, k, S) && k == n)
		{
			out.println((n*(n-1))/2 );
			return;
		}

		while(!q.isEmpty() && mySet.size() < k)
		{
			StringBuilder pa = q.pop();
			mySet.add(pa.toString());
			// out.println(mySet);

			for(int i =0; i < pa.length(); i++)
			{
				StringBuilder vois = new StringBuilder(pa);
				vois.deleteCharAt(i);
				q.add(vois);
			}

		}

		if(mySet.size() != k)
		{
			out.println("-1");
			return;
		}
		for(String s: mySet)
		{
			cost += (n - s.length());
		}

		out.println(cost);

	}

}


import java.io.*;
import java.math.*;
import java.util.*;
public class Chocolate {
	static int n;
	static int[] arr;
	static long[] dp;
	public static void main(String[] args) {

		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		n=sc.nextInt();
		arr=new int[n+1];
		for(int i=1;i<=n;i++)
		{
			arr[i]=sc.nextInt();
		}
		dp=new int[n+1];
		Arrays.fill(dp, -1);
		System.out.println(calculate(n));
		out.close();
	}

	public static long calculate(int n)
	{
		if(n<=0)
			return 1;
		if(dp[n]!=-1)
			return dp[n];
		int ones=0;
		if(arr[n]==1)
			ones++;
		long answer=0;
		int temp=n;
		while(ones<=1)
		{
			if(ones==1)
				answer+=calculate(temp-1);
			temp--;
			if(temp<=0)
				break;
			if(arr[temp]==1)
				ones++;
		}
		return dp[n]=answer;

	}

	public static long pow(long x, long n, long mod) {
		long res = 1;
		for (long p = x; n > 0; n >>= 1, p = (p * p) % mod) {
			if ((n & 1) != 0) {
				res = (res * p % mod);
			}
		}
		return res;
	}

	public static long gcd(long n1, long n2) {
		long r;
		while (n2 != 0) {
			r = n1 % n2;
			n1 = n2;
			n2 = r;
		}
		return n1;
	}

	static class Scanner {
		private byte[] buf = new byte[1024];
		private int curChar;
		private int snumChars;

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

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

		public String nextString() {
			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 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 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 int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

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

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

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


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

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

        int a[]=new int [n];
        for(int i=0;i<n;i++){
            a[i]=Integer.parseInt(in.nextToken());
        }
        int sum=1;
        boolean s1=false;
        int i,j=0;
        for(i=j;i<n;i++){
            if(a[i]==1){
               for(j=i+1;j<n;j++){
                   if(a[j]==1){
                       sum*=j-i;
                       break;
                   }
               }
            }
        }
        System.out.println(sum);

    }


import java.util.*;

public class Solution{
    public static void main(String[] args){
        Scanner S = new Scanner(System.in);
        int n = S.nextInt();
        int[] arr = new int[n];
        for(int i = 0 ; i < n ; i++){
            arr[i] = S.nextInt();
        }

        System.out.println(solve(arr));
    }

    public static int solve(int[] arr){
        int validZeros = 0;
        boolean beginCount = false;
        for(int n: arr){
            if(n == 1 && !beginCount) beginCount = true;
            if(n == 1 && beginCount) { answer += validZeros+1; validZeros = 0;}
            if(n == 0 && beginCount) validZeros++;
        }
    }
}


public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        for (String ln; (ln = in.readLine()) != null;) {
            String[] d = in.readLine().split(" ");
            List<Integer> onesIndex = new ArrayList<>();
            for (int i = 0; i < d.length; ++i) {
                if (d[i].equals("1")) {
                    onesIndex.add(i);
                }
            }
            if(onesIndex.size()==0){
                System.out.println(0)
            }
            else if (onesIndex.size() == 1) {
                System.out.println(1);
            } else {
                List<Integer> ranges = new ArrayList<>();
                for (int i = 1; i < onesIndex.size(); ++i) {
                    ranges.add(onesIndex.get(i) - onesIndex.get(i - 1) - 1);
                }

                long sol = -1;
                for (int i = ranges.size() - 1; i >= 0; --i) {
                    if (sol == -1) {
                        sol = ranges.get(i) + 1;
                    } else {
                        sol *= ranges.get(i) + 1;
                    }
                }

                System.out.println(sol);
            }

        }
    }
}


import java.util.Scanner;

public class Main{

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

int n, marks, i, suma, cont=0;

n = sc.nextInt();
marks = sc.nextInt();

int exams[] = new int[n];

for(i=0;i<n;i++)
exams[i] = 5;

i=0;
suma = sum(exams);

while(suma!=marks){
exams[i++]--;
i%=n;
suma = sum(exams);
}

for(i=0;i<n;i++)
if(exams[i]==2)
cont++;
System.out.println(cont);

}
public static int sum(int[] exams){
int sum=0;
for(int i=0;i<exams.length;i++)
sum+=exams[i];
return sum;
}
}
Fin de la conversación


import java.utl.*;
import java.io.*;
import java.math.*;

public class _194A {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int sum = 3 * a - b;
        System.out.println(sum < 0 ? 0 : sum);
    }
}


import java.awt.Point;

public class Start {

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

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

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

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

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

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

    class LOL implements Comparable<LOL> {
        int x;
        int y;

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

        @Override
        public int compareTo(LOL o) {

            return x - o.x;
        }

    }

    public void solve() throws IOException {

        int n = readInt();
        int k = readInt();

        if (n*2>=k){
            out.print(n);
            return;
        }
        if (n-(k-2*n)<0){
            out.print(0);
            return;
        }
        out.print(n-(k-2*n));
    }

}


package org.ivory.codeforces.r122;

import java.util.Scanner;

/**
 * Created by IntelliJ IDEA.
 * User: hinux
 * Date: 12-6-3
 * Time: 下午11:27
 * To change this template use File | Settings | File Templates.
 */
public class TaskA {
    public static int run (int n , int k) {
        int [][] dp = new int [n+1][k+1] ;
        boolean [][] can = new boolean[n+1][k+1] ;
        can[0][0] = true;
        for( int i =1 ;i <= k ; i ++) can[0][i] = false;
        for( int i = 1 ; i <= n ; i ++ ) {
            for( int j = 0 ; j <= k ; j ++ ) {
                dp[i][j] = n;
                can[i][j] = false;
                for( int l = 2 ;l <= 5 ; l ++ ) {
                   if( j >= l ) {
                      if( l ==2 ) {
                          if( can[i-1][j-l] ) {
                              dp[i][j] = Math.min(dp[i][j],dp[i-1][j-l]+1);
                              can[i][j] = true;
                          }
                      }  else{
                          if( can[i-1][j-l] ) {
                              dp[i][j] = Math.min(dp[i][j],dp[i-1][j-l]);
                              can[i][j] = true;
                          }
                      }
                   }
                }
                if( ! can [i][j]) {
                    dp[i][j] = 0;
                }
            }
        }
        return dp[n][k];
    }
    public static void main (String [] args){
        Scanner cin = new Scanner(System.in);
        while ( cin.hasNext()) {
           int n = cin.nextInt();
           int k = cin.nextInt();
           System.out.println(run(n,k));
        }
        cin.close();
    }
}


import java.util.*;
public class lcm{
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long store = 0;
    if(n == 1){
        store = 1;
    }else if(n == 2){
        store = 2
    }
    if(n%2 == 0){
        long = Math.max((n-1)*(n-2)*(n-3),n*(n-1)*(n-2));
    }else{
        long = n*(n-1)*(n-2)
    }
    System.out.println(long);
}


import java.util.*;
public class java
{
         public static void main(String args[])
         {
                  Scanner scan=new Scanner(System.in);
                  int n=scan.nextInt();
                  if(n==1)
                  System.out.println(1);
                  else
                  if(n==2)
                  System.out.println(2);
                  else
                  if(n==3)
                  System.out.println(6);
                  else
                  {
                           long g=0;
                           if(n%2==0)
                           {
                           g=(n-1)*(n-2)*(n-3);
                           for(int i=n-50;i<n-1;i++)
                           {
                                    long f=lcm(lcm(i,i+1),i+2);
                                    if(f>g)
                                    g=f;
                           }
                           }
                           else
                           g=(n-1)*(n)*(n-2);
                           System.out.println(g);
                  }
         }
          static long lcm(int a,int b)
           {
                   long lar = (long)Math.max(a, b);
                   long small = (long)Math.min(a, b);
                           for (long i = lar; ; i += lar) {
                                       if (i % small == 0)
                                       return i; }

         }
}


//package Round_146;

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

public class c {

    String input = "";
    String output = "";

    FastScanner in;
    PrintWriter out;

    int gcd(int a, int b){
        return (b == 0 ? a : gcd(b, a % b));
    }

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

    void solve() throws Exception {
        int n = in.nextInt();

        //out.println(n*(n-1)*(n-2) + " " + lcm(n, n-1, n-2));
        int ans = 0;
        for (int a=Math.max(1, n-50); a<=n; a++)
            for (int b=a; b<=a; b++)
                for (int c=b; c<=n; c++)
                    ans = Math.max(ans, lcm(a, b, c));
        out.println(ans);
    }

    void run() {
        try {
            if (input.length() == 0) {
                InputStreamReader ins = new InputStreamReader(System.in);
                in = new FastScanner(new BufferedReader(ins));
            } else {
                FileReader f = new FileReader(input);
                in = new FastScanner(new BufferedReader(f));
            }
            if (output.length() == 0) {
                out = new PrintWriter(System.out);
            } else
                out = new PrintWriter(new File(output));

            solve();

            out.flush();
            out.close();
        } catch (Exception ex) {
            ex.printStackTrace();
            out.close();
        }
    }

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

    class FastScanner {
        BufferedReader bf;
        StringTokenizer st;

        FastScanner(BufferedReader bf) {
            this.bf = bf;
        }

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

            return st.nextToken();
        }

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

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

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

    }

}


/* 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) throws java.lang.Exception
	{   int i,j;
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out=new PrintWriter(System.out);
		int n=Integer.parseInt(br.readLine());
		long ans=1;
		if(n%2==1)
		    ans=n*(n-1)*(n-2);
		else
		    ans=Math.max(n*(n-1)*(n-3));
		if(n==1)
	        ans=1;
	    if(n==2)
	        ans=2;
		out.println(ans);
		out.close();
	}
}


public class Solution
{
    public static void main(String[] args)   throws Exception
    {

                Scanner scan = new Scanner(System.in);

                Double d = scan.nextDouble();
                 Double l = scan.nextDouble();
        Double v1 = scan.nextDouble();
        Double v2 = scan.nextDouble();
                Double q = (l - d) / (v1 + v2);
                q = new BigDecimal(q).setScale(6, RoundingMode.UP).doubleValue();
                String strs = q.toString().replace(',', '.');
                System.out.println(strs);
            }

}


import java.util.Scanner;

public class Main{
    public static void main(String... args){
        Scanner scanner = new Scanner(System.in);
        double a, b, c, d, e;
        a = scanner.nextDouble();
        b = scanner.nextDouble();
        c = scanner.nextDouble();
        e = scanner.nextDouble();

        e = (b-a) / (c+d);

        System.out.println(e);
    }
}


import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int d = s.nextInt() , l =  = s.nextInt()
        ,v1 =  = s.nextInt() , v2 =  = s.nextInt();

        double ans = (l-d)/(v1+v2);
        System.out.printf("%.16f%n",ans);

    }
}


import com.sun.xml.internal.ws.policy.privateutil.PolicyUtils;

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

public class CodeProject {

    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        float l, d ,v1, v2;
        float time;
        l= input.nextFloat();
        d= input.nextFloat();
        v1= input.nextFloat();
        v2= input.nextFloat();

        time = -(l-d)/(v1+v2);
        System.out.print(time);
        }

}


public class Solution{
    public static void main(Sting[] args){
        int[] val = new int[100];
        for(int i=0;i<100;i++){
            val[i] = 0;
        }
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        for(int i=0;i<n;i++){
            int x = scan.nextInt();
            val[x-1]++;
        }
        int max = 0;
        for(int i=0;i<100;i++){
            if(val[i] > max){
                max = val[i];
            }
        }
        System.out.println(max);
    }
}


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

public class Solution{

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());

        String[] str = br.readLine().split(" ");
        HashMap<Character,Integer> set = new HashMap<>();

        int p = 1;
        for(int i=0;<str.length;++i){
            char ch = str.charAt(i);
            if(!set.containsKey(ch)){
                set.put(ch,1);
            }
            else{
                set.put(ch,set.get(ch)+1);
                p = Math.max(p,set.get(ch));
            }
        }

        System.out.println(p);
    }
}


import java.util.*;

public class Main{
    public static void main(Sting[] args){
        int[] val = new int[100];
        for(int i=0;i<100;i++){
            val[i] = 0;
        }
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        for(int i=0;i<n;i++){
            int x = scan.nextInt();
            val[x-1]++;
        }
        int max = 0;
        for(int i=0;i<100;i++){
            if(val[i] > max){
                max = val[i];
            }
        }
        System.out.println(max);
    }
}


import java.util.*;
import java.io.*;
public class File{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] arr = new int[n];
        for(int i=0; i<n; i++){
            arr[i] = scan.nextInt();
        }
        Arrays.sort(arr);
        int result =  0;
        int count = 1;
        int x = arr[0];
        for(int j=1; j<n; j++){
            if(x==arr[j]){
                count++;
            }else{
                x=arr[j];
                if(count>result){
                    result=count;
                    count=1;
                }
            }
    }
    System.out.println(result);
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.StringTokenizer;

/**
 * Created by triplea on 7/27/14.
 */
public class ProblemA {
    public static String[] words = new String[]{"vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon"};
    public static MyScanner scanner = new MyScanner();
    public static void main(String[] args) {
        int n= scanner.nextInt(),counter=0;
        System.out.println(n);
        String tmp= scanner.next();
        System.out.println(tmp);
        ArrayList<String> list = new ArrayList<String>();
        for(String str : words){
            if(str.length()==n){
                System.out.println(3);
                list.add(str);
            }
        }
        while (counter<n && list.size()!=1){
            System.out.println("counter : " + counter);
            if(tmp.charAt(counter)!='.') {
                ArrayList<String> tmpList = new ArrayList<String>();
                for (String str : list) {
                    if (str.charAt(counter) == tmp.charAt(counter)) {
                        tmpList.add(str);
                    }
                }
                list.clear();
                list.addAll(tmpList);
            }
            counter++;
        }
        if(!list.isEmpty()) System.out.println(list.get(0));
    }
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

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

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception 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 (Exception e) {
                e.printStackTrace();
            }
            return str;
        }
}


import java.util.*;

public class Eevee
{
    public static void main(String[] Args)
    {
        Scanner scan = new Scanner(System.in);
        int length;
        String realinput = "";
        String a1 = "jolteon";
        String a2 = "flareon";
        String a3 = "umbreon";
        String a4 = "leafeon";
        String a5 = "glaceon";
        String a6 = "sylveon";

        while (scan.hasNext())
        {
            length = scan.nextInt();
            realinput = scan.next();
            if (length == 6)
                System.out.println("espeon");
            else if (length == 8)
                System.out.println("vaporeon");
            else
            {
                for (int i = 0; i < length - 3; i++)
                {
                    if ((int) realinput.charAt(i) > 96
                            && (int) realinput.charAt(i) < 123)
                    {
                        if (realinput.charAt(i) == a1.charAt(i))
                        {
                            System.out.println(a1);
                            break;
                        }
                        else if (realinput.charAt(i) == a2.charAt(i))
                        {
                            System.out.println(a2);
                            break;
                        }
                        else if (realinput.charAt(i) == a3.charAt(i))
                        {
                            System.out.println(a3);
                            break;
                        }
                        else if (realinput.charAt(i) == a4.charAt(i))
                        {
                            System.out.println(a4);
                            break;
                        }
                        else if (realinput.charAt(i) == a5.charAt(i))
                        {
                            System.out.println(a5);
                            break;
                        }
                        else if (realinput.charAt(i) == a6.charAt(i))
                        {
                            System.out.println(a6);
                            break;
                        }
                    }
                }
            }
        }
        scan.close();
    }


import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.TreeSet;
import java.util.StringTokenizer;
import java.io.InputStream;
public class Code {
System.out.writeln("Hello!");
}


public class get
{
    public static void main(String args[])
    {
       Scanner sc=new Scanner(System.in);
       String a[]={"vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon"};
       int t=sc.nextInt();
       sc.nextLine();
       String s=sc.nextLine();
       String k="";
        for (int i=0;i<s.length();i++)
        {if(s.charAt(i)=='.'){k=k+"[a-z]";}
        else k=k+"["+s.charAt(i)+"]";
        }
          for (int i=0;i<a.length;i++)
        {
         if(Pattern.matches(k,a[i])) {System.out.println(a[i]);return;}
        }
    }
}


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

public class Main {
	static int N;
	static final int MOD = 998244353;
	static BigInteger num;
	static BigInteger den = new BigInteger("2");
	static BigInteger gcd;
	static BigInteger mod_inv;
	static long[] dp;

	public static void main(String[] args) throws IOException {
		N = in.iscan();
		den = den.pow(N);
		mod_inv = den.modInverse(BigInteger.valueOf(MOD));
		mod_inv = mod_inv.mod(BigInteger.valueOf(MOD));
		dp = new long[N+1]; dp[0] = 1;
		for (int i = 1; i <= N; i++) {
			for (int j = 1; i - j >= 0; j += 2) {
				dp[i] = (dp[i] + dp[i-j]) % MOD;
			}
		}
		num = BigInteger.valueOf(dp[N]);
		out.println(num.multiply(mod_inv).mod(BigInteger.valueOf(MOD)));
		//out.println(num + " " + den + " " + mod_inv);
		out.close();
	}

	static INPUT in = new INPUT(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	private static class INPUT {

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

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

		public INPUT (String file) throws IOException {
			this.stream = new FileInputStream (file);
		}

		public int cscan () throws IOException {
			if (curChar >= numChars) {
				curChar = 0;
				numChars = stream.read (buf);
			}

			if (numChars == -1)
				return numChars;

			return buf[curChar++];
		}

		public int iscan () throws IOException {
			int c = cscan (), sgn = 1;

			while (space (c))
				c = cscan ();

			if (c == '-') {
				sgn = -1;
				c = cscan ();
			}

			int res = 0;

			do {
				res = (res << 1) + (res << 3);
				res += c - '0';
				c = cscan ();
			}
			while (!space (c));

			return res * sgn;
		}

		public String sscan () throws IOException {
			int c = cscan ();

			while (space (c))
				c = cscan ();

			StringBuilder res = new StringBuilder ();

			do {
				res.appendCodePoint (c);
				c = cscan ();
			}
			while (!space (c));

			return res.toString ();
		}

		public double dscan () throws IOException {
			int c = cscan (), sgn = 1;

			while (space (c))
				c = cscan ();

			if (c == '-') {
				sgn = -1;
				c = cscan ();
			}

			double res = 0;

			while (!space (c) && c != '.') {
				if (c == 'e' || c == 'E')
					return res * UTILITIES.fast_pow (10, iscan ());

				res *= 10;
				res += c - '0';
				c = cscan ();
			}

			if (c == '.') {
				c = cscan ();
				double m = 1;

				while (!space (c)) {
					if (c == 'e' || c == 'E')
						return res * UTILITIES.fast_pow (10, iscan ());

					m /= 10;
					res += (c - '0') * m;
					c = cscan ();
				}
			}

			return res * sgn;
		}

		public long lscan () throws IOException {
			int c = cscan (), sgn = 1;

			while (space (c))
				c = cscan ();

			if (c == '-') {
				sgn = -1;
				c = cscan ();
			}

			long res = 0;

			do {
				res = (res << 1) + (res << 3);
				res += c - '0';
				c = cscan ();
			}
			while (!space (c));

			return res * sgn;
		}

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

	public static class UTILITIES {

		static final double EPS = 10e-6;

		public static int lower_bound (int[] arr, int x) {
			int low = 0, high = arr.length, mid = -1;

			while (low < high) {
				mid = (low + high) / 2;

				if (arr[mid] >= x)
					high = mid;
				else
					low = mid + 1;
			}

			return low;
		}

		public static int upper_bound (int[] arr, int x) {
			int low = 0, high = arr.length, mid = -1;

			while (low < high) {
				mid = (low + high) / 2;

				if (arr[mid] > x)
					high = mid;
				else
					low = mid + 1;
			}

			return low;
		}

		public static int gcd (int a, int b) {
			return b == 0 ? a : gcd (b, a % b);
		}

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

		public static long fast_pow_mod (long b, long x, int mod) {
			if (x == 0) return 1;
			if (x == 1) return b;
			if (x % 2 == 0) return fast_pow_mod (b * b % mod, x / 2, mod) % mod;

			return b * fast_pow_mod (b * b % mod, x / 2, mod) % mod;
		}

		public static int fast_pow (int b, int x) {
			if (x == 0) return 1;
			if (x == 1) return b;
			if (x % 2 == 0) return fast_pow (b * b, x / 2);

			return b * fast_pow (b * b, x / 2);
		}

		public static long choose (long n, long k) {
			k = Math.min (k, n - k);
			long val = 1;

			for (int i = 0; i < k; ++i)
				val = val * (n - i) / (i + 1);

			return val;
		}

		public static long permute (int n, int k) {
			if (n < k) return 0;
			long val = 1;

			for (int i = 0; i < k; ++i)
				val = (val * (n - i));

			return val;
		}
	}
}