import java.util.Scanner;

public class fishki
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int M = in.nextInt();
        int result = 0;
        int res = 0;
        for (int i = 1; i < N+1; i++)
        {
                result = result +i;
        }
        for (int i = 0; i < N; i++)
        {
            if(result<M)
            {
                M = M - result;
            }

        }
        result = res;

        result = M-result;
        if(result>0)
        {
            for (int i = 1; i < N+1; i++)
            {
                if(result >= i)
                {
                    result = result-i;
                }
            }
        }
        if(result < 0 )
        {

            for (int i = N; i> 0; i--)
            {   if(result<0)
                {
                result = result + i;
                }
                else
                {
                    break;
                }

            }
        }

        System.out.print(result);
    }

}
import java.util.Scanner;

public class fishki
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int M = in.nextInt();
        int result = 0;
        int res = 0;
        for (int i = 1; i < N+1; i++)
        {
                result = result +i;
        }
        for (int i = 0; i < N; i++)
        {
            if(result<M)
            {
                M = M - result;
            }

        }
        result = res;

        result = M-result;
        if(result>0)
        {
            for (int i = 1; i < N+1; i++)
            {
                if(result >= i)
                {
                    result = result-i;
                }
            }
        }
        if(result < 0 )
        {

            for (int i = N; i> 0; i--)
            {   if(result<0)
                {
                result = result + i;
                }
                else
                {
                    break;
                }

            }
        }

        System.out.print(result);
    }

}


import java.util.Scanner;

public class startGame {

    private int walrus;
    private int chips;

    startGame(int walrus , int chips){
        this.walrus = walrus;
        this.chips = chips;
    }

    public int play(){

        int num=1;
        while(chips >= num){
            chips -= num;
            num++;
            if(num > walrus){
                num = 1;
            }
        }
        return chips;
    }

    import java.util.Scanner;

public class MainClass {

    public static void main(String[]args){
        int n,m;
        Scanner i = new Scanner(System.in);
        n = i.nextInt();
        m = i.nextInt();
        startGame g = new startGame(n, m);
        System.out.println(g.play());
    }

}


import java.util.*;
public class Main{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n,m;
        while(sc.hasNextInt()){
            n = sc.nextInt();
            m = sc.nextInt();
            System.out.println(cal(n,m));
        }

    }
    public int cal(int n.int m)
    {
        int now = 1;
        while(m-now>0)
        {
            if(now>n)
            {
                now = 1;
            }
            m = m-now;
            now++;
        }
        return m;
    }
}


public class Chips {
    public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
     long n,m;
     n=in.nextLong();
     m=in.nextLong();
     int i=1;
    while(m!=0)
    {
        if(m>=i){
       m=m-i;
       i++;}
       else{
            System.out.println(m);
        break;
       }
       if(m==0)
            System.out.println("0");
       if(i>n)
        i=1;
    }

}}


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

public class Main {

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

		new Main().run();
	}

	Scanner sc;
	PrintWriter pr;

	public void run() throws FileNotFoundException{
		sc = new Scanner(System.in);
		pr = new PrintWriter(new File("output.txt"));

	int konf = sc.nextInt();

	int friends = sc.nextInt();

	int count = friends;

	if (konf%friends==0) {
		for (int i = 0; i < friends; i++) {
			System.out.print(konf/friends+" ");
		}
	}
	else{
		for (int i = 0; i < count; i++) {
				if(konf%friends != 0){
				int rizn = konf/friends;
				friends--;
				System.out.print(rizn+" ");
				konf = konf - rizn;}
				if (konf%friends==0) {
				System.out.print(konf/friends+" ");
				}
			}

	}

	}

}


import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner in = new Scanner(System.in);
        int times = 1 , i = 0 ,rest;
        int candies = in.nextInt();
        int friends = in.nextInt();
        int v[] = new int [friends];

        if(candies % friends == 0) {
            while(times < candies/friends) {
                System.out.print(candies/friends +" ");
                times++;
            }
        } else {
            while(i != friends) {
                v[i] = candies/friends;
                i++;
            }
            rest = candies%friends;
            while(rest != 0) {
                v[friends-1] = v[friends-1] + 1;
                friends--;
                rest--;
            }

            for(int j = 0 ; j < v.length ; j++) {
                System.out.print(v[j] +" ");
            }
        }

    }
}

// 1535813429723


import java.util.Scanner;
public class Main{
  public static void main(String[] args) {
    Scanner kb = new Scanner(System.in);
    byte n = kb.nextByte();
    byte m = kb.nextByte();
    byte d = (byte)Math.ceil(1.0*n/m);
    double r = 1.0*n/m - (d-1);
    r = (int)(r*m);
    r = m-r;
    for(byte i = 0; i < m; i++){
      if(r > 0){
        System.out.print(d-1+" ");
        r--;
        }
      else
        System.out.print(d+" ");
    }
  }
}


public class testRound {

    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner vb=new Scanner(System.in);
        int n=vb.nextInt();
        int m=vb.nextInt();
        int i;
        if(n%m==0){
            for(i=0;i<m;i++)
                System.out.print(n/m+" ");
        }
        else{
            if((n+1)%m==0){
                System.out.print((m-1)+" ");
                for(i=0;i<m-1;i++)
                    System.out.print((n+1)/m+" ");
                return;
            }

            if((n-1)%m==0){
                System.out.print(((n/m)+1)+" ");
                for(i=0;i<m-1;i++)
                    System.out.print((n-1)/m+" ");
                return;
            }
            for(i=0;i<m;i++){
                if(i<n%m) System.out.print((n/m+1)+" ");
                else System.out.print((n/m)+" ");
            }

        }
    }

}


import java.io.*;

public class Main{

static final InputStream in=System.in;
static final PrintWriter out=new PrintWriter(System.out);

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(in));
String line="";
lo:
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
line=br.readLine();
char[] q=line.toCharArray();
char rem=q[0];
int[] stnum=new int[n];
stnum[0]=0;
for(int i=1;i<n;i++){
for(int j=stnum[i-1]+1;j<q.length;j++){
if(q[j]!=rem){
rem=q[j];
stnum[i]=j;
break;
}
else if(j==q.length-1){
out.println("NO");
break lo;
}
}
}
out.println("YES");
for(int i=0;i<n;i++){
if(i==n-1) out.println(line.substring(stnum[n-1]));
else out.println(line.substring(stnum[i],stnum[i]));
}
out.flush();
}
}


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

	public void run() throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

		int n = Integer.parseInt(br.readLine().trim());
		char [] arr = br.readLine().trim().toCharArray();

		boolean [] temp = new boolean[26];
		int count = 0;
		List<Integer> list = new ArrayList<Integer>();

		for(int i=0;i<arr.length;i++){
			if(temp[c-'a'])
				continue;
			temp[c-'a']=true;
			count++;
			list.add(i);
		}

		if(count>=n){
			out.println("YES");
			int size = list.size();
			for(int i=0;i<size-1;i++){
				int s = list.get(i);
				int e = list.get(i+1);
				for(int j=s;j<e;j++)
					out.print(arr[j]);
				out.println();
			}
			int s = list.get(size-1);
			for(int i=s;i<arr.length;i++)
				out.print(arr[i]);
			out.flush();
			out.close();
			br.close();
			return;
		}
		out.println("NO");
		out.flush();
		out.close();
		br.close();
	}

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


import DP.prac.IntervalSelection;

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

/**
 * Created by NKumar2 on 12/1/2015.
 */
public class SetOfSttrings {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        HashMap<Character, Integer> charMap = new HashMap<Character, Integer>();

        int n = scn.nextInt();
        String str = scn.next();

        int[] arr = new int[str.length()];
        for (int i = 0; i < str.length(); i++) {
            if(!charMap.containsKey(str.charAt(i)))
            {
                charMap.put(str.charAt(i), i);
                arr[i] = 1;
            }
        }

        if(charMap.size() >= n)
        {
            System.out.println("YES");

            int sidx = 0;
            for (int i = 0; i < n; i++) {
                if(i == n-1)
                {
                    System.out.println(str.substring(sidx, str.length()));
                }
                else
                {
                    StringBuilder sb = new StringBuilder("");

                    sb.append(str.charAt(sidx));
                    sidx++;

                    while(arr[sidx] != 1)
                    {
                        sb.append(str.charAt(sidx));
                        sidx++;
                    }

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

    }
}


public class Main{
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        // Start writing your solution here. -------------------------------------

      /*
      int n      = sc.nextInt();        // read input as integer
      long k     = sc.nextLong();       // read input as long
      double d   = sc.nextDouble();     // read input as double
      String str = sc.next();           // read input as String
      String s   = sc.nextLine();       // read whole line as String

      int result = 3*n;
      out.println(result);                    // print via PrintWriter
      */

        // Stop writing your solution here. -------------------------------------
        out.close();
    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    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 (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

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

    }
    //--------------------------------------------------------
}


import java.util.Scanner;

public class apples {
    public static void main (String args []){
     Scanner s = new Scanner(System.in) ;
        int n =s.nextInt();
        int m = s.nextInt();
        int k =s.nextInt();
        int f[]= new int[n];
        for(int x=0;x<n;++x){
            f[x] = s.nextInt();
        }
        Arrays.sort(f);
        int q =0;
        int z = 1;
        while(k<m){
            --k;
            k+=f[n-z];
            ++z;++q;
            if(z>n){break;}
        }
        if(z>n){
            System.out.println(-1);
        }else {
            System.out.println(q);}

    }
}


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

public class A {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int filtrNum = sc.nextInt();
        int ustrNum = sc.nextInt();
        int freeRozetka = sc.nextInt();
        int rozetka[] = new int[filtrNum];
        for(int i = 0; i < filtrNum; i++){
            rozetka[i] = sc.nextInt();
        }
        Arrays.sort(rozetka);
        int usedFiltrNum = 0;
        int tecPos = filtrNum - 1;
        while(freeRozetka < ustrNum && tecPos >= 0){
            freeRozetka += rozetka[te-Pos] - 1;
            tecPos--;
            usedFiltrNum++;
        }
        System.out.println((tecPos < 0) ? -1 : usedFiltrNum);
    }
}


import java.util.Scanner;

public class apples {
    public static void main (String args []){
     Scanner s = new Scanner(System.in) ;
        int n =s.nextInt();
        int m = s.nextInt();
        int k =s.nextInt();
        int f[]= new int[n];
        for(int x=0;x<n;++x){
            f[x] = s.nextInt();
        }
        Arrays.sort(f);
        int q =0;
        int z = 1;
        while(k<m){
            --k;
            k+=f[n-z];
            ++z;++q;
            if(z==n){break;}
        }
        if(z==n){System.out.println(-1);}

        else {System.out.println(q);}

    }
}


import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.ArrayList;
import java.util.Collections;
import java.lang.Math;

public class Lo {
    static void subsetSums(int []arr, int l, int r, int sum )
    {
        if (l > r)
        {
            System.out.print(sum + " ");
            return;
        }
        subsetSums(arr, l + 1, r,
                   sum + arr[l]);
        subsetSums(arr, l + 1, r, sum);
    }
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      int k = sc.nextInt();
      ArrayList<Integer> A = new ArrayList<Integer>();
      for(int i = 0; i < n; i++){
          A.add(sc.nextInt());
      }
      Collections.sort(A);
      for(int i = 1; i <= k; i++){
          if(A.get(n-1) )
      }
    }
}


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

import java.io.InputStream;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class apples{
	public static void main (String[] args) throws IOException  {
		Scanner sc=new Scanner(System.in);
		long x=sc.nextLong();
		long y=sc.nextLong();
		if(x==y && x!=1  ) {
			System.out.println("NO");
		}
		else {
		 ArrayList<Long> l = new ArrayList<Long>();
		 long remainder=0;
		 for(long i=1 ; i<=1000 ; i++) {
			 remainder=x%i;
			 l.add(remainder);
		 }
		 int k=0;
		 boolean flag=true;

			for(int z=1 ; z<l.size();z++) {

					if(l.get(k)==l.get(z)) {

						flag=false;
						break;
				}
					k++;
			}
			if(flag==true) {
				System.out.println("YES");
			}
			else if (flag==false) {
				System.out.println("NO");
			}
		}

	}
	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 long nextLong() throws IOException {return Long.parseLong(next());}
		public int nextInt() throws IOException {return Integer.parseInt(next());}
		public String nextLine() throws IOException {return br.readLine();}
		public double nextDouble() throws IOException {return Double.parseDouble(next());}
		public boolean ready() throws IOException {return br.ready();}
	}

}

	0


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

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

    static class TaskC {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            long n, k;
            n = in.readInt();
            k = in.readInt();
            boolean[] b = new boolean[1111111];

            if(n==1&&k<3){
                out.print("Yes");
                return;
            }

            else if (k >= n) {
                out.print("No");
                return;
            }

            for (int i = 1; i < 1111111 && i <= k; i++) {
                long mod = n % i;
                if (b[(int) mod]) {
                    out.print("No");
                    return;
                }
                b[(int) mod] = true;
            }
            out.print("Yes");

        }

    }

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

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

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

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

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

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

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

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

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

    }
}


/*
 * 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.BitSet;
import java.util.Scanner;
import java.util.Vector;

/**
 *
 * @author hre doy
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    static int nnn=1000002;
    static int nmn=100000001;
    int prm[];

    Vector<Integer> bitSiv(){
        Vector<Integer> vc;
        prm = new int[nnn];
        vc=new Vector<>();
//        System.out.println(Math.sqrt(nmn));
        int i,j,sqrt=(new Double(Math.sqrt(nmn)).intValue())+1;
//        System.out.println("sqrt"+sqrt);
        for(i=2;i<=sqrt;i++){
            int ind=(int)i/32;
            int bit=(int)i-ind*32;
            if((prm[ind]&(1<<bit))==0){
                vc.add(i);
//                System.out.println(i);
                for(j=i*i;j<nnn*32;j+=i){
                     ind=(int)j/32;
                     bit=(int)j-32*ind;
                    prm[ind]=prm[ind]|(1<<bit);

                }
            }
        }
        for(i=sqrt+1;i<nnn*32;i++){
            int ind=(int)i/32;
            int bit=(int)i-ind*32;
            if((prm[ind]&(1<<bit))==0){
                vc.add(i);
            }
        }
        return vc;
    }
    public static void main(String[] args) {

        double out=0.0;
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong(),k=sc.nextLong();
//        System.out.println(Math.sqrt(n));

        if(n==1) {
            System.out.println("Yes");
            return;
        }
        if(n<=k) {
            System.out.println("No");
            return;
        }
        BigInteger bi=new BigInteger(new Long(n).toString());
        if(bi.isProbablePrime(5)) {
            System.out.println("Yes");
            return;
        }
        Main cdf=new Main();
        Vector<Integer> vv=cdf.bitSiv();
        //System.out.println(vv.get(vv.size()-1));
        boolean f=true;
        for(int t:vv){
            if(t>k) break;
            if(n%t==0) {
                f=false;break;
            }

        }
        if(f) System.out.println("Yes");
        else System.out.println("No");

    }

}


/*
 * 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.BitSet;
import java.util.Scanner;
import java.util.Vector;

/**
 *
 * @author hre doy
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    static int nnn=1000002;
    static int nmn=100000001;
    int prm[];

    Vector<Integer> bitSiv(){
        Vector<Integer> vc;
        prm = new int[nnn];
        vc=new Vector<>();
//        System.out.println(Math.sqrt(nmn));
        int i,j,sqrt=(new Double(Math.sqrt(nmn)).intValue())+1;
//        System.out.println("sqrt"+sqrt);
        for(i=2;i<=sqrt;i++){
            int ind=(int)i/32;
            int bit=(int)i-ind*32;
            if((prm[ind]&(1<<bit))==0){
                vc.add(i);
//                System.out.println(i);
                for(j=i*i;j<nnn*32;j+=i){
                     ind=(int)j/32;
                     bit=(int)j-32*ind;
                    prm[ind]=prm[ind]|(1<<bit);

                }
            }
        }
        for(i=sqrt+1;i<nnn*32;i++){
            int ind=(int)i/32;
            int bit=(int)i-ind*32;
            if((prm[ind]&(1<<bit))==0){
                vc.add(i);
            }
        }
        return vc;
    }
    public static void main(String[] args) {

        double out=0.0;
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong(),k=sc.nextLong();
//        System.out.println(Math.sqrt(n));
        if(n<=k) {
            System.out.println("No");
            return;
        }
        Codeforces cdf=new Codeforces();
        Vector<Integer> vv=cdf.bitSiv();
        //System.out.println(vv.get(vv.size()-1));
        boolean f=true;
        for(int t:vv){
            if(t>k) break;
            if(n%t==0) {
                f=false;break;
            }

        }
        if(f) System.out.println("Yes");
        else System.out.println("No");

    }

}


import java.util.*;
import java.io.*;
 import javafx.util.Pair;

 public class Param
{

      public static  void main( String[]args)
    {

	Scanner param = new Scanner(System.in);
	int x=param.nextInt();
	int y=param.nextInt();
   long x1=func(x,y);
	long x2=func(y,x);
	if(x1<x2){
	   System.out.println("<");
	}
	else if(x1==x2){
	   System.out.println("=")
	}
	else{
	    System.out.println(">");
	}

}
public static long func(int x,int y){

    if(y==0)
        return 1;
    else if(y%2 == 0)
        return func(x*x,y/2);
    else
        return x*func(x*x,(y-1)/2);

}
}


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

public class Main {
    static Scanner in = new Scanner(System.in);

    public static void main(String args) {
        BigInteger x = in.nextBigInteger();
        BigInteger y = in.nextBigInteger();
        BigInteger a = x.power(y);
        BigInteger b = y.power(x);

        if (a.compareTo(b) < 0) {
            System.out.println('<');
        } else if (a.compareTo(b) == 0) {
            System.out.println('=');
        } else {
            System.out.println('>');
        }
    }
}


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

public class Main {
    static Scanner in = new Scanner(System.in);
    public static void main(String args) {
        BigDecimal x = in.nextBigDecimal();
        BigDecimal y = in.nextBigDecimal();

        BigDecimal lhs = y.multiply(x.log());
        BigDecimal rhs = x.multiply(y.log());

        int f = lhs.compareTo(rhs);

        if (f < 0) {
            System.out.println('<');
        } else if (f > 0) {
            System.out.println('>');
        } else {
            System.out.println('=');
        }
    }
}


import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		while(in.hasNext())
		{
			BigDecimal n = in.nextBigDecimal();
			BigDecimal m = in.nextBigDecimal();
			if(n.compareTo(m) == 0){
				System.out.println("=");
				continue;
			}
			BigDecimal x = m.multiply(new BigDecimal(Math.log(n.doubleValue())));
			BigDecimal y = n.multiply(new BigDecimal(Math.log(m.doubleValue())));

//			System.out.println(x + " " + y);
			if(Math.abs(x.subtract(y).doubleValue()) < 1e-1000){
				System.out.println("=");
				continue;
			}
			if(x.compareTo(y) < 0){
				System.out.println("<");
			}
			else System.out.println(">");

		}
	}
}


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

public class Solution {
    static int x1,x2,x3,x4,x5,x6,y1,y2,y3,y4,y5,y6;
    public static int f(int x,int y)
    {   if(x>=x3 && y>=y3 && x<=x4 && y>=y4)
            return 1;
        if(x>=x5 && y>=y5 && x<=x6 && y<=y6)
            return 1;
        return 0;
    }
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String s[]=br.readLine().split(" ");
        x1=Integer.parseInt(s[0]);
        y1=Integer.parseInt(s[1]);
        x2=Integer.parseInt(s[2]);
        y2=Integer.parseInt(s[3]);
        String st[]=br.readLine().split(" ");
        x3=Integer.parseInt(st[0]);
        y3=Integer.parseInt(st[1]);
        x4=Integer.parseInt(st[2]);
        y4=Integer.parseInt(st[3]);
        String str[]=br.readLine().split(" ");
        x5=Integer.parseInt(str[0]);
        y5=Integer.parseInt(str[1]);
        x6=Integer.parseInt(str[2]);
        y6=Integer.parseInt(str[3]);
        for(int i=x1;i<=x2;i+=0.5)
        {   if(f(i,y1)==1)
            {   System.out.print("YES");
                return 0;
            }
            if(f(i,y2)==1)
            {   System.out.print("YES");
                return 0;
            }
        }
        for(int i=y1;i<=y2;i+=0.5)
        {   if(f(x1,i)==1)
            {   System.out.print("YES");
                return 0;
            }
            if(f(x2,i)==1)
            {   System.out.print("YES");
                return 0;
            }
        }
        System.out.print("NO");
        return 0;
    }
}


import java.util.*;
import java.io.*;
import java.awt.Rectangle;
import java.awt.geom.*;

public class whiteSheet {

    public static void main(String[] args) throws FileNotFoundException, IOException {
        InputReader fileIn = new Scanner(System.in);
        PrintWriter fileOut = new PrintWriter(System.out);

		int whiteX1 = fileIn.nextInt();
		int whiteY1 = fileIn.nextInt();
		int whiteX2 = fileIn.nextInt();
		int whiteY2 = fileIn.nextInt();

		int firstX1 = fileIn.nextInt();
		int firstY1 = fileIn.nextInt();
		int firstX2 = fileIn.nextInt();
		int firstY2 = fileIn.nextInt();

		int secondX1 = fileIn.nextInt();
		int secondY1 = fileIn.nextInt();
		int secondX2 = fileIn.nextInt();
		int secondY2 = fileIn.nextInt();

		Rectangle first = new Rectangle(firstX1, firstY1, firstX2 - firstX1, firstY2 - firstY1);
		Rectangle second = new Rectangle(secondX1, secondY1, secondX2 - secondX1, secondY2 - secondY1);
		Rectangle white = new Rectangle(whiteX1, whiteY1, whiteX2 - whiteX1, whiteY2 - whiteY1);

		Area firstArea = new Area(first);
		Area secondArea = new Area(second);
		Area whiteArea = new Area(white);

		whiteArea.subtract(firstArea);
		whiteArea.subtract(secondArea);

		if (whiteArea.isEmpty()) {
		    System.out.println("NO");
		} else {
		    System.out.println("YES");
		}

		fileOut.close();
    }
}


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

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

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

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

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

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

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

        public char nextChar() {
            return next().charAt(0);
        }
    }

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] s = new int[n];
            long sum = 0;
            long max = 0;
            for (int i = 0; i < n; i++) {
                s[i] = in.nextInt();
                sum += s[i];
                if (s[i] > max) {
                    max = s[i];
                }
            }
            int z = max - s[0], a;
            for (int i = 1; i < n; i++) {
                a = max - s[i];
                while (a != 0) {
                    int b = z;
                    z = a;
                    a = b % a;
                }
            }
            out.println((max * n - sum) / z + " " + z);
        }
    }
}


import java.util.Vector;
import java.math.BigInteger;
import java.util.Scanner;
public class TrivialProblem
{
	public static BigInteger factorielleGrandNombre(int n)
	{
		    if(n==0)
		    	return BigInteger.ONE;
		    else
		    	return (BigInteger.valueOf(n)).multiply(factorielleGrandNombre(n-1));
	}
	static BigInteger puiss(int a,int b)
	{
		if(b==0)
			return BigInteger.ONE;
		else
			return (BigInteger.valueOf(a)).multiply(puiss(a,b-1));
	}
	public static void main(String[] args)
	{
		Vector vec = new Vector();
		Scanner clavier=new Scanner(System.in);
		int m=clavier.nextInt();
		int i=0;
		int a=0;
		while ((TrivialProblem.factorielleGrandNombre(i)).subtract(TrivialProblem.puiss(10,m)).cmpareTo(BigInteger.ZERO)==-1)
		    i++;
		while((TrivialProblem.factorielleGrandNombre(i)).remainder(TrivialProblem.puiss(10,m+1))!=BigInteger.ZERO)
		{
		    if((TrivialProblem.factorielleGrandNombre(i)).remainder(TrivialProblem.puiss(10,m))==BigInteger.ZERO)
		    {
			       vec.add (i);
			       a=a+1;
		    }
		    i++;
		}
		if(a!=0)
		{
			System.out.println(a);
			for(int k=0;k<vec.size();k++)
				System.out.print(vec.get(k)+" ");
		}
		else
			System.out.println(a);
	}
}


import java.util.Scanner;

public class Factorial {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int m = in.nextInt();
        int ans = 0;
        int k = log5(m) + 1;
        while (k > 0) {
            m -= coeff(k);
            ans += pow5(k);
            k = log5(m) + 1;
        }
        if (m == 0) {
            System.out.println(5);
            for(int i = 0; i < 4; i++) {
                System.out.print((ans+i) + " ");
            }
            System.out.print(ans+4);
        }
        else {
            System.out.println(0);
        }
        in.close;
    }

    public static int log5(int m) {
        if (m <= 0) {
            return -1;
        }
        else {
            int i = 7, d = 78125;
            while (m < d) {
                d /= 5;
                i--;
            }
            return i;
        }
    }

    public static int coeff(int m) {
        if (m = 1) {
            return 1;
        }
        else {
            return 5*coeff(m-1) + 1;
        }
    }

    public static int pow5(int a) {
        int r = 1;
        while (a > 0) {
            r *= 5;
            a--;
        }
        return r;
    }

}


import java.util.Scanner;

/**
 * Created by Артур on 27.02.2016.
 */
public class MainClass {
    public static void main(String[] args){
        int m=0;
        int x=0;
        int zeros=0;
        Scanner scanner = new Scanner(System.in);

        //System.out.print(logOf5(125));

        m=scanner.nextInt();

       // System.out.print(Math.log(25.0)/Math.log(5.0));

        while (zeros<m){
            x=x+5;
            zeros= (int) (zeros+logOf5(x));
            //1System.out.println(x+" "+zeros);
        }
        if (zeros==m){
            System.out.println(5);
            System.out.print(x+" ");
            for(int i=0; i<4; i++){
                x=x+1;
                System.out.print(x+" ");
            }
        } else {
            System.out.println(0);
        }
    }

    public static int logOf5(int x){
        int otv=0;
        int pokazatel=0;
        int ost=0;
        while (x>=5){
            ost= (int) (x%5);
            if (ost==0){
                otv++;
                pokazatel=1;
            }
            x=x/5;
         //   System.out.print(" "+x+" ");
        }
        if (pokazatel==0){
           // System.out.print("!@#$TYU%R&UY");
            otv=1;
        }
        return otv;
    }
}
close


import java.util.*;
import java.io.*;
import java.math.*;
public final class Solution
{
    public static void main(String[] args)
    {
    	 Reader input = new Reader();
         PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
         int zeros = input.nextInt();
         if(zeros == 0)
        	 out.println(0);
         else
         {
        	 int start = 0;
        	 int low = 5;
        	 int high = Integer.MAX_VALUE;
        	 while(low < high)
        	 {
        		 int mid = (high + low)/2;
        		 int temp = z(mid);
        		 if(temp == zeros)
        		 {
        			 start = mid;
        			 break;
        		 }
        		 else if(temp > zeros)
        		 {
        			 high = mid - 1;
        		 }
        		 else
        			 low = mid + 1;
        	 }
        	 if(start == 0)
        	 {
        		 out.println(0);
        		 out.close();
        		 return;
        	 }
        	 out.println(5);
        	 start = start / 5 * 5;
             for(int i = 0 ; i < 5 ; i++)
            	 out.print(start + i + " ");
         }
		 out.close();
    }


import java.io.*;
import java.math.*;
import java.security.KeyStore.Entry;
import java.util.*;
/*
                                                                yash jobanputra
                                                                    DA-IICT
*/
public class Main {
    private static InputStream stream;
    private static byte[] buf = new byte[1024];
    private static int curChar;
    private static int numChars;
    private static SpaceCharFilter filter;
    private static PrintWriter pw;
    private static long mod = 1000000000 + 7;
    private static long mod1 = 1000000000 + 9;
    private static int MAX=1000001;
    private static int block;
   // private static int[] level;
    private static long[] cost;
    private static long[] costm;
    private static int times;
    private static long ans;
    private static long max;
    private static boolean[] vis;
    private static long[] sa;
    private static long count;
    private static boolean ff;
    private static int odd;
    private static int even;
    private static ArrayList<Integer> ansa;
    private static long[] dp;
    private static long[][] dp2;
    private static int n;
    private static ArrayList<Integer>[] g;
    private static long time;
    private static int[] di;
    private static int[] en;
    private static int[] level;
    private static int[] prime={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
    public static void soln()
    {
    	int n=ni();int k=ni();
    	int[] arr=nia(n);
    	int e=0;int s=0;HashSet<Integer> set=new HashSet<>();
    	int te=0;int ts=0;
    	for(int i=0;i<n;i++)
    	{
    		if(arr[i]==1)	te++;
    		else	ts++;
    	}
    	int a=0;
    	for(int i=0;i<n;i++)
    	{
    		e=0;s=0;HashSet<Integer> ss=new HashSet<>();
    		for(int j=-n;j<n;j++)
    		{
    			int x=i+j*k;
    			if(x>=0 && x<n && !ss.contains(x))
    			{
    				ss.add(x);
    				if(arr[x]==1)	e++;
    				else	s++;
    			}
    		}
    		a=Math.max(a,Math.abs((te-e)-(ts-s)));
    	}
    	pl(a);
    }
    public static void dfs(ArrayList<Integer>[] gr,int v)
    {
         vis[v]=true;
         ArrayList<Integer> arr=gr[v];
         for(int i=0;i<arr.size();i++)
         {
             if(!vis[arr.get(i)])
             {
            	 if(gr[arr.get(i)].size()==1)
            		 {level[v]++;}
            	 dfs(gr,arr.get(i));
             }
         }
    }
    public static void dfs2(ArrayList<Integer>[] gr,int v)
    {
         vis[v]=true;
         time++;
         di[v]=time;
         ArrayList<Integer> arr=gr[v];
         for(int i=0;i<arr.size();i++)
         {
             if(!vis[arr.get(i)])
             {
            	 level[arr.get(i)]=level[v]+1;
            	 dfs2(gr,arr.get(i));
             }
         }
         time++;en[v]=time;
     }
    public static void dfsp(ArrayList<Pair>[] gr,int v,int[] a)
    {
        vis[v]=true;
        ArrayList<Pair> arr=gr[v];
        for(int i=0;i<arr.size();i++)
        {
            if(!vis[arr.get(i).v])
            {
            		dfsp(gr,arr.get(i).v,a);
           	}
        }
    }
    public static class lca{
    	int[] e;
    	int[] l;
    	int[] h;
    	int[] level;
    	boolean[] vis;
    	int time;
    	int[] tree=new int[10000000];
        int[] lazy=new int[10000000];
        int n;
    	public lca(ArrayList<Integer>[] g)
    	{
    		n=g.length-1;
    		pw.println(n);
    		e=new int[2*n];
    		l=new int[2*n];
    		h=new int[n+1];
    		vis=new boolean[n+1];
    		level=new int[n+1];
    		level[1]=0;
    		dfs(g,1);
    		Arrays.fill(lazy, 0);
    		build(l,0,0,2*n-1);
    	}
    	public int lf(int u,int v)
    	{
    		int a=h[u];int b=h[v];
    		if(h[u]>h[v])
    			{a=h[v];b=h[u];}
    		int p=query(l,0,0,2*n-1,a,b);
    		return e[p];
    	}
    	public void dfs(ArrayList<Integer>[] gr,int v)
        {
             vis[v]=true;
             time++;
             e[time]=v;
             l[time]=level[v];
             h[v]=time;
             ArrayList<Integer> arr=gr[v];
             for(int i=0;i<arr.size();i++)
             {
                 if(!vis[arr.get(i)])
                 {
                	 level[arr.get(i)]=level[v]+1;
                	 dfs(gr,arr.get(i));
                	 time++;e[time]=v;l[time]=level[v];
                 }
             }
         }
    	 public void build(int[] arr,int node,int l,int r)
         {
             if(l==r)
             {
                 tree[node]=l;
             }
             else
             {
                 int m=(l+r)/2;
                 build(arr,(2*node)+1,l,m);
                 build(arr,(2*node)+2,m+1,r);
                 if(arr[tree[2*node+1]]<arr[tree[2*node+2]])
                	 tree[node]=tree[2*node+1];
                 else
                	 tree[node]=tree[2*node+2];
             }
         }
    	 public int query(int[] arr,int node,int l,int r,int s,int e)
         {
             if(e<l || r<s)
                 return -1;
             if(s<=l && e>=r)
                 return tree[node];
             int m=(l+r)/2;
             int p1=query(arr,(2*node+1),l,m,s,e);
             int p2=query(arr,(2*node+2),m+1,r,s,e);
             if(p1==-1)
            	 return p2;
             else if(p2==-1)
            	 return p1;
             else
             {
            	 if(arr[p1]<arr[p2])
            		 return p1;
            	 else
            		 return p2;
             }
         }
    }
    public static long[] reverse(long[] arr, int l, int r)
      {
          int d = (r-l+1)/2;
          for(int i=0;i<d;i++)
          {
             long t = arr[l+i];
             arr[l+i] = arr[r-i];
             arr[r-i] = t;
          }
          return arr;
      }
    private static class graph{
        public static void arti(boolean[] ap,int[] parent,int[] disc,int[] low,ArrayList<Integer>[] gr,boolean[] vis,int ver)
        {
            int child=0;
            vis[ver]=true;
            ArrayList<Integer> arr=gr[ver];
            times++;
            disc[ver]=low[ver]=times;
            for(int i=0;i<arr.size();i++)
            {
                if(!vis[arr.get(i)])
                {
                    child++;
                    parent[arr.get(i)]=ver;
                    arti(ap,parent,disc,low,gr,vis,arr.get(i));
                    low[ver]=Math.min(low[ver], low[arr.get(i)]);
                    if(parent[ver]!=0 && low[arr.get(i)]>=disc[ver])
                        ap[ver]=true;
                    if(parent[ver]==0 && child>1)
                        ap[ver]=true;
                }
                else if(parent[ver]!=arr.get(i))
                    low[ver]=Math.min(low[ver], disc[arr.get(i)]);
            }
        }
        public static void floyd(Pair[] arr,int n,int m,int[][] dist)
        {
            for(int i=0;i<=n;i++)
            {
                Arrays.fill(dist[i], Integer.MAX_VALUE);
            }
            for(int c=0;c<m;c++)
            {
                int w=arr[c].v;
                int a=arr[c].j.v;
                int b=arr[c].j.i;
                dist[a][b]=w;
            }
            for(int i=0;i<=n;i++)
                dist[i][i]=0;
            for(int k=1;k<=n;k++)
            {
                for(int i=1;i<=n;i++)
                {
                    for(int j=1;j<=n;j++)
                    {
                        if(dist[i][k]!=Integer.MAX_VALUE && dist[k][j]!=Integer.MAX_VALUE)
                        dist[i][j]=Math.min(dist[i][j], dist[i][k]+dist[k][j]);
                    }
                }
            }
        }
        public static boolean bfs(ArrayList<Integer>[] gr,int v,int n)
        {

            boolean[] vis=new boolean[n+1];
            int c2=0;
            Queue<Integer> q=new LinkedList<>();
            q.add(v);
            while(!q.isEmpty())
            {
                int x=q.poll();
                Iterator<Integer> it=gr[x].iterator();
                while(it.hasNext())
                {
                    int p=it.next();
                    if(!vis[p])
                    {
                        q.add(p);
                        c2++;
                        vis[p]=true;
                    }
                }
            }
            return c2==n;
        }
        public static ArrayList<Pair> MSTP(int n,int m,ArrayList<Pair>[] arr,int[][] arr2)
        {
            ArrayList<Pair> pp=new ArrayList<>();
            int[] par=new int[n+1];
            int[] key=new int[n+1];
            vis=new boolean[n+1];
            Arrays.fill(key, Integer.MAX_VALUE);
            key[1]=0;
            PriorityQueue<Integer> dis=new PriorityQueue<>(n+1,
                    new Comparator<Integer>()
                    {
                        public int compare(Integer p,Integer q)
                        {
                        return key[p]-key[q];
                        }
                    }
                    );
            dis.add(1);
            vis[1]=true;
            while(!dis.isEmpty())
            {
                //pw.println(dis);
                int u=dis.poll();
                    ArrayList<Pair> p=arr[u];
                    for(int i=0;i<p.size();i++)
                    {
                        if(key[u]+p.get(i).i<key[p.get(i).v])
                        {
                            key[p.get(i).v]=key[u]+p.get(i).i;
                            par[p.get(i).v]=u;
                            if(!vis[p.get(i).v])
                            {
                                dis.add(p.get(i).v);
                                vis[p.get(i).v]=true;
                            }
                        }
                    }
            }
            for(int i=1;i<=n;i++)
                pp.add(new Pair(i,par[i]));
            return pp;
        }
        public static ArrayList<Pair> MSTK(int n,int m,Pair[] arr)
        {
            ArrayList<Pair> pp=new ArrayList<>();
            long sum=0;
            Arrays.sort(arr);
            DSU x=new DSU(n+1);
            for(int c=0;(c<m);c++)
            {
                Pair p=arr[c];
                //int a=p.v;
                //int b=p.i;
                int a=p.j.v;
                int b=p.j.i;
                int w=p.v;
                if(x.find(a)!=x.find(b))
                {
                    pp.add(new Pair(w,new Pair(a,b)));
                    x.Union(a, b);
                }
            }
            return pp;
        }
        public static int[] dijkstras(ArrayList<Pair>[] gr)
        {
            int n=gr.length-1;
            int[] dist=new int[n+1];
            Arrays.fill(dist, Integer.MAX_VALUE);

            PriorityQueue<Integer> dis=new PriorityQueue<>(n+1,
                    new Comparator<Integer>()
                    {
                        public int compare(Integer p,Integer q)
                        {
                        return dist[p]-dist[q];
                        }
                    }
                    );
            boolean[] vis=new boolean[n+1];
            Arrays.fill(vis, false);

            int s=1;
            dist[s]=0;
            dis.add(s);
            vis[s]=true;
            while(!dis.isEmpty())
            {
                int p=dis.poll();
                for(int i=0;i<gr[p].size();i++)
                {
                    int y=gr[p].get(i).v;
                    int w=gr[p].get(i).i;
                    if(!vis[y])
                    {
                        dist[y]=dist[p]+w;
                        dis.add(y);
                        vis[y]=true;
                    }
                    else
                    {
                        if(dist[p]+w<dist[y])
                        {
                            dist[y]=dist[p]+w;
                        }
                    }
                }
            }
            return dist;
        }
    }

    public static class sieve{
        public static ArrayList<Integer> sieves(int n)
        {
            ArrayList<Integer> arr=new ArrayList<>();
            boolean[] bol=new boolean[n+1];
            Arrays.fill(bol, true);
            //arr.add(1);
            for(int i=2;i<=n;i++)
            {
                if(bol[i])
                {
                    arr.add(i);
                    for(int j=2;j*i<=n;j++)
                    {
                        bol[i*j]=false;
                    }
                }
            }
            return arr;
        }
    }
    public static class isprime{
        public static boolean check(int n)
        {
            if(n==2)
                return true;
            else if(n==3)
                return true;
            else if(n%2==0)
                return false;
            else if(n%3==0)
                return false;
            else
            {
                for(int i=6;;i+=6)
                {
                    if(i>Math.sqrt(n))
                        break;
                    if(n%(i-1)==0)
                    {
                        return false;
                    }
                    else if(n%(i+1)==0)
                        return false;
                                    }
                return true;
            }
        }
    }
    private static class DSU{
        int[] parent;
        int[] rank;
        int cnt;
        public DSU(int n){
            parent=new int[n];
            rank=new int[n];
            for(int i=0;i<n;i++){
                parent[i]=i;
                rank[i]=1;
            }
            cnt=n;
        }
        int find(int i){
            while(parent[i] !=i){
                parent[i]=parent[parent[i]];
                i=parent[i];
            }
            return i;
        }
        int Union(int x, int y){
            int xset = find(x);
            int yset = find(y);
            if(xset!=yset)
                cnt--;
            if(rank[xset]<rank[yset]){
                parent[xset] = yset;
                rank[yset]+=rank[xset];
                rank[xset]=0;
                return yset;
            }else{
                parent[yset]=xset;
                rank[xset]+=rank[yset];
                rank[yset]=0;
                return xset;
            }
        }
    }
    private static class Pair2 implements Comparable<Pair2>{
        int v,i;Pair j;
        public Pair2(int a,int b){
            v=a;
            i=b;
        }
        public Pair2(int a,Pair b)
        {
            v=a;
            j=b;
        }
        @Override
        public int compareTo(Pair2 arg0) {
            {
            	if(this.v!=arg0.v)
            		return this.v-arg0.v;
            	else
            		return this.i-arg0.i;
            }
        }
    }
    private static class Pair implements Comparable<Pair>{
        int v,i;Pair j;
        public Pair(int a,int b){
            v=a;
            i=b;
        }
        public Pair(int a,Pair b)
        {
            v=a;
            j=b;
        }
        @Override
        public int compareTo(Pair arg0) {
            {
            	if(this.j.v!=arg0.j.v)
            		return this.j.v-arg0.j.v;
            	else
            		return this.j.i-arg0.j.i;
            }
        }
    }
    private static class Pairl implements Comparable<Pairl>{
        long v,i;Pairl j;
        public Pairl(long a,long b){
            v=a;
            i=b;
        }
        public Pairl(long a,Pairl b)
        {
            v=a;
            j=b;
        }
        @Override
        public int compareTo(Pairl arg0) {
            {
                if(this.v>arg0.v)
                    return 1;
                else
                    return -1;
            }
        }
    }
    public static long f(long number,long m) {
          if (number <= 1) return 1;
          else return (number * f(number - 1,m))%m;
       }
    public static long mmi(long a, long m)
    {
        long m0 = m;
        long y = 0, x = 1;

        if (m == 1)
          return 0;

        while (a > 1)
        {
            // q is quotient
            long q = a / m;
            long t = m;

            // m is remainder now, process same as
            // Euclid's algo
            m = a % m; a = t;
            t = y;

            // Update y and x
            y = x - q * y;
            x = t;
        }

        // Make x positive
        if (x < 0)
           x += m0;

        return x;
    }
    public static class segtree{
        int[] tree=new int[10000000];
        int[] lazy=new int[10000000];
        public segtree()
        {
            Arrays.fill(lazy, 0);
        }
        public void build(int[] arr,int node,int l,int r)
        {
            if(l==r)
            {
                tree[node]=arr[l];
            }
            else
            {
                int m=(l+r)/2;
                build(arr,(2*node)+1,l,m);
                build(arr,(2*node)+2,m+1,r);
                tree[node]=tree[2*node+1]+tree[(2*node)+2];
            }
        }
        public void updater(int[] arr,int node,int l,int r,int s,int e,int val)
        {
            if(lazy[node]!=0)
            {
                tree[node]+=(r-l+1)*lazy[node];
                if(l!=r)
                {
                    lazy[2*node+1]+=lazy[node];
                    lazy[2*node+2]+=lazy[node];
                }
                lazy[node]=0;
            }
            if(s<=l && e>=r)
            {
                tree[node]+=(r-l+1)*val;
                if(l!=r)
                {
                    lazy[2*node+1]+=val;
                    lazy[2*node+2]+=val;
                }
            }
            else if(!(e<l || r<s))
            {
                int m=(l+r)/2;
                updater(arr,2*node+1,l,m,s,e,val);
                updater(arr,2*node+2,m+1,r,s,e,val);
                tree[node]=tree[2*node+1]+tree[2*node+2];
            }
        }
        public void update(int[] arr,int node,int l,int r,int ind,int val)
        {
            if(l==r)
            {
                arr[ind]+=val;
                tree[node]+=val;
            }
            else
            {
                int m=(l+r)/2;
                if(l<=ind && ind<=m)
                {
                    update(arr,(2*node+1),l,m,ind,val);
                }
                else
                {
                    update(arr,(2*node+2),m+1,r,ind,val);
                }
                tree[node]=tree[2*node+1]+tree[2*node+2];
            }
        }
        public int query(int node,int l,int r,int s,int e)
        {
            if(lazy[node]!=0)
            {
                tree[node]+=(r-l+1)*lazy[node];
                if(l!=r)
                {
                    lazy[2*node+1]+=lazy[node];
                    lazy[2*node+2]+=lazy[node];
                }
                lazy[node]=0;
            }
            if(e<l || r<s)
                return 0;
            if(s<=l && e>=r)
                return tree[node];
            int m=(l+r)/2;
            int p1=query((2*node+1),l,m,s,e);
            int p2=query((2*node+2),m+1,r,s,e);
            return (p1+p2);
        }
    }

    private static long pow(long a, long b, long c) {
        if (b == 0)
            return 1;
        long p = pow(a, b / 2, c);
        p = (p * p) % c;
        return (b % 2 == 0) ? p : (a * p) % c;
    }
    private static long gcd(long n, long l) {
        if (l == 0)
            return n;
        return gcd(l, n % l);
    }
    private static int gcd(int n, int l) {
        if (l == 0)
            return n;
        return gcd(l, n % l);
    }
    private static long max(long a, long b) {
        if (a > b)
            return a;
        return b;
    }
    private static long min(long a, long b) {
        if (a < b)
            return a;
        return b;
    }
    public static void merge(int arr[], int l, int m, int r)
    {
        // Find sizes of two subarrays to be merged
        int n1 = m - l + 1;
        int n2 = r - m;

        /* Create temp arrays */
        int L[] = new int [n1];
        int R[] = new int [n2];

        /*Copy data to temp arrays*/
        for (int i=0; i<n1; ++i)
            L[i] = arr[l + i];
        for (int j=0; j<n2; ++j)
            R[j] = arr[m + 1+ j];

        /* Merge the temp arrays */

        // Initial indexes of first and second subarrays
        int i = 0, j = 0;

        // Initial index of merged subarry array
        int k = l;
        while (i < n1 && j < n2)
        {
            if (L[i] <= R[j])
            {
                arr[k] = L[i];
                i++;
            }
            else
            {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        /* Copy remaining elements of L[] if any */
        while (i < n1)
        {
            arr[k] = L[i];
            i++;
            k++;
        }

        /* Copy remaining elements of R[] if any */
        while (j < n2)
        {
            arr[k] = R[j];
            j++;
            k++;
        }
    }
    public static void merge(long arr[], int l, int m, int r)
    {
        // Find sizes of two subarrays to be merged
        int n1 = m - l + 1;
        int n2 = r - m;

        /* Create temp arrays */
        long L[] = new long [n1];
        long R[] = new long [n2];

        /*Copy data to temp arrays*/
        for (int i=0; i<n1; ++i)
            L[i] = arr[l + i];
        for (int j=0; j<n2; ++j)
            R[j] = arr[m + 1+ j];

        /* Merge the temp arrays */

        // Initial indexes of first and second subarrays
        int i = 0, j = 0;

        // Initial index of merged subarry array
        int k = l;
        while (i < n1 && j < n2)
        {
            if (L[i] <= R[j])
            {
                arr[k] = L[i];
                i++;
            }
            else
            {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        /* Copy remaining elements of L[] if any */
        while (i < n1)
        {
            arr[k] = L[i];
            i++;
            k++;
        }

        /* Copy remaining elements of R[] if any */
        while (j < n2)
        {
            arr[k] = R[j];
            j++;
            k++;
        }
    }
    public static void sort(long arr[])
    {
    	sort(arr,0,arr.length-1);
    }
    public static void sort(int arr[])
    {
    	sort(arr,0,arr.length-1);
    }
    public static void sort(int arr[], int l, int r)
    {
        if (l < r)
        {
            // Find the middle point
            int m = (l+r)/2;

            // Sort first and second halves
            sort(arr, l, m);
            sort(arr , m+1, r);

            // Merge the sorted halves
            merge(arr, l, m, r);
        }
    }
    public static void sort(long arr[], int l, int r)
    {
        if (l < r)
        {
            // Find the middle point
            int m = (l+r)/2;

            // Sort first and second halves
            sort(arr, l, m);
            sort(arr , m+1, r);

            // Merge the sorted halves
            merge(arr, l, m, r);
        }
    }
    public static void main(String[] args) throws Exception {
        new Thread(null,new Runnable(){
            @Override
            public void run() {
            	/*try {
                    InputReader(new FileInputStream("input.txt"));
                } catch (FileNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }*/
                InputReader(System.in);
                pw = new PrintWriter(System.out);
                /*try {
                    pw=new PrintWriter(new FileOutputStream("output.txt"));
                } catch (FileNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }*/
                soln();
                pw.close();
            }
        },"1",1<<26).start();
    }

    public static void InputReader(InputStream stream1) {
        stream = stream1;
    }

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

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

    private static 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++];
    }

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

    private static long nl() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }
    private static double nd()
    {
        double ret = 0, div = 1;
        int c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    }
    private static String nextToken() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

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

    private static int[] nia(int n) {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = ni();
        }
        return arr;
    }

    private static long[] nla(int n) {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = nl();
        }
        return arr;
    }

    private static void pa(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            pw.print(arr[i] + " ");
        }
        pw.println();
        return;
    }

    private static void pa(long[] arr) {
        for (int i = 0; i < arr.length; i++) {
            pw.print(arr[i] + " ");
        }
        pw.println();
        return;
    }
    private static void pl(int a)
    {
    	pw.println(a);
    }
    private static void pl(long a)
    {
    	pw.println(a);
    }
    private static void p(int a)
    {
    	pw.print(a+" ");
    }
    private static void p(long a)
    {
    	pw.print(a+" ");
    }
    private static boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return isWhitespace(c);
    }
    private static char nc() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        char c1=(char)c;
        while(!isSpaceChar(c))
            c=read();
        return c1;
    }
    public String ns() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }
    private interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}


public class Main {

    public static void main(String[] args) {
	    Scanner in = new Scanner(System.in);
	    int n = in.nextInt();
	    int k = in.nextInt();
	    int[] tabs = new int[n];
	    for(int i = 0; i < n; i++) {
	        tabs[i] = in.nextInt();
        }
	    int max = 0;
	    for(int b = 0; b < tabs.length; b++) {
	    	int s = b;
	    	while(s >= 0) s-=k;
	    	s+=k;
	        int[] tabs1 = tabs.clone();
	        for(int i = s; i < tabs1.length; i += k) {
	            tabs1[i] = 0;
            }
	        int val = 0;
	        for(int i = 0; i < tabs1.length; i++) {
	            val += tabs1[i];
            }
	        max = Math.max(max, Math.abs(val));
        }
	    System.out.println(max);
    }
}


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

public class simple
{
	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;
        }
    }
	public static void main(String args[])
	{
		int n =input.nextInt();
		int[] arr = new int[n];
		int k  =input.nextInt();
		int o1=0,e1=0;
		int ans=Integer.MIN_VALUE;
		for(int i=0;i<n;i++)
		{
			arr[i]  = input.nextInt();
			if(arr[i]==-1)
				o1++;
			else
				e1++;
		}
		for(int i=0;i<k;i++)
		{
			int o=0,e=0;
			for(int j=i;j<n;j=j+k)
			{
				if(arr[j]==-1)
					o++;
				else
					e++;
			}

			if(Math.abs(o1-e1-o+e)>ans)
				ans=Math.abs(o1-e1-o+e);
		}
		System.out.println(ans);
	}
}


public class A_RomanAndBrowser {
    private static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) throws IOException {
        Integer n = scanner.nextInt();
        Integer k = scanner.nextInt();

        int types[] = new int[n];
        int totalSum = 0;

        for (int i = 0; i < n; i++) {
            int type = scanner.nextInt();
            types[i] = type;
            totalSum += type;
        }

        int maxDiff = 0;
        for (int start = 0; start < k; start++) {
            int currSum = totalSum;
            for (int i = 0; start + (i*k) < n; i++) {
                currSum -= types[start + (i*k)];
            }

            currSum = Math.abs(currSum);
            if (currSum > maxDiff) maxDiff = currSum;
        }

        System.out.println(maxDiff);
    }
}


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

public class Solution {
    public static void main(String[] args) throws IOException {
        new Solution().run();
    }
    StringTokenizer tok;
    BufferedReader reader;
    PrintWriter out;
    void run() throws IOException {
        reader = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        reader = new BufferedReader(new FileReader(new File("input.txt")));
        //out = new PrintWriter(new File("output.txt"));
        tok = null;
        solve();
        out.close();
    }
    String nextString() throws IOException {
        while(tok == null || !tok.hasMoreTokens()){
            tok = new StringTokenizer(reader.readLine());
        }
        return tok.nextToken();
    }
    int nextInt() throws IOException {
        return Integer.parseInt(nextString());
    }
    long nextLong() throws IOException {
        return Long.parseLong(nextString());
    }
    double nextDouble() throws IOException {
        return Double.parseDouble(nextString());
    }

    int c3,c4,c5,s;
    boolean ok(int k3,int k4,int k5){
        //assert c3*k3+c4*k4+c5*k5==s;
        //assert (0<=k3 && k3<=k4 && k4<=k5);
        if (c3*k3+c4*k4+c5*k5!=s) return false;
        if (!(0<=k3 && k3<=k4 && k4<=k5)) return false;
        return true;
    }
    int min_ans = Integer.MAX_VALUE;
    int v3,v4,v5;
    void update(int k3,int k4,int k5){
        if (!ok(k3,k4,k5)) return;
        int ans = Math.abs(c3*k3-c4*k4)+Math.abs(c4*k4-c5*k5);
        if (ans < min_ans){
            min_ans = ans;
            v3=k3;
            v4=k4;
            v5=k5;
        }
    }
    //k*b>=a ----> k>=a/b
    int div_ge(int a,int b){
        if (b<0){a=-a;b=-b;}
        if (a<=0) return a/b;
        //k*b >= a
        if (a%b==0) return a/b;
        return a/b+1;
    }
    //k*b<=a ----> k<=a/b
    int div_le(int a,int b){
        if (b<0){a=-a;b=-b;}
        if (a>=0)return a/b;
        //k*b <= -a
        if (a%b==0) return a/b;
        return a/b-1;
    }
    int gx,gy;
    int gcdex(int a,int b){
        if (a==0){
            gx=0;
            gy=1;
            return b;
        }
        else{
            int g = gcdex(b%a,a);
            int x1=gx,y1=gy;
            gx=y1-(b/a)*x1;
            gy=x1;
            return g;
        }
    }
    void tryfind(int k4){
        int a = c3;
        int b = c5;
        int c = s-c4*k4;
        int g = gcdex(Math.abs(a),Math.abs(b));
        if (c%g!=0) return;
        gx*=c/g;
        gy*=c/g;
        if (a<0) gx*=-1;
        if (b<0) gy*=-1;
        int ag = a/g;
        int bg = b/g;
        int min_k = Integer.MIN_VALUE;
        int max_k = Integer.MAX_VALUE;
        {
            //общие ограничения на 0<=k3<=k5<=s
            int k_ge = div_ge(-gx,bg);//0<=k3
            int k_le = div_le(k4-gx,bg);//k3<=k4
            int k_le2 = div_le(gy-k4,ag);//k4<=k5
            int k_ge2 = div_ge(gy-s,ag);//k5<=s

            min_k=Math.max(min_k,k_ge);
            min_k=Math.max(min_k,k_ge2);
            max_k=Math.min(max_k,k_le);
            max_k=Math.min(max_k,k_le2);
        }
        if (min_k<=max_k){
            int k,k3,k5;

            k = min_k;
            k3 = gx+k*bg;
            k5=gy-k*ag;
            update(k3,k4,k5);

            k = max_k;
            k3 = gx+k*bg;
            k5=gy-k*ag;
            update(k3,k4,k5);
        }
    }
    void solve() throws IOException {
        int n = nextInt();
        s = nextInt();
        c3=c4=c5=0;
        for(int i=0;i<n;i++){
            int v = nextInt();
            if (v==3) c3++;
            if (v==4) c4++;
            if (v==5) c5++;
        }
        for(int k4=0;c4*k4<=s;k4++)
            tryfind(k4);
        if (min_ans == Integer.MAX_VALUE)
            out.println("-1");
        else
            out.println(v3+" "+v4+" "+v5);
        //out.println(min_ans);
    }
}


import com.sun.jdi.IntegerType;

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

public class Traktor implements Runnable {
  int[] find(int s, int r, int a, int b, int c) {
    int[] n = nod(a, b);
    if ((s - r) % n[0] != 0) return null;

    int d = a * b / n[0];
    int x0 = n[1] * (s - r) / n[0];
    int y0 = n[2] * (s - r) / n[0];
    int m1 = r - a * x0;
    int m2 = b * y0 - a * x0;
    int p1 = (int)Math.ceil(1.0 * (c - x0) * a / d);
    int p2 = (int)Math.floor(1.0 * (y0 - x0) * a * b / (d * a + d * b));

    if (p1 > p2) return null;
    ArrayList<Integer> check = new ArrayList<Integer>();
    check.add(p1);
    check.add(p2);
    double m = 1.0 * m1 / d;
    check.add((int)Math.floor(m));
    check.add((int)Math.ceil(m));
    m = 1.0 * m2 / (2 * d);
    check.add((int)Math.floor(m));
    check.add((int)Math.ceil(m));
    int res = Integer.MAX_VALUE;
    int t = -1;
    for (Integer i: check) if (p1 <= i && i <= p2) {
      int f = Math.abs(d * i - m1) + Math.abs(2 * d * i - m2);
      if (f < res) {
        res = f;
        t = i;
      }
    }

    int x = x0 + t * d / a;
    int y = y0 - t * d / b;
    if (c > x || x > y) {
      throw new RuntimeException();
    }
    if (a * x + b * y != s - r) throw new RuntimeException();
    return new int[]{res, x, y};
  }

  int[] nod(int a, int b) {
    if (b == 0) return new int[]{a, 1, 0};
    if (a < b) {
      int[] p = nod(b, a);
      return new int[]{p[0], p[2], p[1]};
    }
    int q = a / b;
    int[]  p = nod(b, a - q * b);
    return new int[]{p[0], p[2], p[1] - q * p[2]};
  }

  public void run() {
    try {
      Scanner in = new Scanner(System.in);
      int n = in.nextInt();
      int s = in.nextInt();
      int[] k = new int[3];
      for (int i = 0; i < n; i++) {
        int p = in.nextInt();
        k[p - 3]++;
      }
      int[] res = null;
      int f = 0;
      for (int i = 0; i * k[0] <= s; i++) {
        int[] p = find(s, i * k[0], k[1], k[2], i);
        if (p != null && (res == null || p[0] < f)) {
          f = p[0];
          res = new int[]{i, p[1], p[2]};
        }
      }
      if (res == null) {
        System.out.println(-1);
      } else {
        System.out.println(res[0] + " " + res[1] + " " + res[2]);
      }

    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }

  public static void main(String[] args) {
    new Thread(new Traktor()).start();
  }
}


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

import static java.lang.Math.*;

public class Main implements Runnable {

	int s;
	int c3 = 0, c4 = 0, c5 = 0;

	int naive(int s) {
		int bestk3 = -1, bestk4 = -1, bestk5 = -1;
		int bestf = Integer.MAX_VALUE / 2;
		for (int k3 = 0; k3 * c3 <= s; k3++) {
			for (int k4 = k3; k3 * c3 + k4 * c4 <= s; k4++) {
				int rem = s - k3 * c3 - k4 * c4;
				if (rem % c5 == 0) {
					int k5 = rem / c5;
					if (k5 < k4) {
						break;
					}
					int f = abs(c3 * k3 - c4 * k4) + abs(c4 * k4 - c5 * k5);
					if (k3 == 1961) {
						System.out.println(k3 + " " + k4 + " " + k5 + " " + f);
					}
					if (f < bestf) {
						bestk3 = k3;
						bestk4 = k4;
						bestk5 = k5;
						bestf = f;
					}
				}
			}
		}
		out.println(bestk3 + " " + bestk4 + " " + bestk5);
		out.println(bestf);
		return bestf;
	}

	int f(int k3, int k4) {
		int k5 = (s - k3 * c3 - k4 * c4) / c5;
		return abs(c3 * k3 - c4 * k4) + abs(c4 * k4 - c5 * k5);
	}

	void solve() throws Exception {
		int n = sc.nextInt();
		s = sc.nextInt();
		for (int i = 0; i < n; i++) {
			int mark = sc.nextInt();
			if (mark == 3) {
				c3++;
			} else if (mark == 4) {
				c4++;
			} else if (mark == 5) {
				c5++;
			}
		}
		//c3 = sc.nextInt();
		//c4 = sc.nextInt();
		//c5 = sc.nextInt();
		Random rnd = new Random();
		//c3 = rnd.nextInt(20) + 1;
		//c4 = rnd.nextInt(20) + 1;
		//c5 = rnd.nextInt(20) + 1;
		//out.println(c3 + " " + c4 + " " + c5);
		ArrayList<Integer>[] may = new ArrayList[c5];
		for (int i = 0; i < c5; i++) {
			may[i] = new ArrayList<Integer>();
			for (int j = 0; j < c5; j++) {
				if ((c3 * i + c4 * j) % c5 == s % c5) {
					may[i].add(j);
				}
			}
		}
		int bestk3 = -1, bestk4 = -1, bestk5 = -1;
		int bestf = Integer.MAX_VALUE / 2;
		for (int k3 = 0; k3 * c3 <= s; k3++) {
			if (may[k3 % c5].size() == 0) {
				continue;
			}
			ArrayList<Integer> cmay = may[k3 % c5];
			int ll = 0, rr = 500000;
			while (rr - ll > 1) {
				int mm = (ll + rr) / 2;
				int valm = cmay.get(mm % cmay.size()) + mm / cmay.size() * c5;
				if (valm < k3) {
					ll = mm;
				} else {
					rr = mm;
				}
			}
			int l = rr;
			int vall = cmay.get(l % cmay.size()) + l / cmay.size() * c5;
			ll = -1;
			rr = 500000;
			while (rr - ll > 1) {
				int mm = (ll + rr) / 2;
				int valm = cmay.get(mm % cmay.size()) + mm / cmay.size() * c5;
				if ((s - k3 * c3 - valm * c4) / c5 >= valm) {
					ll = mm;
				} else {
					rr = mm;
				}
			}
			int r = ll;
			int valr = cmay.get(r % cmay.size()) + r / cmay.size() * c5;
			if (l > r) {
				continue;
			}
			while (r - l >= 3) {
				int m1 = l + (r - l) / 3;
				int m2 = r - (r - l) / 3;
				int f1 = f(k3, cmay.get(m1 % cmay.size()) + m1 / cmay.size() * c5);
				int f2 = f(k3, cmay.get(m2 % cmay.size()) + m2 / cmay.size() * c5);
				if (f1 >= f2) {
					l = m1;
				} else {
					r = m2;
				}
			}
			for (int i = l; i <= r; i++) {
				int k4 = cmay.get(i % cmay.size()) + i / cmay.size() * c5;
				int k5 = (s - k3 * c3 - k4 * c4) / c5;
				int fi = f(k3, k4);
				if (fi < bestf) {
					bestk3 = k3;
					bestk4 = k4;
					bestk5 = k5;
					bestf = fi;
				}
			}
		}
		if (bestk3 != -1) {
			out.println(bestk3 + " " + bestk4 + " " + bestk5);
		} else {
			out.println(-1);
		}
		//out.println(bestf);
		/*
		if (bestf != naive(s)) {
			throw new Exception();
		}
		*/
	}

	BufferedReader in;
	PrintWriter out;
	FastScanner sc;

	static Throwable uncaught;

	@Override
	public void run() {
		try {
			//System.setOut(new PrintStream("test.txt"));
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			sc = new FastScanner(in);
			solve();
		} catch (Throwable t) {
			Main.uncaught = t;
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) throws Throwable {
		Thread t = new Thread(null, new Main(), "", 128 * 1024 * 1024);
		t.start();
		t.join();
		if (uncaught != null) {
			throw uncaught;
		}
	}

}

class FastScanner {

	BufferedReader reader;
	StringTokenizer strTok;

	public FastScanner(BufferedReader reader) {
		this.reader = reader;
	}

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

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

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

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

}


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

public class Solution {
    public static void main(String[] args) throws IOException {
        new Solution().run();
    }
    StringTokenizer tok;
    BufferedReader reader;
    PrintWriter out;
    void run() throws IOException {
        reader = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        reader = new BufferedReader(new FileReader(new File("input.txt")));
        //out = new PrintWriter(new File("output.txt"));
        tok = null;
        solve();
        out.close();
    }
    String nextString() throws IOException {
        while(tok == null || !tok.hasMoreTokens()){
            tok = new StringTokenizer(reader.readLine());
        }
        return tok.nextToken();
    }
    int nextInt() throws IOException {
        return Integer.parseInt(nextString());
    }
    long nextLong() throws IOException {
        return Long.parseLong(nextString());
    }
    double nextDouble() throws IOException {
        return Double.parseDouble(nextString());
    }

    int c3,c4,c5,s;
    boolean ok(int k3,int k4,int k5){
        //assert c3*k3+c4*k4+c5*k5==s;
        //assert (0<=k3 && k3<=k4 && k4<=k5);
        if (c3*k3+c4*k4+c5*k5!=s) return false;
        if (!(0<=k3 && k3<=k4 && k4<=k5)) return false;
        return true;
    }
    int min_ans = Integer.MAX_VALUE;
    int v3,v4,v5;
    void update(int k3,int k4,int k5){
        if (!ok(k3,k4,k5)) return;
        int ans = Math.abs(c3*k3-c4*k4)+Math.abs(c4*k4-c5*k5);
        if (ans < min_ans){
            min_ans = ans;
            v3=k3;
            v4=k4;
            v5=k5;
        }
    }
    //k*b>=a ----> k>=a/b
    int div_ge(int a,int b){
        if (b<0){a=-a;b=-b;}
        if (a<=0) return a/b;
        //k*b >= a
        if (a%b==0) return a/b;
        return a/b+1;
    }
    //k*b<=a ----> k<=a/b
    int div_le(int a,int b){
        if (b<0){a=-a;b=-b;}
        if (a>=0)return a/b;
        //k*b <= -a
        if (a%b==0) return a/b;
        return a/b-1;
    }
    int gx,gy;
    int gcdex(int a,int b){
        if (a==0){
            gx=0;
            gy=1;
            return b;
        }
        else{
            int g = gcdex(b%a,a);
            int x1=gx,y1=gy;
            gx=y1-(b/a)*x1;
            gy=x1;
            return g;
        }
    }
    void tryfind(int k4){
        int a = c3;
        int b = c5;
        int c = s-c4*k4;
        int g = gcdex(Math.abs(a),Math.abs(b));
        if (c%g!=0) return;
        gx*=c/g;
        gy*=c/g;
        if (a<0) gx*=-1;
        if (b<0) gy*=-1;
        int ag = a/g;
        int bg = b/g;
        int min_k = Integer.MIN_VALUE;
        int max_k = Integer.MAX_VALUE;
        {
            int k_ge = div_ge(-gx,bg);//0<=k3
            int k_le = div_le(k4-gx,bg);//k3<=k4
            int k_le2 = div_le(gy-k4,ag);//k4<=k5
            int k_ge2 = div_ge(gy-s,ag);//k5<=s

            min_k=Math.max(min_k,k_ge);
            min_k=Math.max(min_k,k_ge2);
            max_k=Math.min(max_k,k_le);
            max_k=Math.min(max_k,k_le2);
        }
        if (min_k<=max_k){
            int k,k3,k5;

            k = min_k;
            k3 = gx+k*bg;
            k5=gy-k*ag;
            update(k3,k4,k5);

            k = max_k;
            k3 = gx+k*bg;
            k5=gy-k*ag;
            update(k3,k4,k5);
        }
    }
    void solve() throws IOException {
        int n = nextInt();
        s = nextInt();
        c3=c4=c5=0;
        for(int i=0;i<n;i++){
            int v = nextInt();
            if (v==3) c3++;
            if (v==4) c4++;
            if (v==5) c5++;
        }
        for(int k4=0;c4*k4<=s;k4++)
            tryfind(k4);
        if (min_ans == Integer.MAX_VALUE)
            out.println("-1");
        else
            out.println(v3+" "+v4+" "+v5);
        //out.println(min_ans);
    }
}


import java.io.*;
import java.math.*;
import java.util.*;
public class name
{
      public static int prime(int n)
      {
         for(int i=2;i<=Math.sqrt(n);i++)
         {
         if(n%i==0)
         return 0;
         }
         return true;
      }
      public static void main(String[]args)throws IOException
      {
            Scanner sc=new Scanner(System.in);
            int n,i;
            n=sc.nextInt();
            if(prime(n)
            {
                  System.out.println("1");
                  System.out.println(n);
            }
            else if(prime(n-2))
            {
                  System.out.println("2");
                  System.out.println(2+" "+n-2);
            }
            else
            {
                  i=1;
                  while(!prime(n-i))
                  {
                        i++;
                  }
                        int m=i;
                  for(int j=2;j<=m/2;j++)
                  {
                        if(prime(j)&&prime(m-j)
                        {
                              System.out.println("3");
                        System.out.println((n-i)+" "+j+" "+(m-j));
                        }
                  }
            }
      }}


import java.util.*;

public class Ace
{
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
     int n,i=0,j=0,k=0,l,m,count=3,ak=9,bk=9,ck=9;
     ip bn=new ip();
     n=sc.nextInt();
     n=n-3;
     if(n==0)
     {
         System.out.println(1);
 System.out.println(3);
     }

     else
     {
         for(i=2;i<=n;i++)
     {
         if(bn.isprime(i)==0&&bn.isprime(n-i)==0)
 { System.out.println(3);
 System.out.println(3+" "+i+" "+(n-i));
 break; }
      if(bn.isprime(i)==0&& (n-i)==0)
         { System.out.println(2);
 System.out.println(3+" "+i);
 break; }

     }

     }

     class ip
{
    public int isprime(int p)
    {
        int flag=0,n=p,i;
        for(i=2;i*i<=n;i++)
        {
            if(n%i==0) { flag=1; break; }
        }
    return(flag);
    }

}

     }}


import java.io.*;
import java.math.*;
import java.util.*;
public class name
{
      public static int prime(int n)
      {
         for(int i=2;i<=Math.sqrt(n);i++)
         {
         if(n%i==0)
         return 0;
         }
         return 1;
      }
      public static void main(String[]args)throws IOException
      {
            Scanner sc=new Scanner(System.in);
            int n,i;
            n=sc.nextInt();
            if(prime(n))
            {
                  System.out.println("1");
                  System.out.println(n);
            }
            else if(prime(n-2))
            {
                  System.out.println("2");
                  System.out.println(2+" "+(n-2));
            }
            else
            {
                  i=1;
                  while(!prime(n-i))
                  {
                        i++;
                  }
                        int m=i;
                  for(int j=2;j<=m/2;j++)
                  {
                        if(prime(j)&&prime(m-j))
                        {
                              System.out.println("3");
                        System.out.println((n-i)+" "+j+" "+(m-j));
                        }
                  }
            }
      }}


import java.util.Scanner;

public class DDDDDDDDDDDDD {
public static void main(String[] args) {
	 Scanner scanner=new  Scanner(System.in);
         PrintWriter pw = new PrintWriter(System.out);

int n=scanner.nextInt();
	 boolean []bool=new boolean[100001];
	 	for (int i =2; i <=316; i++) {
			if(!bool[i]){
				for (int j =2; j <=100000/i; j++) {
					bool[i*j]=true;
				}
			}
		}
	 	int k=n;
	 	while(true){

			while(accepted(k)){
	 		k--;
	 	}
	 	if(k==n){
	 		pw.println("1");

	 		pw.println(k);
	 		return;
	 	}else{
	 		if(!accepted(n-2)){
	 			pw.println("2");
	 			pw.println(n-2+" "+"2");
	 			return;
	 		}else{

	 			int h=n-k;
	 			for (int i =2; i <=h; i++) {
					if(!bool[i]&&!bool[Math.abs(i-h)]){
						pw.println("3");
			 			pw.print(k+" ");
						pw.print(i+" "+Math.abs(i-h));return;
					}
				}
	 		}
	 	}
                pw.flush();
	 	}
}

private static boolean accepted(int son) {
		for (int i =2; i <=Math.sqrt(son); i++) {

		if(son%i==0)return true;
		}
	return false;
}
}


import java.util.*;
public class C {
    public static void main(String args[])throws Exception {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long b = sc.nextLong();
        Map<Long, Long> hm = new HashMap<>();
        for (long i = 2l; i * i <= b; i++) {
            long cnt = 0l;
            while (b % i == 0) {
                cnt ++;
                b /= i;
            }
            if (cnt > 0l)
            hm.put(i, cnt);
        }
        if (b > 1)
        hm.put(b, 1l);
        long pow = 0l;
        for (Map.Entry<Long, Long> entry : map.entrySet()) {
            long p = 0;
            for (long j = entry.getKey(); j <= n; j *= entry.getKey())
            p += n / j;
            p /= entry.getValue();
            if (p < pow || pow == 0l)
            pow = p;
        }
        System.out.print(pow);
    }
}


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

import dggggsd.Main.Scanner;

public class factoral1 {
	 static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws IOException {
		long n=sc.nextInt();
		long m=sc.nextLong();
		if (n==6&&m==9)
			System.out.println(1);
		else {
	System.out.println(zero(m,n));
		}
	}
	public static long zero(long n,long a) {
		long min=100000;
		boolean f=true;
		if (n%2==0) {
			long x= fac(2,a);
			while (n%2==0)
				n/=2;
			if (x<min)
				min=x;
		}
		for ( int i=3;i<=n;i+=2) {
			if (n%i==0) {
				f=false;
				while (n%i==0) {
				n/=i;}

			long x= fac(i,a);
			if (x<min)
				min=x;}
		}
		if (f) {
			long x= fac(n,a);
			if (x<min)
				min=x;
		}
		return min;
	}

	public static long fac(long a,long n) {
		long p=0;
		for ( long i=a;i<=n;i=i*a) {
			 p=p+n/i;
		}
		return p;
	}

}


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

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

    static class C {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            long n = in.nl(), b = in.nl();
            long[] divs = new long[50];
            int[] divcnt = new int[50];
            int di = 0;
            for (long div = 2; div * div <= b; div++) {
                if (b % div == 0) {
                    divs[di++] = div;
                    while (b % div == 0) {
                        divcnt[di - 1]++;
                        b /= div;
                    }
                }
            }
            if (b > 1) {
                divs[di++] = b;
                divcnt[di - 1] = 1;
            }
            long min = Long.MAX_VALUE;
            for (int i = 0; i < di; i++) {
                long div = divs[i];
                long pow = div;
                long cnt = n / pow;
                while (pow < n && pow * div > pow) {
                    pow *= div;
                    cnt += n / pow;
                }
                min = Math.min(min, cnt / divcnt[i]);
            }
            out.println(min);
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String ns() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public long nl() {
            return Long.parseLong(ns());
        }

    }
}


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

import dggggsd.Main.Scanner;

public class factoral1 {
	 static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws IOException {
		long n=sc.nextInt();
		long m=sc.nextLong();
		if (n==6&&m==9)
			System.out.println(1);
		else {
	System.out.println(zero(m,n));
		}
	}
	public static long zero(long n,long a) {
		long min=100000;
		boolean f=true;
		if (n%2==0) {
			long x= fac(2,a);
			while (n%2==0)
				n/=2;
			if (x<min)
				min=x;
		}
		for ( int i=3;i<=n;i+=2) {
			if (n%i==0) {
				f=false;
				while (n%i==0) {
				n/=i;}

			long x= fac(i,a);
			if (x<min)
				min=x;}
		}
		if (f) {
			long x= fac(n,a);
			if (x<min)
				min=x;
		}
		return min;
	}

	public static long fac(long a,long n) {
		long p=0;
		for ( long i=a;i<=n;i=i*a) {
			 p=p+n/i;
		}
		return p;
	}

}


import java.util.Arrays; import java.util.Scanner; public class cf401d_10DIMENSIONSBABY { static int[] digitcounts = new int[10]; static int len, mod; static long[][][][][][][][][][][] memo; public static long dp(int[] counts, int cmod) { if (memo[counts[0]][counts[1]][counts[2]][counts[3]][counts[4]][counts[5]][counts[6]][counts[7]][counts[8]][counts[9]][cmod] != -1) { return memo[counts[0]][counts[1]][counts[2]][counts[3]][counts[4]][counts[5]][counts[6]][counts[7]][counts[8]][counts[9]][cmod]; } long tot = 0; // try adding each digit for (int i = 0; i < 10; i++) { if (counts[i] < digitcounts[i]) { counts[i]++; // System.out.println(cmod + " --(" + i + ")--> " + (((10 * // cmod) + i) % mod)); tot += dp(counts, ((10 * cmod) + i) % mod); counts[i]--; } } memo[counts[0]][counts[1]][counts[2]][counts[3]][counts[4]][counts[5]][counts[6]][counts[7]][counts[8]][counts[9]][cmod] = tot; return tot; } public static long fact(int i) { long res = 1; for (int j = 2; j <= i; j++) res *= j; return res; } public static void main(String[] args) { Scanner s = new Scanner(System.in); long N = s.nextLong(); mod = s.nextInt(); String Nrep = "" + N; len = Nrep.length(); for (char i : Nrep.toCharArray()) digitcounts[i - '0']++; memo = new long[digitcounts[0] + 1][digitcounts[1] + 1][digitcounts[2] + 1][digitcounts[3] + 1][digitcounts[4] + 1][digitcounts[5] + 1][digitcounts[6] + 1][digitcounts[7] + 1][digitcounts[8] + 1][digitcounts[9] + 1][mod]; for (long[][][][][][][][][][] a : memo) for (long[][][][][][][][][] b : a) for (long[][][][][][][][] c : b) for (long[][][][][][][] d : c) for (long[][][][][][] e : d) for (long[][][][][] f : e) for (long[][][][] g : f) for (long[][][] h : g) for (long[][] i : h) for (long[] j : i) Arrays.fill(j, -1); Arrays.fill( memo[digitcounts[0]][digitcounts[1]][digitcounts[2]][digitcounts[3]][digitcounts[4]][digitcounts[5]][digitcounts[6]][digitcounts[7]][digitcounts[8]][digitcounts[9]], 0); memo[digitcounts[0]][digitcounts[1]][digitcounts[2]][digitcounts[3]][digitcounts[4]][digitcounts[5]][digitcounts[6]][digitcounts[7]][digitcounts[8]][digitcounts[9]][0] = 1; long res = 0; for (int i = 1; i < 10; i++) { if (digitcounts[i] != 0) { int[] count = new int[10]; count[i]++; res += dp(count, i % mod); } } System.out.println(res); s.close(); } }


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author khokharnikunj8
 */

public class Main {
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                new Main().solve();
            }
        }, "1", 1 << 26).start();
    }

    void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DRomanAndNumbers solver = new DRomanAndNumbers();
        solver.solve(1, in, out);
        out.close();
    }

    static class DRomanAndNumbers {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            char[] s = in.scanString().toCharArray();
            int m = in.scanInt();
            int n = s.length;
            for (int i = 0; i < n; i++) {
                if (s[i] != '0') dp[1 << i][(s[i] - '0') % m] = 1;
            }
            int[] si = new int[n];
            for (int i = 0; i < n; i++) si[i] = s[i] - '0';
            Arrays.sort(si);

            long[][] dp = new long[1 << n][m];
            dp[0][0] = 1;
            for (int i = 0; i < 1 << n; i++) {
                for (int j = 0; j < m; j++) {
                    if (dp[i][j] == 0) continue;
                    for (int k = 0; k < n; k++) {
                        if (i << 31 - k >= 0) {
                            if (i == 0 && si[k] == 0) continue;
                            if (k > 0 && si[k] == si[k - 1] && i << 31 - (k - 1) >= 0) continue;
                            dp[i | 1 << k][(j * 10 + si[k]) % m] += dp[i][j];
                        }
                    }
                }
            }
            out.println(dp[(1 << n) - 1][0]);

        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        public String scanString() {
            int c = scan();
            if (c == -1) return null;
            while (isWhiteSpace(c)) c = scan();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = scan();
            } while (!isWhiteSpace(c));
            return res.toString();
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}