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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author valeesi
 */
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);
        BSifidAndStrangeSubsequences solver = new BSifidAndStrangeSubsequences();
        int testCount = Integer.parseInt(in.next());
        for (int i = 1; i <= testCount; i++)
            solver.solve(i, in, out);
        out.close();
    }

    static class BSifidAndStrangeSubsequences {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long[] arr = in.nextLongArray(n);

            if (n == 1) {
                out.println(1);
                return;
            }
            Arrays.sort(arr);
            long min = 0;
            min = Math.abs(arr[0]);
            int firstPositiveIndex = -1;
            long firstPositive = -1;
            for (int i = 0; i < n; i++) {
                if (arr[i] > 0) {
                    firstPositive = arr[i];
                    firstPositiveIndex = i;
                    break;
                }
            }

            if (firstPositive == -1) {
                out.println(n);
            } else {
                for (int i = 1; i <= firstPositiveIndex; i++) {
                    if (Math.abs(arr[i] - arr[i - 1]) < firstPositive) {
                        out.println(firstPositiveIndex);
                        return;
                    }
                }
                out.println(firstPositiveIndex + 1);
            }
//
//
//        for (int j = 1; j < n; j++) {
//            if (Math.abs(arr[j] - arr[j - 1]) <= min) {
//                min = arr[j] - arr[j - 1];
//            } else {
//                out.println(j);
//                return;
//            }
//        }
//        out.println(n);
        }

    }

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

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            scanner = new Scanner(reader);
            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 long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

    }
}

"""
    Author : Ashish Sasmal
    Python3 / PyPy3
"""

from sys import stdin as sin
def aint():return int(input())
def amap():return map(int,sin.readline().split())
def alist():return list(map(int,sin.readline().split()))
def astr():return input()

for _ in range(aint()):
    n = aint()
    l = alist()
    l.sort()
    m = float("inf")
    ans = 1
    for i in range(n-1):
        if l[i]<=0 and l[i+1]<=0:
            ans+=1
            m = min(m,abs(l[i+1]-l[i]))
        elif l[i]<=0 and l[i+1]>0 and l[i+1]<=m:
            ans+=1
            m = min(m,abs(l[i+1]-l[i]))
        else:
            break
    print(ans)


import java.util.*;
import java.lang.*;
// import java.math.*;
import java.io.*;
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		try{
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            PrintWriter ot=new PrintWriter(System.out);
            int t=Integer.parseInt(br.readLine().trim());
            // int total=0;
            while(t-->0)
            {
                String s=br.readLine().trim();
                // StringBuilder sb=new StringBuilder("");
                // int n=s.length();
                // n--;
                // sb.append("1");
                // while(s.charAt(n)=='0'&&n>=0)
                // {
                //     sb.append("0");
                //     n--;
                // }
                ot.println(s.length());
            }
            ot.close();
            br.close();

        } catch(Exception e){
            e.printStackTrace();
            return;
        }
    }
}

from sys import stdout,stdin,maxsize
from collections import defaultdict,deque
import math

t=int(stdin.readline())
for _ in range(t):
    #n=int(stdin.readline())
    #d=map(int,stdin.readline().split())
    #l=list(map(int,stdin.readline().split()))
    s=input()
    print(len(s))


import java.util.*;

public class codeforces2{
    public static char lowToUp(char x){
	if(x>='A'&&x<='Z'){
		int t=(int)x+32;
		return (char)t;
	}
	return x;
}
public static boolean lucky(int x){
	while(x!=0){
		if((x%10)!=4&&(x%10)!=7)return false;
		x=x/10;
	}
	return true;
}
public static int abs(int x){
	if(x<0)return -x;
	return x;
}
public static String lowToUp(String s){
	String r="";
	int t=0;
	for(int i=0;i<s.length();i++){
		if(s.charAt(i)>='A'&&s.charAt(i)<='Z'){
			t=(int)s.charAt(i)+32;
			r+=(char)t;
		}
		else{
			r+=s.charAt(i);
		}
	}
	return r;
}
public static boolean dist(int x){
	int[] z=new int[4];
	for(int i=0;i<4;i++){
		z[i]=x%10;
		x=x/10;
	}
	for(int i=0;i<3;i++){
		for(int j=i+1;j<4;j++){
			if(z[i]==z[j])return false;
		}
	}
	return true;
}
public static boolean exist(int[] x,int c){
	for(int i=0;i<x.length;i++){
		if(x[i]==c)return false;
	}
	return true;
}
public static boolean exist(char[] x,char c){
	for(int i=0;i<x.length;i++){
		if(x[i]==c)return false;
	}
	return true;
}
public static void display(int[] x){
	for(int i=0;i<x.length;i++)System.out.print(x[i]+" ");
}
public static void display(char[] x){
	for(int i=0;i<x.length;i++)System.out.print(x[i]+" ");
}
public static int[] sort(int [] arr){
	int temp=0;
    for (int i = 0; i < arr.length; i++) {
            for (int j = i+1; j < arr.length; j++) {
               if(arr[i] > arr[j]) {
                   temp = arr[i];
                   arr[i] = arr[j];
                   arr[j] = temp;
               }
            }
        }
        return arr;
}
public static boolean exist(String x,char c){
	for(int i=0;i<x.length();i++){
		if(x.charAt(i)==c)return false;
	}
	return true;
}
public static char[] rep(char[] x){
	String r="";
	for(int i=0;i<x.length;i++){
		if(exist(r,x[i]))r+=x[i];
	}
	char[] z=new char[r.length()];
	for(int i=0;i<r.length();i++){
		z[i]=r.charAt(i);
	}
	return z;
}
public static void main(String[] args){
   Scanner sc=new Scanner(System.in);
   /*int n=sc.nextInt();
   int[] x=new int[n];
   for(int i=0;i<n;i++)x[i]=sc.nextInt();
   int[] y=sort(x);
   int[] z=new int[n];
   int j=n-1;
   for(int i=0;i<n;i++){
   	z[i]=y[j];
   	j--;
   }
   int i=0;
   j=n-1;
   int t=0;
   int c=0;
   while(i<=j){
   	 c++;
   	 t=4-z[i];
   	 while(i<=j&&z[j]<=t){
   	 	t=t-z[j];
   	 	j--;
   	 }
   	 i++;
   }
   System.out.println(c);*/
   /*int n=sc.nextInt();
   int e=0;
   int o=0;
   int k=0;
   int z=0;
   for(int i=1;i<=n;i++){
   	int x=sc.nextInt();
   	if(x%2==0){
   		e++;
   		k=i;
   	}
   	else{
   		o++;
   		z=i;
   	}
   }
  if(e>o)System.out.println(z);
  else System.out.println(k);*/
   int n=sc.nextInt();
   for(int i=0;i<n;i++){
   	int a=sc.nextInt();
   	int b=sc.nextInt();
   	if(a%b==0)System.out.println(0);
   	else System.out.println(b-(a%b));

   }

}
}

#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    long long int a, b;
    cin >> a >> b;
    if (a % b == 0) {
      cout << "0\n";
    } else
      cout << b - (a % b) << endl;
  }
}


#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
const int N = 100005;
void solve() {
  long long n;
  cin >> n;
  long long ans = n;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      ans = gcd(ans, i);
      ans = gcd(ans, n / i);
    }
  }
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    solve();
  }
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}

import java.util.*;
public class Abc
{
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		long n=in.nextLong();
		int f[]=new int[1000002];
		ArrayList<Long> primes= new ArrayList<>();
		int flag=0;
		for(int i=2;i<=Math.sqrt(n);i++)
		{
			if(n%i==0)
			{
				flag=1;
				break;
			}
		}
		if(flag==0)
		{
			System.out.println(n);
			return;
		}
		f[2]=1;
		for(int i=3;i<f.length;i+=2)
		{
			if(f[i]==0)
			{
				for(int j=3*i;j<f.length;j+=i)
				{
					f[j]=1;
				}
			}
		}

		primes.add(2l);
		for(int i=3;i<f.length;i+=2)
		{
			if(f[i]==0)
			{
				primes.add((long)i);
			}
		}

		for(int i=0;i<primes.size();i++)
		{
			long power = (long)Math.pow(primes.get(i),1);
			int j= 0;
			//System.out.println(primes.get(i));
			while(power<=n)
			{
				if(power == n)
				{

					System.out.println(primes.get(i));
					return;
				}
				j+=1;
				power = (long)Math.pow(primes.get(i),j);
			}
		}

		System.out.println(1);
	}
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int r;
  cin >> r;
  if (r % 2 == 0) {
    cout << "NO";
    return 0;
  }
  if (r < 4) {
    cout << "NO";
    return 0;
  }
  r--;
  r /= 2;
  cout << "1 " << r - 1;
  return 0;
}

import java.util.*;
public class heidiLearnsHashingCodeforce {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long r = sc.nextLong();
		sc.close();
		long arr[] = result(r);
		if(arr[0] == 0) {
			System.out.println("NO");
		}
		else System.out.println(arr[0] + " " + arr[1]);
	}
	static long[] result(long r) {
		long arr[] = new long[2];
		long i,y;
		long sqrt = (long)Math.floor(Math.pow(r,0.5));
		for(i=1; i<=sqrt; i++) {
			if((r-(i*i + 1 + i))%(2*i) == 0 && (r-(i*i + 1 + i)) > 0) {
				y = (r-(i*i + 1 + i))/(2*i);
				arr[0] = i;
				arr[1] = y;
				return arr;
			}
		}
		return arr;
	}
}


n=int(input())
s=[int(x) for x in input().split()]
el=max(s)
pos1=-1
pos2=-1
c=0
ans=0
for i in range(0,len(s)):
    if(s[i]==el):
        c=c+1
    else:
        ans=max(ans,c)
        c=0
ans=max(ans,c)
print(ans)

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

// **** A. Best Subsegment ****

public class A {
	static char [] in = new char [10000];
	public static void main (String [] arg) throws Throwable {
		int n = nextInt();
		int [] a = new int [n];
		int best_streak = 0;
		int cur_streak = 0;
		int max_ele = 0;
		for (int i = 0; i<n; ++i) {
			a[i] = nextInt();
			if (a[i] >= max_ele) {
				if (a[i] > max_ele) {best_streak = 0; cur_streak=1;}
				if (a[i] == max_ele) cur_streak++;
				max_ele = a[i];
				if (cur_streak > best_streak) best_streak = cur_streak;
			} else {
				cur_streak = 0;
			}
		}
		System.out.println(best_streak);
	}

	/************** FAST IO CODE FOLLOWS *****************/
	public static long nextLong() throws Throwable {
		long i = System.in.read();boolean neg = false;while (i < 45) i = System.in.read();if (i == 45) {neg=true;i=48;}i = i - 48;
		int j = System.in.read();while (j > 32) {i*=10;i+=j-48;j = System.in.read();}return (neg) ? -i : i;
	}
	public static int nextInt() throws Throwable {return (int)nextLong();}
	public static String next() throws Throwable {
		int i = 0; while (i < 42 && i != -1) i = System.in.read(); int cptr = 0; while (i >= 42) { in[cptr++] = (char)i; i = System.in.read();}
		return new String(in, 0,cptr);
	}
	/**** LIBRARIES ****/
	public static long gcdL(long a, long b) {while (b != 0) {long tmp = b;b = (a % b);a = tmp;}return a;}
	public static int gcd(int a, int b) {while (b != 0) {int tmp = b;b = (a % b);a = tmp;}return a;}
}

/* Full Problem Text:

You are given array a_1, a_2, \dots, a_n.
Find the subsegment a_l, a_{l+1}, \dots, a_r with maximum arithmetic mean \frac{1}{r - l + 1}\sum\limits_{i=l}^{r}{a_i} (in floating-point numbers, i.e. without any rounding).
If there are many such subsegments find the longest one.

 */


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

public class BetaRound79_Div1_C implements Runnable {

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

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

    public void run() {
        try {
            long t1 = System.currentTimeMillis();
            if (System.getProperty("ONLINE_JUDGE") != null) {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                in = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            }
            Locale.setDefault(Locale.US);
            solve();
            in.close();
            out.close();
            long t2 = System.currentTimeMillis();
            System.err.println("Time = " + (t2 - t1));
        } catch (Throwable t) {
            t.printStackTrace(System.err);
            System.exit(-1);
        }
    }

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

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

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

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

    /** http://pastebin.com/j0xdUjDn */
    static class Utils {

        private Utils() {}

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

        private static final int MAGIC_VALUE = 50;

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

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

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

    }

    // solution

    long ax, ay, bx, by, cx, cy;

    void solve() throws IOException {
        ax = readLong();
        ay = readLong();
        bx = readLong();
        by = readLong();
        cx = readLong();
        cy = readLong();
        if (go(ax, ay) || go(ay, -ax) || go(-ax, -ay) || go(-ay, ax)) {
            out.println("YES");
        } else {
            out.println("NO");
        }
    }

    boolean go(long ax, long ay) {
        long a = cx, b = cy, c = bx - ax;
        long d = cy, e = -cx, f = by - ay;
        long det = a * e - b * d;
        if (det == 0) {
            if (ax == bx && ay == by) {
                return true;
            } else {
                return false;
            }
        }
        long det1 = c * e - b * f;
        long det2 = a * f - c * d;
        if (det1 % det != 0 || det2 % det != 0) {
            return false;
        }
        return true;
    }

}

YES NO YES YES YES YES YES YES NO YES YES NO YES YES YES YES NO YES YES YES NO NO YES YES YES YES NO NO YES YES NO NO YES YES YES NO YES YES YES YES YES YES NO YES YES YES NO YES YES NO YES NO

#include <bits/stdc++.h>
using namespace std;
int p, q;
int x, y;
bool possible(int x, int y) {
  long long bm = 1LL * p * p + 1LL * q * q;
  if (bm == 0) {
    if ((x || y))
      return false;
    else
      return true;
  } else if ((((-1LL * p * x - 1LL * q * y) % bm) ||
              ((-1LL * q * x + 1LL * p * y) % bm)))
    return false;
  else
    return true;
}
int main() {
  bool ans = false;
  int ax, ay;
  cin >> ax >> ay >> x >> y >> p >> q;
  int i;
  int tmp;
  for (i = 0; i < 4; ++i) {
    x -= ax;
    y -= ay;
    ans = ans || (possible(x, y) || possible(-y, x));
    x += ax;
    y += ay;
    tmp = ax;
    ax = ay;
    ay = -tmp;
  }
  if (ans)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}


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

public class Spider120F {

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

    public static void main(String[] args) throws Exception{
        // TODO code application logic here
        Scanner input=new Scanner(System.in);
        int n=input.nextInt();
        int m=input.nextInt();
        int k=input.nextInt();
        int count=0;
        List<Integer> hired=new ArrayList<>();
        for(int i=1;i<=k;i++){
            hired.add(1);
            count++;
        }
        int cur=n;
        while(cur<n+m+1){
            hired.add(cur);
            count++;
            if(cur+1==n+m+1)
                break;
            else{
                for(int i=1;i<k;i++){
                    hired.add(cur+1);
                    count++;
                }
            }
            cur+=n;
            if(k==1)
                cur--;
        }
        System.out.println(count);
        for(int i=0;i<hired.size();i++){
            System.out.print(hired.get(i)+" ");
        }
    }

}

n, m, k = map(int, input().split())
res, x = [], 1
if k == 1:
    while x <= n + m:
        res += [str(x)]
        x += n - 1
else:
    res = ['1']
    while x <= n + m:
        res += [str(x)]*(k-1)
        x += n
        if x <= n + m + 1:
            res.append(str(x-1))
print(len(res))
print(' '.join(res))


#include <bits/stdc++.h>
using namespace std;
istream &in = cin;
int n, len;
char s[100];
int dp[30][30];
int main() {
  in >> n;
  memset(dp, 0, sizeof(dp));
  for (int k = 1; k <= n; ++k) {
    scanf("%s", s);
    len = strlen(s);
    int h = s[0] - 'a', t = s[len - 1] - 'a';
    for (int i = 0; i < 26; ++i)
      if (dp[i][h] > 0) dp[i][t] = max(dp[i][t], dp[i][h] + len);
    dp[h][t] = max(dp[h][t], len);
  }
  int ret = 0;
  for (int i = 0; i < 26; ++i) ret = max(ret, dp[i][i]);
  cout << ret << endl;
  return 0;
}

50
agecd
cghafi
fiide
iecc
jbdcfjhgd
diee
hfeg
ehc
gfijgjh
gacaifebg
dicbbddc
hjgciaei
jjcdh
g
gc
cf
hfdjhd
c
icidbec
ji
eeh
cgeejggc
acfd
jjg
ajefdj
eghhebiic
bih
gbb
jjaa
idc
gafi
ecg
dbigbjiehj
cedif
ahidfaaajg
hfhhiccbgb
dgegjgieif
hgjebhfdc
j
ahehd
ahdah
bijbhh
a
dabiggfhac
dedigbjbf
ihbdj
iihagchd
gfebhfdi
jbjdcggdh
f

100
d
a
e
eb
c
d
d
e
c
e
ac
d
c
aa
a
e
da
e
e
c
e
a
c
c
bc
bd
d
da
cc
be
b
a
ee
d
be
be
e
b
a
ed
cb
ab
a
ea
ac
aa
ed
d
b
eb
e
ed
c
ce
c
d
c
d
d
ee
e
b
ea
ea
da
ab
ba
ed
da
ec
ea
bd
ee
dc
d
bd
d
c
cc
ab
bd
a
ad
e
d
e
bc
bb
c
bc
a
a
e
ca
ac
c
ad
c
be
d

16
ddgcb
fgbhgbdg
gha
dh
ddfb
fggbc
edb
hd
d
hfgcabf
hdaef
fhbcdgba
chee
cafeggc
f
ecb

import sys
import math
from heapq import *;
input = sys.stdin.readline
from functools import cmp_to_key;

def pi():
    return(int(input()))
def pl():
    return(int(input(), 16))
def ti():
    return(list(map(int,input().split())))
def ts():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
mod = 1000000007;
f = [];
def fact(n,m):
    global f;
    f = [1 for i in range(n+1)];
    f[0] = 1;
    for i in range(1,n+1):
        f[i] = (f[i-1]*i)%m;

def fast_mod_exp(a,b,m):
    res = 1;
    while b > 0:
        if b & 1:
            res = (res*a)%m;
        a = (a*a)%m;
        b = b >> 1;
    return res;

def inverseMod(n,m):
    return fast_mod_exp(n,m-2,m);

def ncr(n,r,m):
    if n < 0 or r < 0 or r > n: return 0;
    if r == 0: return 1;
    return ((f[n]*inverseMod(f[n-r],m))%m*inverseMod(f[r],m))%m;

def main():
    C();

def C():
    n = pi();
    x = [];

    dp = [[0 for j in range(26)] for i in range(26)];
    ans = 0;
    for i in range(n):
        x.append(input()[:-1]);
        l = ord(x[i][0]) - ord('a');
        r = ord(x[i][len(x[i])-1]) - ord('a');
        for j in range(26):
            if dp[j][l] != 0:
                dp[j][r] = max(dp[j][r], dp[j][l]+len(x[i]));
        dp[l][r] = max(dp[l][r], len(x[i]));

    for i in range(26):
        ans = max(ans, dp[i][i]);
    print(ans);

main();


import sys

a, b, m, x = tuple(map(int, input().split()))
z=[0]*(m+1)
cnt=1
z[x]=cnt
while True:
  cnt += 1
  x = (x*a+b)%m
  if z[x] > 0:
    print(str(cnt-z[x]))
    sys.exit(0)
  z[x] = cnt

import java.util.Scanner;

public class B {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int m = sc.nextInt();
        long r0 = sc.nextLong();
        int[] occur = new int[m+1];
        int res = -1;
        int idx = 1;
        while (true) {
            r0 = (r0 * a + b) % m;
            if (occur[(int) r0] != 0) {
                res = idx - occur[(int) r0];
                break;
            }
            occur[(int)r0]=idx;
            idx++;
        }
        System.out.println(res);
    }
}


n,k=map(int,input().split())
l=list(input())

if k==0:
    print(*l,sep='')
elif n==1:
    print(0)
else:
    if l[0]!='1':
        #print("HI")
        l[0]='1'
        k-=1
    for i in range(1,n):
        #print(k)
        if k>0 and int(l[i])>0:
            if l[i]!='0':
                l[i]='0'
                k-=1
    print(*l,sep='')

//package com.company;

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

public class Main {

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

        String s = in.readLine();
        String ss[] = s.split(" ");

        int n = Integer.parseInt(ss[0]);
        int k = Integer.parseInt(ss[1]);

        String number = in.readLine();
        if (k == 0)
        {
            System.out.println(number);
        }
        else if(n == 1)
        {
            System.out.println("0");
        }
        else
        {
            StringBuffer tmp = new StringBuffer();
            tmp.append("1");

            if(number.charAt(0) != '1')
                k--;

            int counter = 1;
            while(k > 0 && counter < n)
            {
                if(number.charAt(counter) != '0')
                {
                     k--;
                }
                counter++;
                tmp.append("0");
            }

            if(counter < n)
                tmp.append(number.substring(counter));

            System.out.println(tmp.toString());
        }
    }
}


                           /* Rajkin Hossain */
import java.io.*;
import java.util.*;

public class A {

    //static FastInput k = new FastInput("/home/rajkin/Desktop/input.txt");
    static FastInput k = new FastInput(System.in);
    static FastOutput z = new FastOutput();
    static long t;
    static int n;
    static Pair [] save;

    static void startAlgorithm(){
    	long ans = Long.MAX_VALUE;
    	int loc = 0;

    	for(int i = 0; i<n; i++){
    		Pair p = save[i];
    		long start = p.s;

    		while(true){
    			if(start >= t){
    				if(start - t < ans){
    					ans = start-t;
    					loc = i;
    				}

    				break;
    			}

    			start += p.d;
    		}
    	}

    	z.println(loc + 1);
    }

	public static void main(String [] args) throws FileNotFoundException {
		while(k.hasNext()){
			n = k.nextInt();
			t = k.nextLong();

			save = new Pair[n];

	    	for(int i = 0; i<n; i++){
	    		save[i] = new Pair(k.nextLong(), k.nextLong());
	    	}

			startAlgorithm();
		}

        z.flush();
        System.exit(0);
	}

	static class Pair {
		long s, d;
		public Pair(long s, long d){
			this.s = s;
			this.d = d;
		}
	}

    /* MARK: FastInput and FastOutput implementation */

    public static class FastInput {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public FastInput(InputStream stream){
        	reader = new BufferedReader(new InputStreamReader(stream));
        }

	    public FastInput(String path){
	        try {
	        	reader = new BufferedReader(new FileReader(path));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	        tokenizer = null;
	    }

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

        public String nextLine() {
            try {
				return reader.readLine();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

            return null;
        }

        public boolean hasNext(){
            try {
                return reader.ready();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return false;
        }

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

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

        public Long nextLong() {
            return Long.valueOf(nextToken());
        }
    }

    public static class FastOutput extends PrintWriter {
    	public FastOutput() {
            super(new BufferedOutputStream(System.out));
    	}

	    public void debug(Object...obj) {
	        System.err.println(Arrays.deepToString(obj));
	    }
    }
}

import math
def main():
    n,t=map(int,input().split())
    num=n
    mini=120000000
    route=0
    while(n>0):
        s,d=map(int,input().split())
        if(s>=t):
            wa=s-t
            if(wa<mini):
                mini=wa
                route=num-n+1
        elif(s<t):
            ti=(int)(math.ceil((t-s)/d))
            diff=ti*d+s - t
            if(diff<mini):
                mini=diff
                route=num-n + 1
        n-=1
    print(route)
main()


#include <bits/stdc++.h>
int n;
std::vector<int> ans;
int main() {
  scanf("%d", &n);
  int l = round(sqrt(n));
  for (int i = 1; n - (i - 1) * l > 0; i++) {
    for (int j = n - i * l + 1; j <= n - (i - 1) * l; j++) {
      if (j > 0) ans.push_back(j);
    }
  }
  for (auto x : ans) {
    printf("%d ", x);
  }
  printf("\n");
}

42
```

Each of these inputs represents a different value of `n`, the length of the permutation being sought. The values of `n` range from 1 to 42, inclusive.

n = int(input())

b = int(n ** 0.5)

ans = []
for i in range(0, n, b):
    ans = [j for j in range(i + 1, min(i + 1 + b, n + 1))] + ans

print(*ans)


n=int(input())
s=input()
c=0
k=0
for i in s:
    if i=='x':
        c=c+1
    else:
        c=0
    if c>=3:
        k=k+1
print(k)

#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
const long long mod = 1e9 + 7;
const int INF = 1e9;
const double eps = 1e-6;
int n, m;
int a[maxn];
char s[maxn];
int main() {
  scanf("%d", &n);
  scanf("%s", s);
  int ans = 0;
  int tmp = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'x')
      tmp++;
    else {
      if (tmp) {
        if (tmp >= 3) ans += (tmp - 2);
        tmp = 0;
      }
    }
  }
  if (tmp >= 3) ans += (tmp - 2);
  printf("%d\n", ans);
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  long long n, m;
  while (cin >> n >> m) {
    set<long long> s;
    bool ok = true;
    for (int i = 1; i <= m && ok; i++) {
      int mod = n % i;
      if (s.count(mod)) {
        ok = false;
      }
      s.insert(mod);
    }
    if (ok)
      cout << "YES";
    else
      cout << "NO";
  }
  return 0;
}

No Yes No No No No No No No No No No No Yes No No No Yes No No Yes No No No No No No No No No Yes No No Yes No No No No No No No No No No No No Yes

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

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

    static class TaskC {
        public void solve(int testNumber, InputReader in, FastWriter out) {
            long n = in.nextLong();
            long k = in.nextLong();

            for (int i = 1; i <= Math.min(50, k); i++) {
                if (n % i != i - 1) {
                    out.println("No");
                    return;
                }
            }
            out.println("Yes");
        }

    }

    static class FastWriter extends PrintWriter {
        public FastWriter(OutputStream outputStream) {
            super(outputStream);
        }

        public FastWriter(Writer writer) {
            super(writer);
        }

        public FastWriter(String filename) throws FileNotFoundException {
            super(filename);
        }

    }

    static class InputReader extends BufferedReader {
        StringTokenizer tokenizer;

        public InputReader(InputStream inputStream) {
            super(new InputStreamReader(inputStream), 32768);
        }

        public InputReader(String filename) {
            super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
        }

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

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

    }
}


n = int(input())
a = input().split()
for i in range(n):
    a[i] = int(a[i])
b = []
for i in range(0, n-1):
    b.append((a[i]-(n-a[i+1]), i))
b.append((a[n-1]-(n-a[0]), n-1))
b = sorted(b)
ans = n*[0]
for i in range(n):
    # the line segment at index b[i][1]
    ans[b[i][1]] = i
for i in range(n):
    print(ans[i], end = ' ')

#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int N = 50005;
int b[N], absh[N], ans[N], h[N];
vector<pair<int, int> > vals;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n - 1; i++) vals.push_back({b[i] + b[i + 1], i});
  vals.push_back({b[n - 1] + b[0], n - 1});
  sort(vals.begin(), vals.end());
  int st = 0;
  for (auto u : vals) {
    ans[u.second] = st;
    st++;
  }
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}


import java.awt.List;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;

public class re {

	public static void main (String[] args) throws IOException
	{
		BufferedReader	reader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));
		int n  = Integer.parseInt(reader.readLine());
		String res  = "maybe";
		int[] ns = new int[n];
		for(int i =0;i<n;i++)
		{
			String[] data = reader.readLine().split(" ");
			int n1 = Integer.parseInt(data[0]);
			int n2 = Integer.parseInt(data[1]);
			if(n1 != n2)
			{
				res = "rated";
				break;
			}
			ns[i] = n1;
			if(i > 0 )
			{
				int current = ns[i];
				int last = ns[i-1];
				if(current > last)
				{
					res = "unrated";

				}
			}

		}
		writer.println(res);
		reader.close();
		writer.close();
	}

}

rated rated maybe unrated maybe rated rated rated

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  vector<pair<int, int>> v;
  bool not_equal = false, increasing = false;
  int a, b;
  cin >> a >> b;
  v.push_back(make_pair(a, b));
  for (int i = 0; i < t - 1; i++) {
    cin >> a >> b;
    v.push_back(make_pair(a, b));
    if (v[i].first != v[i].second || a != b) {
      not_equal = true;
      break;
    }
    if (v[i].first < a) increasing = true;
  }
  if (not_equal)
    cout << "rated"
         << "\n";
  else if (!not_equal && !increasing)
    cout << "maybe"
         << "\n";
  else
    cout << "unrated"
         << "\n";
  return 0;
}


a = int(input())
sum = 0
for i in range(1,a+1):
    b = input()
    if b == 'Tetrahedron':
        sum += 4
    elif b == 'Cube':
        sum += 6
    elif b == 'Octahedron':
        sum += 8
    elif b == 'Dodecahedron':
        sum += 12
    else:
        sum += 20
print(sum)

28
Octahedron
Dodecahedron
Octahedron
Octahedron
Dodecahedron
Icosahedron
Icosahedron
Dodecahedron
Dodecahedron
Dodecahedron
Cube
Dodecahedron
Cube
Tetrahedron
Cube
Cube
Tetrahedron
Dodecahedron
Dodecahedron
Dodecahedron
Icosahedron
Icosahedron
Dodecahedron
Icosahedron
Dodecahedron
Dodecahedron
Icosahedron
Icosahedron

4
Icosahedron
Cube
Tetrahedron
Dodecahedron

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.*;
import java.util.*;

public class t1{
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		String[] ary=new String[n];
		scan.nextLine();
		for(int i=0;i<n;i++){
			ary[i]=scan.nextLine();

		}
		int sum=0;
		for(int i=0;i<n;i++){
			switch(ary[i]){
				case "Tetrahedron":
					sum=sum+4;
					break;
				case "Cube":
					sum=sum+6;
					break;
				case "Octahedron":
					sum=sum+8;
					break;
				case "Dodecahedron":
					sum=sum+12;
					break;
				case "Icosahedron":
					sum=sum+20;
					break;
				default:
					sum=sum;
			}
		}

		System.out.println(sum);

	}

}


n,m=map(int,input().split())
min_val=9999999
for _ in range(m):
    y,x=map(int,input().split())
    if min_val>x-y:
        x1=x
        y1=y
        min_val=x-y
print(min_val+1)
L=[0]*n
tp=0
listNum=[]
for i in range(n):
    listNum.append(tp)
    tp+=1
    if tp>min_val:
        tp=0
for i in listNum[:-1]:
    print(i,end=' ')
print(listNum[-1])

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int Max = 1e6 + 100;
  for (int i = 0; i < m; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    Max = min(Max, r - l + 1);
  }
  cout << Max << endl;
  int sign = 0;
  for (int i = 0; i < n; i++) {
    cout << sign << " ";
    sign++;
    sign = sign % Max;
  }
  cout << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  if (n > a * b) return cout << -1, 0;
  for (int i = 0; i < n / b; ++i) {
    for (int j = 0; j < b; ++j)
      cout << (b % 2 ? i * b + j + 1
                     : (i % 2 ? (i + 1) * b - j : (i * b + j + 1)))
           << ' ';
    cout << '\n';
  }
  if (n % b) {
    if (b % 2 == 0 && n / b % 2) {
      for (int i = b - n % b; i--;) cout << "0 ";
      for (int i = n; i > n / b * b; --i) cout << i << ' ';
    } else {
      for (int i = n / b * b + 1; i <= n; ++i) cout << i << ' ';
      for (int i = b - n % b; i--;) cout << "0 ";
    }
    cout << '\n';
  }
  for (int i = a - (n + b - 1) / b; i--;) {
    for (int j = b; j--;) cout << "0 ";
    cout << '\n';
  }
  return 0;
}

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

public class CrocA {

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

		int n = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt(), c[] = new int[a * b];
		if(n > a * b)
			out.println(-1);
		else
		{
			for(int i = 0; i < n; ++i)
				c[i] = i + 1;
			int[][] grid = new int[a][b];
			if(a*b%2 != n%2)
				++n;

			if(b%2 == 0)
				for(int i = 0, k = 0; i < a; ++i)
				{
					if(i%2 == 0)
						for(int j = 0; j < b; ++j, ++k)
							grid[i][j] = c[k];
					else
						for(int j = b - 1; j >= 0; --j, ++k)
							grid[i][j] = c[k];
				}
			else
				for(int i = 0, k = 0; i < a; ++i)
					for(int j = 0; j < b; ++j, ++k)
							grid[i][j] = c[k];

			for(int i = 0; i < a; ++i)
			{
				for(int j = 0; j < b; ++j)
					out.print(grid[i][j] + " ");
				out.println();
			}
		}
		out.flush();
		out.close();

	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

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

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

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

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

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

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

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

	}
}


#include <bits/stdc++.h>
using namespace std;
const double exps = 1e-10;
const int INF = 0x3f3f3f3f;
int to_int(double x) { return round(x); }
int main() {
  double a, b;
  while (~scanf("%lf%lf", &a, &b)) {
    if (a < b) {
      printf("-1\n");
      continue;
    }
    double ans = INF;
    int k;
    k = (a - b) / (2 * b);
    if (k > 0) ans = (a - b) / (2.0 * k);
    ans = min(ans, (a + b) / (2.0 * (k + 1)));
    printf("%.12lf\n", ans);
  }
  return 0;
}

a,b=(int(i) for i in input().split())
if (a<b):
    print('-1')
elif (a==b):
    print(a)
else:
    i1=(a+b)//(2*b);
    i2=(a-b)//(2*b)
    if i2 is not 0:
        p=(a+b)/2
        q=(a-b)/2
        print(min(p/i1,q/i2))
    else:
        print((a+b)/(2*i1))


#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, m;
  cin >> w >> m;
  while (m > 0) {
    int r = m % w;
    if (r == 0)
      m = m / w;
    else if (r == 1)
      m = (m - 1) / w;
    else if (r == w - 1)
      m = (m + 1) / w;
    else {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  return 0;
}

2 42
```

Note that these are just random examples and not necessarily valid or invalid inputs based on the problem description.

YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES NO YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES NO YES YES YES YES YES YES YES YES YES YES

from sys import exit
w, m = map(int, input().split())
if w in (2, 3):
    print('YES')
    exit()

while True:
    if m in (0, 1):
        print('YES')
        exit()
    prev = 1
    cur = w
    while cur < m:
        prev = cur
        cur *= w
    if cur == m:
        print('YES')
        exit()
    sum1k = (cur - 1) // (w - 1)
    if sum1k < m < cur - sum1k:
        print('NO')
        exit()
    m = min(m - prev, cur - m)


n, k = map(int, input().split())
a = [1 for i in range(n + 1)]
a[n] = 0
for iter in range(k):
    for i in range(1, n - 1):
        target = n - i
        if a[i + 1] > target - a[i]:
            # find right number
            target -= a[i]
            print(n - target, end=' ')
            a[i] += a[n - target];
        else:
            a[i] += a[i + 1]
            print(i + 1, end=' ')
    for i in range(max(0, n - 2), n):
        print(n, end=' ')
    print()


#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double EPS = 1e-12;
int n, m;
struct NODE {
  int v, p;
} node[6000];
bool cmp(NODE a, NODE b) {
  if (a.v == b.v) return a.p < b.p;
  return a.v < b.v;
}
int a[6000];
int dp[5100];
int main() {
  scanf("%d%d", &n, &m);
  double tmp;
  for (int i = 0; i < n; i++) {
    scanf("%d%lf", &node[i].v, &tmp);
    node[i].p = i;
  }
  sort(node, node + n, cmp);
  for (int i = 0; i < n; i++) {
    a[node[i].p] = i;
  }
  int maxval = 1;
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i < n; i++) {
    dp[i] = 1;
    for (int j = i - 1; j >= 0; j--) {
      if (a[j] < a[i]) {
        if (dp[j] + 1 > dp[i]) {
          dp[i] = dp[j] + 1;
        }
      }
    }
    maxval = max(maxval, dp[i]);
  }
  printf("%d\n", n - maxval);
  return 0;
}

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

public class GreenhouseEffect
{
	static class C implements Comparator<Plant>
	{

		@Override
		public int compare(Plant arg0, Plant arg1)
		{
			return (int)Math.signum(arg0.x - arg1.x);
		}

	}

	static class Plant
	{
		int sp;
		double x;

		public Plant(int sp0, double x0)
		{
			sp = sp0;
			x = x0;
		}
	}

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

		int n = sc.nextInt();
		int m = sc.nextInt();
		Plant[] pl = new Plant[n];
		C c = new C();
		int[] a = new int[n];

		for(int i = 0; i < n; i++)
		{
			pl[i] = new Plant(sc.nextInt()-1, sc.nextDouble());
		}

		Arrays.sort(pl, c);

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

		long cc = 0;

		int[] mem = new int[m];

		for(int i = n-1; i >= 0; i--)
		{
			int cur = a[i];
			mem[cur]++;
			for(int j = cur-1; j >= 0; j--)
			{
				mem[j] = Math.max(mem[j], mem[cur]);
			}
		}

		for(int i = 0; i < m; i++)
		{
			cc = Math.max(cc, mem[i]);
		}

		System.out.println(n-cc);
	}

}


a1, b1, c1 = [int(i) for i in input().split()]
a2, b2, c2 = [int(i) for i in input().split()]

if c1 != c2 and (a1 == 0 and b1 == 0) and (a2 == 0 and b2 == 0) :
    print(0)
elif (a1 == 0 and b1 == 0 and c1 == 0) or (a2 == 0 and b2 == 0 and c2 == 0) :
    print(-1)
elif (a1 == 0 and b1 == 0 and c1 != 0) or (a2 == 0 and b2 == 0 and c2 != 0) and (c1 == c2):
    print(0)
elif a1 * b2 == b1 * a2 and b2 * c1 == c2 * b1 and c1 * a2 == c2 * a1 :
    print(-1)
elif ((a1 * b2) - (a2 * b1)) == 0:
    print(0)
else:
    print(1)


from collections import defaultdict
import sys

n,m=map(int,input().split())
s=input()
t=input()
dp=[[0 for i in range(m+1)] for j in range(n+1)]
for i in range(n):
    for j in range(m):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+2
        else:
            dp[i+1][j+1]=max(0,max(dp[i+1][j]-1,dp[i][j+1]-1))
ans=0
for i in range(n+1):
    for j in range(m+1):
        ans=max(ans,dp[i][j])
print(ans)

16 16 abababababababab babababababababab

17 17 ababababababababab bababababababababab

20 20 abababababababababab babababababababababab

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353, INF = 2E18 + 5;
const double PI = 2 * acos(0.0);
const long double EPS = 1.0E-14;
string s, t;
int dp[5005][5005];
int rec(int posS, int posT) {
  if (posS == 0 or posT == 0) return 0;
  if (dp[posS][posT] != -1) return dp[posS][posT];
  int ans = 0;
  if (s[posS - 1] == t[posT - 1]) {
    ans = max(ans, rec(posS - 1, posT - 1) + 2);
  } else {
    ans = max(ans, max(rec(posS - 1, posT) - 1, rec(posS, posT - 1) - 1));
  }
  return dp[posS][posT] = ans;
}
int main() {
  int n, m, ans = 0;
  cin >> n >> m >> s >> t;
  memset(dp, -1, sizeof dp);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      ans = max(ans, rec(i, j));
    }
  }
  cout << ans;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  int n;
  cin >> n;
  vector<pair<int, int>> v(n + 1), w(n);
  for (int i = 0; i < n; i++) cin >> v[i].first >> v[i].second;
  v.back() = v[0];
  for (int i = 0; i < n; i++) {
    w[i].first = v[i + 1].first - v[i].first;
    w[i].second = v[i + 1].second - v[i].second;
  }
  if (n % 2) {
    cout << "NO";
  } else {
    int k = n / 2;
    for (int i = 0; i < k; i++) {
      if (w[i].first + w[i + k].first != 0 or
          w[i].second + w[i + k].second != 0) {
        cout << "NO";
        return 0;
      }
    }
    cout << "YES";
  }
}

n = int(input())
if n % 2 == 0:
    a = [0]*n
    x1, y1 = list(map(int, input().split()))
    x11, y11 = x1, y1
    for i in range(n-1):
        x2, y2 = list(map(int, input().split()))
        a[i] = [x2-x1, y2-y1]
        x1, y1 = x2, y2
    a[n-1] = [x11-x2, y11-y2]
    fl = True
    for i in range(int(n/2)):
        if fl and ((a[i][0] == -a[int(n/2)+i][0]) and (a[i][1] == -a[int(n/2)+i][1])):
            pass
        else:
            fl = False
    if fl:
        print("YES")
    else:
        print("NO")
else:
    for i in range(n):
        a = input()
    print("NO")


from itertools import product

def main():
    n, s, t = int(input()), input(), input()
    print('YES')
    abc = ('abc', 'acb', 'bac', 'bca', 'cab', 'cba')
    if s[0] != s[1] and t[0] != t[1]:
        for p in abc:
            if s not in p and t not in p:
                print(p[0] * n, p[1] * n, p[2] * n, sep='')
                return
    for pp in product(abc, repeat=min(n, 2)):
        p = f'{pp[0]}{pp[-1]}{pp[0]}'[:min(n, 3) * 3]
        if s not in p and t not in p:
            break
    print((p[:6] * ((n + 1) // 2))[:n * 3])

if __name__ == '__main__':
    main()

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

public class E582TwoSmallStrings {

    static PrintWriter pr = new PrintWriter(System.out);
    public static class InputReader {
        private BufferedReader reader;
        private 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 static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        int n = in.nextInt();
        String s = in.next();
        String t = in.next();

        ans(n,s,t);
        pr.flush();
    }

    private static void ans(int n, String s, String t) {

        String[] buf = { "abc", "acb", "cba", "bca", "bac", "cab"};

        ArrayList<String> list = new ArrayList<>();
        for (int i = 0; i < 6; i++) {

            StringBuilder str = new StringBuilder();

            for (int j = 0; j < n; j++) {
                str.append(buf[i]);
            }

            list.add(new String(str));
            str = new StringBuilder();

            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < n; k++) {
                    str.append(buf[i].charAt(j));
                }
            }
            list.add(new String(str));
        }

        for (String str: list) {
            if (!str.contains(s) && !str.contains(t)){
                pr.println("YES");
                pr.print(str);
                return;
            }
        }

        pr.print("NO");
    }
}


#include <bits/stdc++.h>
bool debug = true;
using namespace std;
static auto start = chrono::high_resolution_clock::now();
int prime(int n) {
  int i, j;
  for (i = 2; i * i <= n; i++) {
    if (!(n % i)) return 0;
  }
  return 1;
}
int main(void) {
  if (0) {
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
  }
  int i, j, k, n, m, mx;
  scanf("%d", &n);
  m = n;
  mx = (n * (n - 1)) >> 1;
  for (; m <= mx; m++) {
    if (prime(m)) break;
  }
  printf("%d\n", m);
  for (i = 0; i < n; i++) {
    printf("%d %d\n", i + 1, ((i + 1) % n) + 1);
  }
  m -= n;
  vector<int> vis(n);
  for (i = 0; i < n - 2; i++) {
    if (!m) break;
    if (!vis[i]) {
      vis[i + 2] = true;
      printf("%d %d\n", i + 1, i + 3);
      m--;
    }
  }
  auto stop = chrono::high_resolution_clock::now();
  auto duration = chrono::duration_cast<chrono::microseconds>(stop - start);
  if (0) {
    printf("Time in seconds: %.6lf\n", (double)duration.count() / 1000000);
  }
}

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while (p * p <= n):
		if (prime[p] == True):

			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	pp=[]
	for p in range(2, n + 1):
		if prime[p]:
			pp.append(p)
	return pp
def f(n):
	Primes=SieveOfEratosthenes(10000)
	deg=0
	for i in Primes:
		if i>=n:
			deg=i
			break
	a=[]
	cnt=[0]*(n)
	cnt[0]+=1
	cnt[n-1]+=1
	a.append((1,n))
	for i in range(n-1):
		a.append((i+1,i+2))
		cnt[i]+=1
		cnt[i+1]+=1
	req=deg-len(a)
	l=0
	r=n-2
	c=2
	for i in range(req):
		a.append((l+1,r+1))
		cnt[l]+=1
		cnt[r]+=1
		if r==l+1:
			l=0
			c+=1
			r=n-c
		else:
			l+=1
			r-=1
	print(len(a))
	for i in a:
		print(*i)
	return ''
print(f(int(input())))


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;

public class newA {
	static FastReader scan = new FastReader();
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		Solver solver = new Solver();
		int testCases = 1;
		while (testCases-- > 0) solver.solve();
		out.close();
	}

	static class Solver {
		void solve() {
			int n = scan.nextInt();
			int[] a = scan.nextIntArray(n);
			long res = 0;
			for(int i = n-1; i > 0; i--) {
				if(a[i] + a[i-1] == 5) {
					out.println("Infinite");
					return;
				}
				if(a[i] == 1) res += a[i-1]+1;
				else if(a[i] == 3) res += 4;
				else {
					res += 3;
					if(i-2>=0&&a[i-1]==1&&a[i-2]==3)res--;
				}
			}
			out.println("Finite");
			out.println(res);
		}

	}

	//Sathvik's Template Stuff BELOW!!!!!!!!!!!!!!!!!!!!!!

	static class DSU {
		int[] root, size;
		int n;
		DSU(int n) {
			this.n = n;
			root = new int[n];
			size = new int[n];
			for(int i = 0; i < n; i++) {
				root[i] = i;
				size[i] = 1;
			}
		}
		int findParent(int idx) {
			while(root[idx] != idx) {
				root[idx] = root[root[idx]];
				idx = root[idx];
			}
			return idx;
		}
		boolean union(int x, int y) {
			int parX = findParent(x);
			int parY = findParent(y);
			if(parX == parY) return false;
			if(size[parX] < size[parY]) {
				root[parY] = parX;
				size[parX] += size[parY];
			} else {
				root[parX] = parY;
				size[parY] += size[parX];
			}
			return true;
		}
	}

	static class Extra {
		static void sort(int[] a) {
			Integer[] aa = new Integer[a.length];
			for (int i = 0; i < aa.length; i++) aa[i] = a[i];
			Arrays.sort(aa);
			for (int i = 0; i < aa.length; i++) a[i] = aa[i];
		}
		static void sort(long[] a) {
			Long[] aa = new Long[a.length];
			for (int i = 0; i < aa.length; i++) aa[i] = a[i];
			Arrays.sort(aa);
			for (int i = 0; i < aa.length; i++) a[i] = aa[i];
		}
		static void sort(double[] a) {
			Double[] aa = new Double[a.length];
			for (int i = 0; i < aa.length; i++) aa[i] = a[i];
			Arrays.sort(aa);
			for (int i = 0; i < aa.length; i++) a[i] = aa[i];
		}
		static void sort(char[] a) {
			Character[] aa = new Character[a.length];
			for (int i = 0; i < aa.length; i++) aa[i] = a[i];
			Arrays.sort(aa);
			for (int i = 0; i < aa.length; i++) a[i] = aa[i];
		}
		static long gcd(long a, long b) {
			while(b > 0) {
				long temp = b;
				b = a%b;
				a = temp;
			}
			return a;
		}
		static long lcm(long a, long b) {
			return a * (b / gcd(a,b));
		}
		static boolean isPrime(long n) {
			if (n <= 1) return false;
	        if (n <= 3) return true;
	        if (n % 2 == 0 || n % 3 == 0) return false;
	        for (long i = 5; i * i <= n; i = i + 6) {
	            if (n % i == 0 || n % (i + 2) == 0) return false;
	        }
	        return true;
		}
		static HashSet<Integer> sieve(int n) {
			boolean[] prime = new boolean[n+1];
			HashSet<Integer> res = new HashSet<>();
			for(int p = 2; p*p <= n; p++) {
				if(!prime[p]) {
					res.add(p);
					for(int i = p*p; i <= n; i+=p) prime[i] = true;
				}
			}
			return res;
		}
		static HashMap<Long, Integer> primeFactorization(long n) {
			HashMap<Long, Integer> res = new HashMap<>();
			while(n % 2 == 0) {
				res.put(2L, res.getOrDefault(2L, 0)+1);
				n/=2;
			}
			for(long i = 3; i*i <= n; i+=2) {
				while(n % i == 0) {
					res.put(i, res.getOrDefault(i, 0)+1);
					n/=i;
				}
			}
			if(n > 2) res.put(n, 1);
			return res;
		}
	}

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

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

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

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

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

		double[] nextDoubleArray(int n) {
			double[] a = new double[n];
			for (int i = 0; i < n; i++)
				a[i] = nextDouble();
			return a;
		}

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

}

n = int(input())
sh = list(map(int, input().split()))
sh += [0]
ans = ""
el = 0
for i in range(n - 1):
	if len(sh) >= 3:
		if sh[i] == 3 and sh[i + 1] == 1 and sh[i + 2] == 2:
			el -= 1
	if sh[i] == 2 and sh[i + 1] == 3 or sh[i] == 3 and sh[i + 1] == 2:
		ans = "Infinite"
		break
	elif sh[i] == 1 and sh[i + 1] == 2 or sh[i] == 2 and sh[i + 1] == 1:
		el += 3
	else:
		el += 4
if ans == "Infinite":
	print(ans)
	exit()
else:
	print("Finite") ; print(el)


#include <bits/stdc++.h>
using namespace std;
int n;
char s[200];
int ucnt, rcnt;
int main() {
  scanf("%d", &n);
  getchar();
  gets(s);
  int ans = strlen(s);
  for (int i = 0; i < n - 1; i++) {
    if ((s[i] == 'U' && s[i + 1] == 'R') || (s[i] == 'R' && s[i + 1] == 'U'))
      i++, ans--;
  }
  cout << ans << endl;
}

n = int(input())
s = str(input())
l = len(s)
prev = '';
for i in s:
    if prev=='':
        prev = i
        continue
    if (i=='U' and prev =='R') or (i=='R' and prev =='U'):
        l=l-1
        prev = ''
    else:
        prev = i
print(l)


a, b = input().split()
t = int(input())

d = dict()
d["^"] = 0
d[">"] = 1
d["v"] = 2
d["<"] = 3

a, b = d[a], d[b]
t = t % 4
if t == 2 or t == 0:
    print("undefined")
else:
    if t == 1:
        if (b-1) % 4 == a:
            print("CW".lower())
        else:
            print("CCW".lower())
    elif t == 3:
        if (b+1) % 4 == a:
            print("CW".lower())
        else:
            print("CCW".lower())

cw undefined undefined cw undefined undefined ccw cw

import java.util.Scanner;

public class Spinner {
	private static Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		Spinner s = new Spinner();
		String answer = new String();
		SpinPosition initialPosition = s.new SpinPosition(in.next().charAt(0));
		SpinPosition finalPosition = s.new SpinPosition(in.next().charAt(0));
		long time = in.nextLong();
		time %= 4;
		int clockWise = (finalPosition.positionOrder > initialPosition.positionOrder) ? finalPosition.positionOrder - initialPosition.positionOrder
																					  :  4 - Math.abs(finalPosition.positionOrder - initialPosition.positionOrder);
		int counterCW = (finalPosition.positionOrder > initialPosition.positionOrder) ?  4 - Math.abs(finalPosition.positionOrder - initialPosition.positionOrder)
				  : Math.abs(finalPosition.positionOrder - initialPosition.positionOrder);
		if(time == 0 || clockWise == counterCW)
		{
			answer = "undefined";
		}
		else
		{
			if(time - clockWise == 0)
			{
				answer = "cw";
			}
			else if(time - counterCW == 0)
			{
				answer = "ccw";
			}
			else
			{
				answer = "undefined";
			}
		}
		System.out.println(answer);
	}

	public class SpinPosition
	{
		int positionOrder;
		char position;
		public SpinPosition(char x)
		{
			position = x;
			if(position == 'v')
			{
				positionOrder = 1;
			}else if(position == '<') {
				positionOrder = 2;
			}else if (position == '^') {
				positionOrder = 3;
			}else {
				positionOrder = 4;
			}
		}
	}

}


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

public class App {
	public static PrintWriter out;
	static int s = Integer.MIN_VALUE;
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));

		/* My brute force way of doing it.
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0;i<n;i++) {
			a[i] = sc.nextInt();
		}
		for(int r = 1; r < n; r++) {
			for(int l = 0;l < r; l++) {
				s = Math.max(s, f(a,l,r));
			}
		}
		out.println(s);
		*/

		/*
		 * Alright, the function works like this:
		 * You have an array. l, r are the start and end indices within which you perform your calculation.
		 * The calculate takes the first value (a[i]) and finds the absolute difference with the next value (a[i+1]).
		 * From this absolute difference, it subtracts the next absolute difference ( a[i+1],a[i+2]), then adds the next, then subtracts, then adds, ad mortem.
		 *
		 * Now you begin to understand why it's useful to have an array of differences. You simply add the elements in this array!
		 *
		 * The non brute force idea, is to generate all possibilities as fast as possible, using divide and conquer.
		 * It first sets out the two cases, which arise from the fact that the position of the bounds affect the numerical values of the arrays of the differences.
		 *
		 * E.g. if the array is [1,4,2,3,1], then the two possible arrays of differences are:
		 * 1. [3,-2,1,-2] or 2. [-3,2,-1,2]
		 * For bound(0,2), this falls into case 1; 3 + -2
		 * For bound(1,2), this falls into case 2; 2
		 * For bound(3,4), this falls into case 2; 2.
		 * For bound(i,whatever), if differenceArray[i] == positive, then that is the case it falls into.
		 *
		 *
		 *
		 *
		 */

		int n = sc.nextInt();
		long[] arr1 = new long[n-1];
		long[] arr2 = new long[n-1];
		long[] a = new long[n];
		for(int i = 0; i< n ; i++) {
			a[i] = sc.nextInt();
			if(i!=0) {
				long vv = Math.abs(a[i-1] - a[i]);
				if(i%2 == 1) {
					arr1[i-1] = vv;
					arr2[i-1] = -vv;
				}else {
					arr1[i-1] = -vv;
					arr2[i-1] = vv;
				}
			}
		}
		out.println(Math.max(find_max(arr1,0,n-2),find_max(arr2,0,n-2)));

		//Tests
		//long[] x = new long[] {-4,0};
		//out.println(cross(x,0,1,1));
		//out.println(find_max(new long[] {-500,1,500,1,-500},0,4));

		out.close();

	}
	/*
	 * Here's how find_max works. The basic idea is to compare:
	 *
	 *  the greatest possible positive sum returned from the left array,
	 *  with the greatest possible positive sum returned from the right array,
	 *  with the sum of the combined arrays.
	 *
	 * The bounds will simply fall into place.
	 * 			If the sum returned from the left array is the greatest greatest value, then the bounds will be within the left array.
	 * 			Likewise for the right array.
	 * 			If the sum of the combined arrays (not the sum of the greatest possible positive sums) is the greatest value, then the bounds will be the full array.
	 *
	 * Here's a simple breakdown:
	 * For the array [1,4,2,3,1], the two arrays of differences are:
	 * 		arr1 = [3,-2,1,-2] or arr2 = [-3,2,-1,2]
	 *
	 * arr1 = [3,-2,1,-2]:
	 * [3,-2]        			and      [1,-2]
	 * [3] and [2]						[1] and [-2]
	 * Compare above three			Compare above three
	 * ^ returns 3					^ returns 1
	 *
	 * 			Compare 3,1 and sum of [3,-2,1,-2]
	 *          ^ returns 3;
	 * Therefore for arr1, the max is 3, and this corresponds to the bounds(0,1);
	 *
	 *
	 */
	private static long find_max(long[] arr, int low, int high) {

		// Some recursion
		if(high == low) {
			return arr[low];
		}
		int mid = (low+high)/2;

		long lm = find_max(arr,low,mid); // huh divide and conquer
		long rm = find_max(arr,mid+1,high);
		long com = cross(arr,low,mid,high); // Finding the greatest possible positive sum for this array.
		com = Math.max(com, lm); // Comparison betwen the three values.
		com = Math.max(com, rm);

		return com;
	}
	// This function is a helper function that finds the greatest possible positive sum of the array.
	private static long cross(long[] arr, int low, int mid, int high) {
		long leftsum = Long.MIN_VALUE;
		long leftsum1 = Long.MIN_VALUE;
		long sum = 0;
		for(int i = mid;i>=low;i--) {
			sum = sum + arr[i];
			if(sum>leftsum1) {
				leftsum1 = sum;
			}
		}
		long rightsum = Long.MIN_VALUE;
		long rightsum1 = Long.MIN_VALUE;
		sum = 0;
		for(int i = mid + 1;i<=high;i++) {
			sum = sum + arr[i];
			if(sum>rightsum1) {
				rightsum1 = sum;
			}
		}
		if(rightsum1<=0) {
			rightsum1 = 0;
		}
		return Math.max(0, leftsum1+rightsum1);
	}
	private static int f(int[] a,int l, int r) {
		int sum = 0;
		for(int i = l; i < r ; i++) {

			sum = (int) (sum + Math.abs(a[i]-a[i+1]) * Math.pow(-1, i-l));

		};
		return sum;
	}

}

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

#include <bits/stdc++.h>
using namespace std;
int n, a[100005];
long long b[100005], dpMax[100005], dpMin[100005], ans = (1ll << 63);
void setup() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n - 1; i++) b[i] = abs(a[i] - a[i + 1]);
  n--;
}
void xuly() {
  for (int i = n; i >= 1; i--) {
    dpMax[i] = -min(dpMin[i + 1], 0ll) + b[i];
    dpMin[i] = -max(dpMax[i + 1], 0ll) + b[i];
    ans = max(ans, dpMax[i]);
  }
  cout << ans;
}
int main() {
  iostream::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  setup();
  xuly();
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  printf("YES\n");
  for (int i = 0; i < n; i++) {
    int arr[4];
    for (int j = 0; j < 4; j++) {
      scanf("%d", &arr[j]);
    }
    int x = arr[0] % 2;
    if (x < 0) x = 1;
    int y = arr[1] % 2;
    if (y < 0) y = 1;
    printf("%d\n", (2 * x) + (y) + 1);
  }
}

'''plan
    noticed that if both upperle
'''
from sys import stdin, stdout
# n = int(stdin.readline().rstrip())
# n = int(input())

all_lines = stdin.read().split('\n')
stdout.write('YES\n')
for line in all_lines[1:-1]:
    x1, y1, x2, y2 = (int(x) % 2 for x in line.split())
    num = 2 * x2 + y2 + 1
    # stdout.write(str(x2) + ' ' + str(y2) + '\n')
    print(num)
#stdout.flush()
#exit()

# for i in range(n):
    # coordinates.append([int(x) % 2 for x in input().split()])
# for i in range(n):
    # coordinates.append([int(x) % 2 for x in stdin.readline().rstrip().split()])
# stdout.write('YES\n')
# for coordinate in coordinates:
    # x1, y1, x2, y2 = coordinate
    # stdout.write(str(2 * x2 + y2 + 1) + '\n')


def gen_prime(n):
	prime = []
	prime.append(2)
	prime.append(3)
	prime.append(4)

	for i in range(5, n+1):
		div = False
		for j in prime:
			if not i%j:
				div = True
				break
		if not div:
			prime.append(i)

	return prime

n = int(input())
prime = gen_prime(n)
prime = prime[1:]
prime.append(n)
a = [int(i) for i in input().split()]

possible = False
for i in prime:
	if not n%i:
		found = False
		l = n//i
		for k in range(0, l):
			mood = True
			for j in range(k, n, l):
				if not a[j]:
					mood = False
					break
			if mood:
				found = True
				break
		if found:
			possible = True
			break

if possible:
	print("YES")
else:
	print("NO")

YES YES YES NO YES YES YES YES YES YES YES NO NO NO YES YES YES YES YES YES YES NO NO YES YES YES YES NO YES YES NO YES YES YES YES NO YES YES YES YES YES YES YES YES YES YES

import java.util.Scanner;

public class P071C {

    public static void main(String[] args) {
        Scanner inScanner = new Scanner(System.in);
        int n = inScanner.nextInt();
        int[] moods = new int[n];
        for (int i = 0; i < n; i++) {
            moods[i] = inScanner.nextInt();
        }
        for (int vertices = 3; vertices <= n; vertices++) {
            if (n % vertices != 0)
                continue;
            int step = n / vertices;
            tryLoop: for (int offset = 0; offset < step; offset++) {
                for (int vertice = offset; vertice < n; vertice += step)
                    if (moods[vertice] == 0)
                        continue tryLoop;
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }
}


def digits(n):
    rd = []
    while n:
        n, d = divmod(n, 10)
        rd.append(d)
    return list(reversed(rd))

def _ifs(dn, i, j, ci, cj, al, ar):
    while i < j:
        di = dn[i] + 10*ci
        dj = dn[j] - cj
        for (ci, cj) in ((0, 0), (0, 1), (1, 0), (1, 1)):
            d = di - ci
            if d < 0 or d > 18:
                continue
            if dj + 10*cj == d:
                if d < 10:
                    if d == 0 and not al:
                        return
                    al.append(d)
                    ar.append(0)
                else:
                    al.append(9)
                    ar.append(d-9)
                break
        else:
            return
        i += 1
        j -= 1

    if i == j:
        d = dn[i] + 10*ci - cj
        if d < 0 or d % 2:
            return
        al.append(d//2)
    else:
        if ci != cj:
            return

    return al + list(reversed(ar))

def inv_fsum(dn):
    if dn[0] == 1:
        return (_ifs(dn, 0, len(dn)-1, 0, 0, [], []) or
                _ifs(dn, 1, len(dn)-1, 1, 0, [], []) or
                [0])
    else:
        return _ifs(dn, 0, len(dn)-1, 0, 0, [], []) or [0]

if __name__ == '__main__':
    dn = tuple(map(int, input()))
    print(''.join(map(str, inv_fsum(dn))))


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

public class sequence {

    /**
     * @param args
     * @throws IOException
     * @throws NumberFormatException
     */
    public static void main(String[] args) throws NumberFormatException,
            IOException {
        BufferedReader str = new BufferedReader(
                new InputStreamReader(System.in));
        int n = Integer.parseInt(str.readLine());
        PrintWriter out = new PrintWriter(System.out);

        int[] arr = new int[3];
        StringTokenizer input = new StringTokenizer(str.readLine());
        for (int i = 0; i < n; i++) {

            int x = Integer.parseInt(input.nextToken());
            arr[(x - 1)]++;

        }
        int max = 0;
        max = Math.max(arr[0], Math.max(arr[1], arr[2]));
        out.println(n - max);
        out.close();

    }

}

#include <bits/stdc++.h>
using namespace std;
int arr[4];
int main() {
  int n, a;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    arr[a]++;
  }
  return printf("%d\n", n - max(max(arr[1], arr[2]), arr[3])), 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[4];
int main() {
  string s;
  int suma = 0, sumb = 0, sumc = 0, sumd = 0;
  bool o1 = false, o2 = false;
  cin >> s;
  a[0] = suma = s.length() - 2;
  cin >> s;
  a[1] = sumb = s.length() - 2;
  cin >> s;
  a[2] = sumc = s.length() - 2;
  cin >> s;
  a[3] = sumd = s.length() - 2;
  int i, j, re = 0, ve = 0, in = 2;
  for (i = 0; i < 4; i++) {
    re = 0;
    ve = 0;
    for (int j = 0; j < 4; j++) {
      if (i != j && a[i] >= 2 * a[j]) re++;
      if (i != j && a[i] * 2 <= a[j]) ve++;
    }
    if (re == 3) {
      in = i;
      o1 = true;
    }
    if (ve == 3) {
      in = i;
      o2 = true;
    }
  }
  if (o1 && o2) {
    cout << "C";
    return 0;
  }
  if (in == 0) cout << "A";
  if (in == 1) cout << "B";
  if (in == 2) cout << "C";
  if (in == 3) cout << "D";
  return 0;
}

A.____JGWsfiU
B.S_LMq__MpE_oFBs_P
C.U_Rph_VHpUr____X_jWXbk__ElJTu_Z_wlBpKLTD
D.p_ysvPNmbrF__

A._LYm_nvl_E__RCFZ_IdO
B.k__qIPO_ivvZyIG__L_
C.D_SabLm_R___j_HS_t__
D._adj_R_ngix____GSe_aw__SbOOl_

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

 static class InputReader {

        final private int BUFFER_SIZE = 1 << 17;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public InputReader(InputStream in) {
            din = new DataInputStream(in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public byte next() {
            try {
                return read();
            } catch (Exception e) {
                throw new InputMismatchException();
            }
        }

        public String nextString() {
            StringBuilder sb = new StringBuilder("");
            byte c = next();
            while (c <= ' ') {
                c = next();
            }
            do {
                sb.append((char) c);
                c = next();
            } while (c > ' ');
            return sb.toString();
        }

        public int nextInt() {
            int ret = 0;
            byte c = next();
            while (c <= ' ') {
                c = next();
            }
            boolean neg = c == '-';
            if (neg) {
                c = next();
            }
            do {
                ret = (ret << 3) + (ret << 1) + c - '0';
                c = next();
            } while (c > ' ');
            if (neg) {
                return -ret;
            }
            return ret;
        }

        private void fillBuffer() {
            try {
                bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (bytesRead == -1) {
                buffer[0] = -1;
            }
        }

        private byte read() {
            if (bufferPointer == bytesRead) {
                fillBuffer();
            }
            return buffer[bufferPointer++];
        }
    }
    static int cc=0;
    public static void main(String[] args) throws NumberFormatException, IOException {

 BufferedReader r=new BufferedReader(new InputStreamReader(System.in));
    //   InputReader r=new InputReader(System.in);

PrintWriter pr=new PrintWriter(System.out);
int a=r.readLine().length()-2;
int b=r.readLine().length()-2;
int c=r.readLine().length()-2;
int d=r.readLine().length()-2;

int p[]={a,b,c,d};

int max=-1;
int min=Integer.MAX_VALUE;
int indmin=-1,indmax=-1;

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

	if(max<p[i])
	{
		max=p[i];
		indmax=i;

	}
	if(min>p[i])
	{
		min=p[i];
		indmin=i;
	}

}

int flag=0;
for(int i=0;i<4;i++)
{
	if(i!=indmin&&min*2>p[i])
	{
		flag=1;
		break;
	}

}
char ch[]={'A','B','C','D'};

int flag1=0;
for(int i=0;i<4;i++)
{
	if(i!=indmax&&max<p[i]*2)
	{
		flag1=1;
		break;
	}

}
if(flag1==flag)
pr.println("C");
else
	if(flag1==0)
{
	pr.println(ch[indmax]);
	pr.flush();
	pr.close();
return;
}
	else
if(flag==0)
{
	pr.println(ch[indmin]);
	pr.flush();
	pr.close();
return;
}

 pr.flush();
 pr.close();

}
}


#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import*
from io import BytesIO, IOBase
def vsInput():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
def value():return tuple(map(int,input().split()))
def array():return [int(i) for i in input().split()]
def Int():return int(input())
def Str():return input()
def arrayS():return [i for i in input().split()]

#-------------------------code---------------------------#
#vsInput()

def possible(s):

    last={i:a[i] for i in range(s)}

    for i in range(s,n,s):
        for j in range(0,s):
            if(last[j]==0):
                return False
            else:
                last[j]=min(last[j]-1,a[i+j])
            if(i+j+1==n):
                break

    return True

n=Int()
a=sorted(array(),reverse=True)

low=1
high=n

while(low<=high):

    mid=low+(high-low)//2

    if(possible(mid)):
        ans=mid
        high=mid-1
    else:
        low=mid+1

print(ans)

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

public class CSolver {
  private static InputReader in;
  private static PrintWriter out;

  public static void main(String[] args) throws IOException {
    InputStream is = System.in;
    PrintWriter pw = new PrintWriter(System.out);
    init(is, pw);
    solve();
    is.close();
    out.close();
  }

  public static void init(InputStream is, PrintWriter pw) {
    in = new InputReader(is);
    out = pw;
  }

  static int n;
  static int[] boxesCount;

  public static void solve() {
    int n = in.ni();
    boxesCount = new int[101];

    for (int i = 0; i < n; i++) {
      boxesCount[in.ni()]++;
    }

    int count = 0;

    for (; !arePiled(); count++) {
      int boxesCountSoFar = 0;
      for (int i = 0; i <= 100; i++) {
        if (boxesCount[i] > 0) {
          int canLift = Math.min(i - boxesCountSoFar, boxesCount[i] - 1);
          //          System.out.println(i + " " + canLift);

          boxesCountSoFar += 1 + canLift;
          boxesCount[i] -= 1 + canLift;
        }
      }
    }

    out.println(count);
  }

  static boolean arePiled() {
    for (int i = 0; i <= 100; i++) {
      if (boxesCount[i] > 0) {
        return false;
      }
    }
    return true;
  }

  private static class InputReader {
    BufferedReader br;
    StringTokenizer st;

    InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }

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

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

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

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


#include <bits/stdc++.h>
using namespace std;
int n, d;
int dp[1130000];
int main() {
  scanf("%d %d", &n, &d);
  int s = 0;
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    int ci;
    scanf("%d", &ci);
    s += ci;
    for (int v = s; v >= ci; v--) {
      dp[v] |= dp[v - ci];
    }
  }
  int lla = -1e9;
  int la = 0;
  int days = 0;
  for (int i = 1; i <= s; i++) {
    if (dp[i] && i - la <= d) {
      if (i - lla > d) {
        days++;
        lla = la;
      }
      la = i;
    }
  }
  printf("%d %d\n", la, days);
}

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

public class Main{

    BufferedReader in;
    StringTokenizer str = null;
    PrintWriter out;

    private String next() throws Exception{
    	if (str == null || !str.hasMoreElements())
    	    str = new StringTokenizer(in.readLine());
    	return str.nextToken();
    }

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

    public void run() throws Exception{
    	in = new BufferedReader(new InputStreamReader(System.in));
    	out = new PrintWriter(System.out);
	int n = nextInt();
	int d = nextInt();
	int c[] = new int[n];
	int sum = 0;
	for(int i=0;i<n;i++){
	    c[i] = nextInt();
	    sum+=c[i];
	}
	boolean f[][] = new boolean[n+1][sum+1];
	f[0][0] = true;
	for(int i=1;i<=n;i++){
	    for(int j=0;j<=sum;j++){
		f[i][j] = f[i-1][j];
		if (j - c[i-1] >=0){
		    f[i][j]|=f[i-1][j-c[i-1]];
		}
	    }
	}

	int r = 0, days = 0;
	while(true){
	    int next = -1;
	    for(int i=Math.min(r + d, sum);i>r;i--){
		if (f[n][i]){
		    next = i;
		    break;
		}
	    }
	    if (next == -1) break;
	    r = next;
	    days++;
	}

	out.println(r + " " + days);
	out.close();
    }

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


import static java.lang.Math.*;

//@SuppressWarnings("unused")
public class D {

	private final static boolean autoflush = false;

	private static final int INF = (int) 1e9;

	public D () {
		N = sc.nextInt();
		M = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		char [] dir = sc.nextChars();

		int dx = dir[0] == 'D' ? 1 : -1;
		int dy = dir[1] == 'R' ? 1 : -1;

		W = new int [] { X, Y };
		T = new int [] { dx, dy };

		A = new int [N]; B = new int [N];
		C = new int [M]; D = new int [M];

		Z = 2 * (N/2 + M/2); int P = (X+Y) % 2;
		if (N % 2 == 1 && P == 0) ++Z;
		if (N % 2 == 1 && P == (1 + M) % 2) ++Z;
		if (M % 2 == 1 && P == 0) ++Z;
		if (M % 2 == 1 && P == (1 + N) % 2) ++Z;

		long res = 1;
		for (;;) {
			if (mark())
				break;
			res += next();
		}

		exit(res);
	}

	private int N, M, Z, K = 0;
	private int [] A, B, C, D, W, T;

	private int next() {
		int X = W[0], Y = W[1];
		int dx = T[0], dy = T[1];

		if (X == 1) dx =  1;
		if (X == N) dx = -1;
		if (Y == 1) dy =  1;
		if (Y == M) dy = -1;

		int t = INF;
		if (dx ==  1) t = min(t, N - X);
		if (dx == -1) t = min(t, X - 1);
		if (dy ==  1) t = min(t, M - Y);
		if (dy == -1) t = min(t, Y - 1);

		X += t * dx; Y += t * dy;

		W[0] = X; W[1] = Y;
		T[0] = dx; T[1] = dy;

		return t;
	}

	private boolean mark() {
		int X = W[0], Y = W[1];
		boolean res = false;
		if (Y == 1)
			res = res || inc(A, X);
		if (Y == M)
			res = res || inc(B, X);
		if (X == 1)
			res = res || inc(C, Y);
		if (X == N)
			res = res || inc(D, Y);
		return res;
	}

	private boolean inc(int [] A, int X) {
		--X; if (A[X] == 0) ++K; ++A[X];
		if (A[X] == 3)
			exit(-1);
		return K == Z;
	}

	////////////////////////////////////////////////////////////////////////////////////
	private static int [] rep(int N) { return rep(0, N); }
	private static int [] rep(int S, int T) { int [] res = new int [max(T-S, 0)]; for (int i = S; i < T; ++i) res[i-S] = i; return res; }
	private static <T extends Comparable<T>> T max(T x, T y) { return x.compareTo(y) > 0 ? x : y; }
	////////////////////////////////////////////////////////////////////////////////////
	private final static MyScanner sc = new MyScanner();
	private static class MyScanner {
		private String next() {
			newLine();
			return line[index++];
		}
		private int nextInt() {
			return Integer.parseInt(next());
		}
		private char [] nextChars() {
			return next ().toCharArray ();
		}
		//////////////////////////////////////////////
		private boolean eol() {
			return index == line.length;
		}
		private String readLine() {
			try {
				return r.readLine();
			} catch (Exception e) {
				throw new Error (e);
			}
		}
		private final java.io.BufferedReader r;
		private MyScanner () {
			this(new java.io.BufferedReader(new java.io.InputStreamReader(System.in)));
		}
		private MyScanner (java.io.BufferedReader r) {
			try {
				this.r = r;
				while (!r.ready())
					Thread.sleep(1);
				start();
			} catch (Exception e) {
				throw new Error(e);
			}
		}
		private String [] line;
		private int index;
		private void newLine() {
			if (line == null || eol()) {
				line = readLine().split(" ");
				index = 0;
			}
		}
	}
	private static void print (Object o, Object... a) {
		printDelim(" ", o, a);
	}
	private static void printDelim (String delim, Object o, Object... a) {
		pw.println(build(delim, o, a));
	}
	private static void exit (Object o, Object... a) {
		print(o, a);
		exit();
	}
	private static void exit() {
		pw.close();
		System.out.flush();
		System.err.println("------------------");
		System.err.println("Time: " + ((millis() - t) / 1000.0));
		System.exit(0);
	}
	////////////////////////////////////////////////////////////////////////////////////
	private static String build (String delim, Object o, Object... a) {
		StringBuilder b = new StringBuilder();
		append(b, o, delim);
		for (Object p : a)
			append(b, p, delim);
		return b.toString().trim();
	}
	private static void append(StringBuilder b, Object o, String delim) {
		if (o.getClass().isArray()) {
			int L = java.lang.reflect.Array.getLength(o);
			for (int i : rep(L))
				append(b, java.lang.reflect.Array.get(o, i), delim);
		} else if (o instanceof Iterable<?>)
			for (Object p : (Iterable<?>)o)
				append(b, p, delim);
		else
			b.append(delim).append(o);
	}
	////////////////////////////////////////////////////////////////////////////////////
	private static void start() {
		t = millis();
	}
	private static java.io.PrintWriter pw = new java.io.PrintWriter(System.out, autoflush);
	private static long t;
	private static long millis() {
		return System.currentTimeMillis();
	}
	public static void main (String[] args) {
		new D();
		exit();
	}
}

#include <bits/stdc++.h>
using namespace std;
int n, m, s, t, x, y;
long long ans;
set<pair<int, int> > st;
int rd() {
  char c;
  while (c = getchar(), c < 'A')
    ;
  return c;
}
int main() {
  scanf("%d%d%d%d", &m, &n, &t, &s);
  y = (rd() == 'D') ? 1 : -1, x = (rd() == 'R') ? 1 : -1;
  ans = 1;
  for (int i = 1; i <= 2 * (n + m); i++) {
    st.insert(pair<int, int>(s, t));
    if (s == 1) x = 1;
    if (s == n) x = -1;
    if (t == 1) y = 1;
    if (t == m) y = -1;
    if (st.size() >= n + m - 2) return printf("%I64d\n", ans), 0;
    int z = min(x > 0 ? n - s : s - 1, y > 0 ? m - t : t - 1);
    ans += z, s += x * z, t += y * z;
  }
  return puts("-1"), 0;
}


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

public class Matrix {

	public static void main(String[] args) throws java.lang.Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(in, out);
		out.close();
	}
}

class TaskA {
	public final static int maxn = 505;
	public final static int maxm = 100005;
	int[][] M = new int[maxn][maxn];
	boolean[] visit = new boolean[maxm];
	int[] inc = new int[maxm];

	public void solve(InputReader in, PrintWriter out) {
		int n = in.nextInt(), m = in.nextInt();
		int[] rs = new int[n];
		int[] cs = new int[m];
		int i, j, k;
		int ans = Integer.MAX_VALUE;

		init();

		for (i=0; i<n; ++i) {
			for (j=0; j<m; ++j) {
				k = inc[in.nextInt()];
				rs[i] += k;
				cs[j] += k;
			}
		}

		for (i=0; i<n; ++i)
			ans = Math.min(ans, rs[i]);
		for (i=0; i<m; ++i)
			ans = Math.min(ans, cs[i]);

		out.println(ans);
	}

	private void init() {
		int i, j;
		long tmp;
		int pre = 0;

		Arrays.fill(visit, true);
		visit[0] = visit[1] = false;
		for (i=2; i<maxm; ++i) {
			if (visit[i]) {
				tmp = 1L * i * i;
				if (tmp < maxm) {
					for (j=i+i; j<maxm; j+=i)
						visit[j] = false;
				}
				for (j=pre+1; j<=i; ++j)
					inc[j] = i - j;
				pre = i;
			}
		}
	}
}

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

# coding: utf-8
matrix_params = input()
params = matrix_params.split(" ")
rows = int(params[0])
cols = int(params[1])

initial_matrix = []
count_r = []
count_c = []
curr_row = []

def is_prime(n):
  if n <= 3:
    return n > 1
  if n % 2 == 0 or n % 3 == 0:
    return False
  i = 5
  while i ** 2 <= n:
    if n % i == 0 or n % (i + 2) == 0:
      return False
    i += 6
  return True

def count_to_prime(n):
  count = 0
  while not is_prime(n + count):
    count += 1
  return count

for i in range(cols):
  count_c.append(0)

for i in range(rows):
  count_r.append(0)
  raw_row = input()
  curr_row = raw_row.split(" ")
  initial_matrix.append(curr_row)

for i in range(rows):
  for j in range(cols):
    increase = count_to_prime(int(initial_matrix[i][j]))
    count_c[j] += increase
    count_r[i] += increase

def get_min(array):
  minimum = array[0]
  for i in range(1, len(array)):
    if array[i] < minimum:
      minimum = array[i]
  return minimum

min_cols = get_min(count_c)
min_rows = get_min(count_r)

print(min_cols if min_cols < min_rows else min_rows)


import java.util.*;

public class index {

    public static void main(String[] args) {

        Scanner cin = new Scanner(System.in);
        int input = cin.nextInt();

        if (input == 1 || input == 2) {
            System.out.println(-1);
            return;
        }

        for(int i = input; i>0; i--)
        System.out.print(i + " ");
    }
}

def s(a):
    k = len(a)
    for i in range(k-1):
        for j in range(i,k-1):
            if a[j] > a[j+1]:
                a[j],a[j+1] = a[j+1],a[j]
    return a
def main():
    n = int(input())
    if n <= 2:
        v = [-1]
    else:
        v = [int(i) for i in range(n,0,-1)]
    print(*v,sep = ' ')
if __name__ == '__main__':
    main()


import os
import sys
from io import BytesIO, IOBase
from collections import Counter

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

def gcd(a, b):
    if a == 0:
        return b
    return gcd(b % a, a)

mod = int(1e9) + 7

def lcm(a, b):
    return (a * b) / gcd(a, b)

def power(k, n):
    if n == 0:
        return 1
    if n % 2:
        return (power(k, n - 1) * k) % mod
    t = power(k, n // 2)
    return (t * t) % mod

def intersect(a, b):
    d2=(a[0]-b[0])**2+(a[1]-b[1])**2
    r1r22=(a[2]+b[2])**2
    dr1r22=(a[2]-b[2])**2
    # print(a, b)
    # print(dr1r22, d2, r1r22)
    return dr1r22<d2<r1r22

def lies(a, b, c):
    d2=(a[0]-b[0])**2+(a[1]-b[1])**2
    # if a[2]>b[2]:
    #     return 0
    # if a[2]>c[2]:
    #     return 1
    return (max(0,b[2]-a[2]))**2<d2<=(max(0,c[2]-a[2]))**2

def main():
    a = []
    x, y, r, R = map(int, input().split())
    a.append([x, y, r])
    a.append([x, y, R])
    x, y, r, R = map(int, input().split())
    a.append([x, y, r])
    a.append([x, y, R])

    ans=0
    for i in range(4):
        f=0
        for j in range(4):
            if i!=j and intersect(a[i], a[j]):
                f=1
        #print(i, f)
        if i<2:
            if lies(a[i], a[2], a[3]):
                f=1
        else:
            if lies(a[i], a[0], a[1]):
                f=1
        #print(i, f)
        if f==0:
            ans+=1
    print(ans)

    return

if __name__ == "__main__":
    main()


#include <bits/stdc++.h>
using namespace std;
long long fastpow(long long a, long long b,
                  long long m = (long long)(1e9 + 7)) {
  long long res = 1;
  a %= m;
  while (b > 0) {
    if (b & 1) res = (res * a) % m;
    a = (a * a) % m;
    b >>= 1;
  }
  return res;
}
int32_t main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  ;
  long long n, x;
  cin >> n;
  vector<long long> freq(n + 5);
  vector<long long> counts(n + 5);
  for (long long i = 0; i < n; i++) {
    cin >> x;
    freq[x] = i;
  }
  for (long long i = 0; i < n; i++) {
    cin >> x;
    if (freq[x] < i) {
      counts[freq[x] + n - i]++;
    } else {
      counts[freq[x] - i]++;
    }
  }
  cout << *max_element(counts.begin(), counts.end()) << endl;
  return 0;
}

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

public class a{

  public static void main(String [] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int [] a=new int[n+1];
    int [] b=new int[n];
    Arrays.fill(a,0);
    for(int i=0;i<n;i++)a[sc.nextInt()]=i;
    for(int i=0;i<n;i++)b[i]=sc.nextInt();

    Map<Integer,Integer> map=new HashMap<>();
    for(int i=0;i<n;i++){
      int e=b[i];

      int d=i;
      int u=a[e];

      int leftMove=0;
      if(d<u){
        leftMove=d+(n-(u));
      }
      else{
        leftMove=d-u;
      }

      if(map.containsKey(leftMove)){
        map.put(leftMove,map.get(leftMove)+1);
      }
      else{
        map.put(leftMove,1);
      }

    }
    int max=0;

    for(Map.Entry<Integer,Integer> entry : map.entrySet()){
      max=Math.max(entry.getValue(),max);
    }

    System.out.println(max);

  }
}