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

public class Secret {

	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 void solve(InputReader in, PrintWriter out) {
		int n = in.nextInt();
		String s = in.next(), ss;
		String ans = s;
		StringBuilder sb;
		int delta;
		int i, j, k;

		for (i=0; i<n; ++i) {
			ss = s.substring(i, n) + s.substring(0, i);
			sb = new StringBuilder();
			delta = (10 - (ss.charAt(0) - '0')) % 10;
			for (j=0; j<n; ++j) {
				k = (ss.charAt(j)-'0'+delta)%10 + '0';
				sb.append((char) k);
			}
			ss = sb.toString();
			if (ss.compareTo(ans) < 0) {
				ans = ss;
			}
		}

		out.println(ans);
	}
}

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

n = int(input())
s = input()
i = 0
min_ = int(s)
s1 = s
i = 0
while (i <= n):
    s = s[1::] + s[0]
    if (int(s[0]) != 0):
        g = (9 - int(s[0])) + 1
        s2 = ''
        for j in range(len(s)):
            h = int(s[j]) + g
            if (h >= 10):
                h = abs(10 - h)
            s2 = s2 + str(h)
        s = s2
    if (int(s) < min_):
        min_ = int(s)
        s1 = s
    i = i + 1
print(s1)


def isprime(k):
    m=0
    for j in range(2,k):
        if k%j==0:
            m=m+1
    if m==0:
        return 0
    else:
        return 1

n=int(input())
for i in range(4,n-3):
    if isprime(i)==1 and isprime(n-i)==1:
        print(i,n-i)
        exit()

#include <bits/stdc++.h>
using namespace std;
bool prost(int x) {
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) return false;
  }
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  if (prost(n - 4) == false) {
    cout << "4 " << n - 4 << endl;
  } else if (prost(n - 9) == false) {
    cout << "9 " << n - 9 << endl;
  }
  return 0;
}


class Platforms:
    @classmethod
    def read_input(cls):
        nums = list(map(int, input('').split()))
        return nums[0], nums[1], nums[2], nums[3]

    @classmethod
    def run(cls):
        n, d, m, l = cls.read_input()
        end_plat = (n - 1) * m + l
        for cur_jump in range(d, (m + 1) * d, d):
            if (cur_jump % m) > l or cur_jump > end_plat:
                print(cur_jump)
                return
        print(end_plat - (end_plat % d) + d)

if __name__ == "__main__":
    Platforms.run()

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, d, m, l, X = 0, cur = 0;
  cin >> n >> d >> m >> l;
  bool f = false;
  for (int i = 1; i <= n;) {
    cur = ((X + l) / d) * d;
    cur += d;
    while (cur > X + l && i <= n) X = (i - 1) * m, i++;
    if (cur < X) {
      f = true;
      break;
    }
  }
  if (f)
    cout << cur;
  else {
    X = (n - 1) * m;
    cur = ((X + l) / d) * d;
    cur += d;
    cout << cur;
  }
  return 0;
}


t = int(input())

for _ in range(t):
    variables = [int(_) for _ in input().split()]
    n = variables[0]
    s = variables[1]
    k = variables[2]
    closed = set([int(i) for i in input().split()])
    minimum = n
    tmp = n
    for x in range(s, 0, -1):
        if x not in closed:
            tmp = abs(s-x)
            if tmp < minimum:
                minimum = tmp
            break
    for x in range(s, n+1):
        if x not in closed:
            tmp = abs(s-x)
            if tmp < minimum:
                minimum = tmp
            break

    print(minimum)

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

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

  static class AConneRAndTheARCMarklandN {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int t = in.nextInt();
      while (t-- > 0) {
        int n = in.nextInt(), s = in.nextInt(), k = in.nextInt();
        int[] arr = new int[k];
        HashSet<Integer> memo = new HashSet<>();
        for (int i = 0; i < k; i++) {
          arr[i] = in.nextInt();
          memo.add(arr[i]);
        }
        for (int i = 0, l = 0; l < 10000; l++, i++) {
          if (!memo.contains(s - i) && s - i > 0) {
            out.println(i);
            break;
          } else if (!memo.contains(s + i) && s + i <= n) {
            out.println(i);
            break;
          }
        }
      }
    }

  }

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

    public InputReader(InputStream inputStream) {
      reader = new BufferedReader(new InputStreamReader(inputStream));
    }

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

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

  }
}


n=int(input())
l=list(map(int,input().split()))
n1,n2=0,0
for i in l:
    if i==1:
        n1+=1
    else:
        n2+=1

r=[]
if n1==0 or n2==0:
    r=l
else:
    r.append(2)
    r.append(1)
    n1-=1
    n2-=1
    while n2!=0:
        r.append(2)
        n2-=1
    while n1!=0:
        r.append(1)
        n1-=1

for i in range(n):
    print(r[i],end=" ")
print()

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int a[n];
  int cnt1 = 0, cnt2 = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 1)
      cnt1++;
    else
      cnt2++;
  }
  if (cnt2 >= 1) {
    cnt2--;
    cout << 2 << " ";
  }
  if (cnt1 >= 1) {
    cnt1--;
    cout << 1 << " ";
  }
  long long sum = 0;
  for (int i = 0; i < cnt2; i++) {
    cout << 2 << " ";
  }
  for (int i = 0; i < cnt1; i++) {
    cout << 1 << " ";
  }
}


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

public class Code
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner s = new Scanner(System.in);
		int n= s.nextInt();
		int[][] a = new int[2*n+1][2];
	    for(int i=0;i<2*n;i++){
	        int temp = s.nextInt();
	        if(a[temp][0]==0)
	        a[temp][0]=i+1;
	        else
	        a[temp][1]=i+1;
	    }
	    long ans=0;
	    int tempposs=1;
	    int tempposd=1;
	    for(int j=1;j<=n;j++){
	        int temp1=Math.max(a[j][0]-tempposs,tempposs-a[j][0]);
	        int temp2=Math.max(a[j][1]-tempposs,tempposs-a[j][1]);
	        int temp3=Math.max(a[j][0]-tempposd,tempposd-a[j][0]);
	        int temp4=Math.max(a[j][1]-tempposd,tempposd-a[j][1]);
	        if(temp1+temp4<=temp2+temp3){
	            tempposs=a[j][0];
	            tempposd=a[j][1];
	            ans=ans+temp1+temp4;
	        }
	        else{
	            tempposs=a[j][1];
	            tempposd=a[j][0];
	            ans=ans+temp2+temp3;
	        }
	    }
	    System.out.println(ans);
	}
}

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> v(n * 2 + 1), kal1((n * 2)), kal2(n * 2 + 1);
  for (long long i = 1; i <= n * 2; i++) {
    cin >> v[i];
    if (kal1[v[i]] == 0) {
      kal1[v[i]] = i;
    } else {
      kal2[v[i]] = i;
    }
  }
  long long x = 1, needx = 1, y = 1, needy = 1, s = 0;
  while (needx != n + 1) {
    s += abs(kal1[needx] - x);
    x = kal1[needx];
    needx++;
  }
  while (needy != n + 1) {
    s += abs(kal2[needy] - y);
    y = kal2[needy];
    needy++;
  }
  cout << s;
}


import java.io.*;
import java.util.*;
public class div531B
{
	BufferedReader in;
	PrintWriter ob;
	StringTokenizer st;

	public static void main(String[] args) throws IOException {
		new div531B().run();
	}
	void run() throws IOException {
		in=new BufferedReader(new InputStreamReader(System.in));
		ob=new PrintWriter(System.out);
		solve();
		ob.flush();
	}
	void solve() throws IOException {
		int n = ni();
		int k = ni();
		int a[] = new int[n+1];
		int cnt[] = new int[5002];
		int max = 0;
		for(int i=1 ; i<=n ; i++) {
			a[i] = ni();
			++cnt[a[i]];
			max = Math.max( max , cnt[a[i]] );
		}
		if( max > k )
			ob.println("NO");
		else {
			boolean good = true;
			int color = 1;
			int res[] = new int[n+1];
			Arrays.fill( res , -1 );
			for(int i=1 ; i<=n ; i++) {
				if( res[i] == -1 ) {
					for(int j=1 ; j<=n ; j++) {
						if( res[j] == -1 && a[j] == a[i] )
							{
								res[j] = color++;
								if( color == k+1 ) {
									color = 1;
									good = true;
								}
							}
					}
				}
			}
			if( good ){
				ob.println("YES");
				for(int i=1; i<=n ; i++)
				ob.print(res[i]+" ");
			} else {
				ob.println("NO");
			}

		}
	}
	String ns() throws IOException {
		return nextToken();
	}
	long nl() throws IOException {
		return Long.parseLong(nextToken());
	}
	int ni() throws IOException {
		return Integer.parseInt(nextToken());
	}
	double nd() throws IOException {
		return Double.parseDouble(nextToken());
	}
	String nextToken() throws IOException {
		if(st==null || !st.hasMoreTokens())
			st=new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	int[] nia(int start,int b) throws IOException {
		int a[]=new int[b];
		for(int i=start;i<b;i++)
			a[i]=ni();
		return a;
	}
	long[] nla(int start,int n) throws IOException {
		long a[]=new long[n];
		for (int i=start; i<n ;i++ ) {
			a[i]=nl();
		}
		return a;
	}
}

from collections import defaultdict
n,k=map(int,input().split())
arr=list(map(int,input().split()))
temp=[0]*5001
for i in arr:
    temp[i]+=1
if(max(temp)>k):
    print('NO')
elif(k>n):
    print('NO')
else:
    print('YES')
    d=defaultdict(list)
    c=0
    t=[0]*n
    for i in range(n):
        t[i]=arr[i]
    t.sort()
    for i in range(len(t)):
        d[t[i]].append(c+1)
        c=(c+1)%k
    p=[0]*5001
    for i in range(len(arr)):
        print(d[arr[i]][p[arr[i]]],end=' ')
        p[arr[i]]+=1


#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n, sum;
  cin >> n >> sum;
  cout << (sum + n - 1) / n;
  return 0;
}

import java.util.Scanner;
public class Terst{
	public static void main(String[ ] args){
		Scanner in = new Scanner(System.in);
		double a = in.nextInt();
		double b = in.nextInt();
		System.out.println((int)Math.ceil(b/a));
	}
}


#include <bits/stdc++.h>
using namespace std;
int N[105] = {0};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  vector<int> vec;
  cin >> n >> m;
  while (n--) {
    int le, ri;
    cin >> le >> ri;
    for (int i = le; i <= ri; i++) {
      N[i]++;
    }
  }
  for (int i = 1; i <= m; i++) {
    if (N[i] == 0) {
      vec.push_back(i);
    }
  }
  cout << vec.size() << '\n';
  for (int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
    if (i < vec.size() - 1)
      cout << " ";
    else
      cout << '\n';
  }
  return 0;
}

import java.util.Scanner;
import java.util.TreeSet;

public class ProblemA {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		TreeSet<Integer> set = new TreeSet<>();
		for(int i = 1; i <= m; i++) {
			set.add(i);
		}

		for(int i = 0; i < n; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			for(int j = l; j <= r; j++) {
				if(set.contains(j)) set.remove(j);
			}
		}

		System.out.println(set.size());
		for(int x: set) {
			System.out.print(x + " ");
		}

	}

}


import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class RaznayaCommanda {

	public static int[] getArray(int size) {
		int[] array = new int[size];
		for (int i = 0; i < size; i++) {
			array[i] = sr.nextInt();
		}
		return array;
	}

	public static int[][] getMatrix(int sizeI, int sizeJ) {
		int[][] array = new int[sizeI][sizeJ];
		for (int i = 0; i < sizeI; i++) {
			for (int j = 0; j < sizeJ; j++) {
				array[i][j] = sr.nextInt();
			}
		}
		return array;
	}

	public static boolean isSimpleNumber(int val) {
		for (int i = 2; i <= Math.sqrt(val); i++) {
			if (val % i == 0)
				return false;
		}
		return true;
	}

	public static int NOD(int a, int b) {
		while (a != 0 && b != 0) {
			if (a > b) {
				a = a % b;
			} else {
				b = b % a;
			}
		}
		return a + b;
	}

	public static int NOK(int a, int b) {
		return a * b / NOD(a, b);
	}

	public static long factorial(int i) {
		long res = 1;
		for (int j = 2; j <= i; j++) {
			res *= j;
		}
		return res;
	}

	static char letters[] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
			's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };

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

	public static void main(String[] args) {

		int guysAmount = sr.nextInt();
		int commandSize = sr.nextInt();
		HashMap<Integer, Integer> a = new HashMap<>();
		for (int i = 0; i < guysAmount; i++) {
			a.put(sr.nextInt(), i + 1);
		}
		if(a.size() >= commandSize){
			System.out.println("YES");
			int counter = 0;
			for (Map.Entry<Integer, Integer> entry : a.entrySet()) {
				System.out.print(entry.getValue() + " ");
				counter++;
				if(counter == commandSize) break;
			}
		}
		else{
			System.out.println("NO");
		}
	}
}

n, k = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for i in range(n):
  d[a[i]] = i + 1

if len(d) < k:
  print('NO')
else:
  print('YES')
  values = list(d.values())
  for i in range(k):
    print(values[i], end=' ')


//package CodeForces;

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

public class Main {

    public class Haha {
        /*                     _____                                                             ___
                /\      /\    |     | |   |    /\       /\      /\       /\      /\       /\    |   \     محمد أبوحسن*
               /  \    /  \   |     | |___|   /__\     /  \    /  \     /  \    /  \     /__\   |    \
              /    \  /    \  |     | |   |  /    \   /    \  /    \   /    \  /    \   /    \  |    /
             /      \/      \ |_____| |   | /      \ /      \/      \ /      \/      \ /      \ |___/
         */
    }

    public static class MyScanner {

        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

    public static class MyPair {

        int x;
        int y;

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

    public static int Fibonacci(int n) {
        int[] a = new int[n + 1];
        a[0] = 0;
        a[1] = 1;
        for (int i = 2; i < a.length; i++) {
            a[i] = a[i - 1] + a[i - 2];
        }
        return a[n];
    }

    public static boolean isprime(int n) {
        for (int i = 2; i * i <= n; i++) {
            if (n % i == 0) {
                return true;
            }
        }
        return false;
    }

    public static int[] addarr(int[] a, int n) {
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        return a;
    }

    public static int fact(int n){
        int fact = 1;
        for(int i = 1; i <= n; i++)
            fact *= i;
        return fact;
    }

    public static long sumDigit(long n){
        int a = 0;
        while(n != 0){
            a += n%10;
            n /= 10;
        }
        return a;
    }

    public static MyScanner sc = new MyScanner();
    public static int MOD = 1000000007;
    // __builtin_popcountll(n) <-- c++ // binary count(1) ex. 8 --> 0100 --> 1
    HashSet<Integer> set = new HashSet<>();
    HashMap<Integer, Integer> map = new HashMap<>();
    Random r = new Random();
    ArrayList<Integer> l = new ArrayList<>();

    public static void main(String[] args) {
        int k = sc.nextInt();
        if(k > 36){
            System.out.println(-1);
            return;
        }
        for (int i = 0; i < k/2; i++)
            System.out.print(8);
        if(k%2 != 0)
            System.out.println(4);
    }
}

#include <bits/stdc++.h>
using namespace std;
int a[] = {1, 4, 8}, k;
int main() {
  cin >> k;
  if (k > 36)
    cout << -1 << endl;
  else if (k % 2 == 1) {
    for (int i = 0; i < k / 2; i++) cout << a[2];
    cout << a[1];
    for (int i = k / 2 + 1; i < 18; i++) cout << a[0];
    cout << endl;
  } else {
    for (int i = 0; i < k / 2; i++) cout << a[2];
    for (int i = k / 2; i < 18; i++) cout << a[0];
    cout << endl;
  }
}


import java.util.*;
import java.io.*;
import java.io.FileWriter;
import java.math.BigInteger;
import java.math.BigDecimal;
// Solution

public class Main
{
  public static void main (String[] argv)
  {
	  new Main();
  }

  boolean test = false;
  final int[][] dirs8 = {{0,1}, {0,-1}, {-1,0}, {1,0}, {1,1},{1,-1},{-1,1},{-1,-1}};
  final int[][] dirs4 = {{0,1}, {0,-1}, {-1,0}, {1,0}};
  final int MOD = 1000000007;  //998244353;

  final int WALL = -1;
  final int EMPTY = -2;
  final int VISITED = 1;
  final int FULL = 2;

  final int START = 1;
  final int END = 0;

  long[] fac;
  long[] ifac;
  long[] rfac;

  int[] mobius;
  int[] sieve;
  int[][] factors;

  //long[] fac = new long[100];
  //long[] ifac = new long[100001];
  public Main()  {
	FastReader in = new FastReader(new BufferedReader(new InputStreamReader(System.in)));

    //FastReader in = new FastReader(new BufferedReader(new FileReader("Main.in")));

    //int nt = in.nextInt();
    int nt = 1;
    StringBuilder sb = new StringBuilder();

    //fac[0] = 1;
    //ifac[0] = 1;
    //for (int i = 1; i <= 20; i++) {
      //  fac[i] = fac[i-1] * i % MOD;
      //  ifac[i] = ifac[i-1] * inv(i) % MOD;
    //}
    long[][] C = new long[19][11];

    // Caculate value of Binomial Coefficient
    // in bottom up manner
    for (int i = 0; i <= 18; i++)
    {
        for (int j = 0; j <= min(i, 10); j++)
        {
            // Base Cases
            if (j == 0 || j == i)
                C[i][j] = 1;

            // Calculate value using previously
            // stored values
            else
                C[i][j] = C[i - 1][j - 1] +
                          C[i - 1][j];
        }
    }

    //long[] invs = new long[101];
    //for (int i = 1; i <= 100; i++) invs[i] = inv(i);
    BigInteger ans = new BigInteger("0");

    for (int it = 0; it < nt; it++)
    {
       long n = in.nextLong();
       long k = in.nextLong();
       long x = n / (2 * (k+1));
       long y = k * x;
       long z = n - x - y;

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

    }

    System.out.println(sb);
  }

  private void add(Map<Integer, Integer> map, int key)
  {
      if (map.containsKey(key)) map.put(key, map.get(key) + 1);
      else map.put(key, 1);
  }

  private long[][] matIdentity(int n)
  {
      long[][] a = new long[n][n];
      for (int i = 0; i < n; i++)
          a[i][i] = 1;
      return a;
  }
  private long[][] matPow(long[][] mat0, long p)
  {
      int n = mat0.length;
      long[][] ans = matIdentity(n);
      long[][] mat = matCopy(mat0);
      while (p > 0)
      {
          if (p % 2 == 1){
              ans = matMul(ans, mat);
          }

          p /= 2;
          mat = matMul(mat, mat);
      }
      return ans;
  }

  private long[][] matCopy(long[][] a)
  {
      int n = a.length;
      long[][] b = new long[n][n];
      for (int i = 0; i < n; i++)
          for (int j = 0; j < n; j++)
              b[i][j] = a[i][j];
      return b;
  }
  private long[][] matMul(long[][] a, long[][] b)
  {
      int n = a.length;

      long[][] c = new long[n][n];
      for (int i = 0; i < n; i++)
      {
          for (int j = 0; j < n; j++)
          {
              for (int k = 0; k < n; k++)
                  c[i][j] = (c[i][j] + a[i][k] * b[k][j]) % MOD;
          }
      }

      return c;
  }

  private long[] matMul(long[][] a, long[] b)
  {
      int n = a.length;

      long[] c = new long[n];
      for (int i = 0; i < n; i++)
      {
          for (int j = 0; j < n; j++)
              c[i] = (c[i] + a[i][j] * b[j]) % MOD;
      }

      return c;
  }

  class Mark implements Comparable<Mark> {
      int type, h;
      long x;
      public Mark(int h, long x, int type)
      {
         this.h = h;
         this.x = x;
         this.type = type;
      }

      @Override
      public int compareTo(Mark o)
      {
          if (this.x == o.x) return type - o.type; // let end comes before start
          return Long.compare(x, o.x);
      }
  }

  private boolean coLinear(int[] p, int[] q, int[] r)
  {
      return 1L * (p[1] - r[1]) * (q[0] - r[0]) == 1L * (q[1] - r[1]) * (p[0] - r[0]);
  }

  private void fill(char[] a, int lo, int c, char letter)
  {
      //System.out.println("fill " + lo + " " + c + " " + letter);
      for (int i = lo; i < lo + c; i++) a[i] = letter;
  }

  private int cntBitOne(String s){
      int c = 0, n = s.length();
      for (int i = 0; i < n; i++)
          if (s.charAt(i) == '1') c++;
      return c;
  }

  class DSU {
      int n;
      int[] par;
      int[] sz;
      int nGroup;

      public DSU(int n)
      {
          this.n = n;
          par = new int[n];
          sz = new int[n];
          for (int i = 0;  i < n; i++){
              par[i] = i;
              sz[i] = 1;
          }
          nGroup = n;
      }

      private boolean add(int p, int q) {
          int rp = find(p);
          int rq = find(q);
          if (rq == rp) return false;

          if (sz[rp] <= sz[rq]) {
              sz[rq] += sz[rp];
              par[rp] = rq;
          }else {
              sz[rp] += sz[rq];
              par[rq] = rp;
          }
          nGroup--;
          return true;
      }

      private int find(int p)
      {
          int r = p;
          while (par[r] != r) r = par[r];

          while (r != p) {
              int t = par[p];
              par[p] = r;
              p = t;
          }
          return r;
      }

  }

  // μ(n) = 1 if n is a square-free positive integer with an even number of prime factors. e.g.  6, 15
  // μ(n) = −1 if n is a square-free positive integer with an odd number of prime factors. e.g.  2, 3, 5, 2*3*5
  // μ(n) = 0 if n has a squared prime factor. e.g : 2*2,  3*3*5
  private void build_mobius_function(int n)
  {
      mobius = new int[n+1];
      sieve = new int[n+1];
      factors = new int[n+1][];
      //for (int i = 1; i <= n; i++)factors[i] = new ArrayList<>();
      for (int i = 2; i <= n; i++)
        sieve[i] = i;
      for (int i = 2; i <= n; i++)
      {
        if (sieve[i] == i){
            mobius[i] = -1;
            for (long j = 1L * i * i; j <= n; j += i)
                sieve[(int)j] = i;
        }
      }

      for (int i = 6; i <= n; i++)
      {
          if (sieve[i] != i) {
              int pre = i / sieve[i];
              if (pre % sieve[i] != 0)
                  mobius[i] = -mobius[pre];
          }
      }
      int[] sz = new int[n+1];
      long tot = 0;
      for (int i = 2; i <= n; i++)
      {
          if (mobius[i] != 0)
          {
              for (int j = i * 2; j <= n; j += i) {
                  sz[j]++;
                  tot++;
              }
          }
      }
      for (int i = 2; i <= n; i++) {
          factors[i] = new int[sz[i]];
          sz[i] = 0;
      }

      for (int i = 2; i <= n; i++)
      {
          if (mobius[i] != 0)
          {
              for (int j = i * 2; j <= n; j += i) {
                  factors[j][sz[j]++] = i;
                  //factors[j].add(i);
              }
          }
      }
      //System.out.println("tot  =  "  + tot);
  }

  private int[] build_z_function(String s)
  {
      int n = s.length();
      int[] zfun = new int[n];

      int l = -1, r = -1;
      for (int i = 1; i < n; i++)
      {
         // Set the start value
         if (i <= r)
            zfun[i] = Math.min(zfun[i-l], r - i + 1);

         while (i + zfun[i] < n && s.charAt(i + zfun[i]) == s.charAt(zfun[i]))
             zfun[i]++;

         if (i + zfun[i] - 1> r){
             l = i;
             r = i + zfun[i] - 1;
         }
      }

      if (test)
      {
          System.out.println("Z-function of " + s);
          for (int i = 0; i < n; i++) System.out.print(zfun[i] + " ");
          System.out.println();
      }
      return zfun;
  }

  class BIT {
      int[] bit;
      int n;

      public BIT(int n){
          this.n = n;
          bit = new int[n+1];
      }

      private int query(int p)
      {
          int sum = 0;
          for (; p > 0; p -= (p & (-p)))
             sum += bit[p];

          return sum;
      }

      private void add(int p, int val)
      {
         //System.out.println("add to BIT " + p);
         for (; p <= n; p += (p & (-p)))
            bit[p] += val;
      }

  }

  private List<Integer> getMinFactor(int sum)
  {
      List<Integer>  factors = new ArrayList<>();

               for (int sz = 2; sz <= sum / sz; sz++){
                   if (sum % sz == 0) {
                       factors.add(sz);
                       factors.add(sum / sz);
                   }
               }
               if (factors.size() == 0)
                   factors.add(sum);

      return factors;
  }

  /* Tree class */
  class Tree {
      int V = 0;
      int root = 0;
      List<Integer>[] nbs;
      int[][] timeRange;
      int[] subTreeSize;
      int t;
      boolean dump = false;

      public Tree(int V, int root)
      {
          if (dump)
              System.out.println("build tree with size = " + V + ", root = " + root);

          this.V = V;
          this.root = root;
          nbs = new List[V];
          subTreeSize = new int[V];
          for (int i = 0; i < V; i++)
              nbs[i] = new ArrayList<>();

      }

      public void doneInput()
      {
          dfsEuler();
      }

      public void addEdge(int p, int q)
      {
          nbs[p].add(q);
          nbs[q].add(p);
      }

      private void dfsEuler()
      {
          timeRange = new int[V][2];
          t = 1;
          dfs(root);
      }

      private void dfs(int node)
      {
          if (dump)
              System.out.println("dfs on node " + node + ", at time " + t);
          timeRange[node][0] = t;

          for (int next : nbs[node]) {
              if (timeRange[next][0] == 0)
              {
                  ++t;
                  dfs(next);
              }
          }
          timeRange[node][1] = t;
          subTreeSize[node] = t - timeRange[node][0] + 1;
      }

      public List<Integer> getNeighbors(int p) {
          return nbs[p];
      }

      public int[] getSubTreeSize(){
          return subTreeSize;
      }

      public int[][] getTimeRange()
      {
          if (dump){
              for (int i = 0; i < V; i++){
                  System.out.println(i + ": " + timeRange[i][0] + " - " + timeRange[i][1]);
              }
          }
          return timeRange;
      }

  }

  /* segment tree */
  class SegTree {
      int[] a;
      int[] tree;
      int[] treeMin;
      int[] treeMax;
      int[] lazy;
      int n;
      boolean dump = false;

      public SegTree(int n)
      {
          if (dump)
              System.out.println("create segTree with size " + n);
          this.n = n;
          treeMin = new int[n*4];
          treeMax = new int[n*4];
          lazy = new int[n*4];
      }

      public SegTree(int n, int[] a) {
          this(n);
          this.a = a;
          buildTree(1, 0, n-1);
      }

      private void buildTree(int node, int lo, int hi)
      {
          if (lo == hi) {
              tree[node] = lo;
              return;
          }

          int m = (lo + hi) / 2;
          buildTree(node * 2, lo, m);
          buildTree(node * 2 + 1, m + 1, hi);
          pushUp(node, lo, hi);
      }

      private void pushUp(int node, int lo, int hi)
      {
          if (lo >= hi) return;

          // note that, if we need to call pushUp on a node, then lazy[node] must be zero.

          //the true value is the value + lazy
          treeMin[node] = Math.min(treeMin[node * 2] + lazy[node * 2], treeMin[node * 2 + 1] + lazy[node * 2 + 1]);
          treeMax[node] = Math.max(treeMax[node * 2] + lazy[node * 2], treeMax[node * 2 + 1] + lazy[node * 2 + 1]);
          // add combine fcn
      }

      private void pushDown(int node, int lo, int hi)
      {
          if (lazy[node] == 0) return;

          int lz = lazy[node];
          lazy[node] = 0;

          treeMin[node] += lz;
          treeMax[node] += lz;

          if (lo == hi) return;

          int mid = (lo + hi) / 2;
          lazy[node * 2] += lz;
          lazy[node * 2 + 1] += lz;
      }

      public int rangeQueryMax(int fr, int to)
      {
          return rangeQueryMax(1, 0, n-1, fr, to);
      }

      public int rangeQueryMax(int node, int lo, int hi, int fr, int to)
      {
          if (lo == fr && hi == to)
              return treeMax[node] + lazy[node];

          int mid = (lo + hi) / 2;
          pushDown(node, lo, hi);

          if (to <= mid) {
              return rangeQueryMax(node * 2, lo, mid, fr, to);
          }else if (fr > mid)
              return rangeQueryMax(node * 2 + 1, mid + 1, hi, fr, to);
          else {
              return Math.max(rangeQueryMax(node * 2, lo, mid, fr, mid),
                              rangeQueryMax(node * 2 + 1, mid + 1, hi, mid + 1, to));
          }
      }

      public int rangeQueryMin(int fr, int to)
      {
          return rangeQueryMin(1, 0, n-1, fr, to);
      }

      public int rangeQueryMin(int node, int lo, int hi, int fr, int to)
      {
          if (lo == fr && hi == to)
              return treeMin[node] + lazy[node];

          int mid = (lo + hi) / 2;
          pushDown(node, lo, hi);

          if (to <= mid) {
              return rangeQueryMin(node * 2, lo, mid, fr, to);
          }else if (fr > mid)
              return rangeQueryMin(node * 2 + 1, mid + 1, hi, fr, to);
          else {
              return Math.min(rangeQueryMin(node * 2, lo, mid, fr, mid),
                              rangeQueryMin(node * 2 + 1, mid + 1, hi, mid + 1, to));
          }
      }

       public void rangeUpdate(int fr, int to, int delta){
           rangeUpdate(1, 0, n-1, fr, to, delta);
       }

      public void rangeUpdate(int node, int lo, int hi, int fr, int to, int delta){
          pushDown(node, lo, hi);
          if (fr == lo && to == hi)
          {
              lazy[node] = delta;
              return;
          }

          int m = (lo + hi) / 2;
          if (to <= m)
              rangeUpdate(node * 2, lo, m, fr, to, delta);
          else if (fr > m)
              rangeUpdate(node * 2 + 1, m + 1, hi, fr, to, delta);
          else  {
              rangeUpdate(node *  2, lo, m, fr, m, delta);
              rangeUpdate(node * 2 + 1, m + 1, hi, m + 1, to, delta);
          }

          // re-set the in-variant
          pushUp(node, lo, hi);
      }

      public int query(int node, int lo, int hi, int fr, int to)
      {
          if (fr == lo && to == hi)
              return tree[node];

          int m = (lo + hi) / 2;
          if (to <= m)
              return  query(node * 2, lo, m, fr, to);
          else if (fr > m)
              return query(node * 2 + 1, m + 1, hi, fr, to);

          int lid = query(node * 2, lo, m, fr, m);
          int rid = query(node * 2 + 1, m + 1, hi, m + 1, to);
          return a[lid] >= a[rid] ? lid : rid;
      }

  }

  private long inv(long v)
  {
      return pow(v, MOD-2);
  }

  private long pow(long v, long p)
  {
      long ans = 1;
      while (p > 0)
      {
          if (p % 2 == 1)
              ans = ans * v % MOD;
          v = v * v % MOD;
          p = p / 2;
      }
      return ans;
  }

  private double dist(double x, double y, double xx, double yy)
  {
      return Math.sqrt((xx - x) * (xx - x) + (yy - y) * (yy - y));
  }

  private int mod_add(int a, int b) {
      int v = a + b;
      if (v >= MOD) v -= MOD;
      return v;
  }

  private long overlap(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
      if (x1 > x3) return overlap(x3, y3, x4, y4, x1, y1, x2, y2);

      if (x3 > x2 || y4 < y1 || y3 > y2) return 0L;

      //(x3, ?, x2, ?)
      int yL = Math.max(y1, y3);
      int yH = Math.min(y2, y4);
      int xH = Math.min(x2, x4);

      return f(x3, yL, xH, yH);
  }
  //return #black cells in rectangle
  private long f(int x1, int y1, int x2, int y2) {
      long dx = 1L + x2 - x1;
      long dy = 1L + y2 - y1;
      if (dx % 2 == 0 || dy % 2 == 0 || (x1 + y1) % 2 == 0)
          return 1L * dx * dy / 2;
      return 1L * dx * dy / 2 + 1;
  }

  private int distM(int x, int y, int xx, int yy) {
      return abs(x - xx) + abs(y - yy);
  }

  private boolean less(int x, int y, int xx, int yy) {
      return x < xx || y > yy;
  }

  private int mul(int x, int y) {
      return (int)(1L * x * y % MOD);
  }

  private int nBit1(int v) {
      int v0 = v;
      int c = 0;
      while (v != 0) {
          ++c;
          v = v & (v - 1);
      }
      return c;
  }

  private long abs(long v) {
      return v > 0 ? v : -v;
  }

  private int abs(int v) {
      return v > 0 ? v : -v;
  }

  private int common(int v) {
      int c = 0;
      while (v != 1) {
          v = (v >>> 1);
          ++c;
      }

      return c;
  }

  private void reverse(char[] a, int i, int j) {
      while (i < j) {
          swap(a, i++, j--);
      }
  }

  private void swap(char[] a, int i, int j) {
      char t = a[i];
      a[i] = a[j];
      a[j] = t;
  }

  private int gcd(int x, int y) {
      if (y == 0) return x;
      return gcd(y, x % y);
  }
  private long gcd(long x, long y) {
      if (y == 0) return x;
      return gcd(y, x % y);
  }
  private int max(int a, int b) {
      return a >  b ? a : b;
  }

  private long max(long a, long b) {
      return a >  b ? a : b;
  }

  private int min(int a, int b) {
      return a >  b ? b : a;
  }

  private long min(long a, long b) {
      return a >  b ? b : a;
  }

  static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(BufferedReader in)
        {
            br = in;
        }

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, a;
  cin >> n >> k;
  a = (n / 2) / (k + 1);
  cout << a << " " << a * k << " " << n - (k + 1) * a;
}


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

public class SRM68_1 {
    public static void main(String[] args) throws NumberFormatException,
            IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        //String []s = in.readLine().split(" ");
        int n = Integer.parseInt(in.readLine());
        String max = "";
        int m = -1000000000;
        for (int i = 0; i < n; i++) {
            String []s = in.readLine().split(" ");
            int curr = Integer.parseInt(s[1])*100 - Integer.parseInt(s[2])*50 + Integer.parseInt(s[3])
             + Integer.parseInt(s[4])+ Integer.parseInt(s[5])+Integer.parseInt(s[6])+Integer.parseInt(s[7]);
            if(curr>m){
                m = curr;
                max = s[0];
            }
        }
        System.out.println(max);
    }
}

arr = []
for _ in range(0,int(input())):
  arr.append(list(input().split()))

ans = []
for i in range(0,len(arr)):
  sum  = int(arr[i][1])*100 - int(arr[i][2])*50
  for j in range(3,8):
    sum += int(arr[i][j])
  ans.append(sum)

a = max(ans)
for i in range(0,len(ans)):
  if ans[i] == a:
    print(arr[i][0])
    break


#include <bits/stdc++.h>
using namespace std;
const int MXN = 1e6 + 30;
const int MAXN = 1e3 + 2;
const long long INF = 1e9 + 7;
const long long BINF = 1e15;
const int MOD = 1e9 + 7;
const long double EPS = 1e-15;
long long n, m;
long long a[MXN];
long long used[MXN];
multiset<long long> st;
multiset<long long>::iterator it;
long long cnt, ans;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    if (i != m && a[i] == 0) a[i] = 1000000;
  }
  if (a[m] != 0) {
    a[m] = 0, ans++;
  }
  for (int i = 1; i <= n; i++) {
    used[a[i]]++;
    st.insert(a[i]);
  }
  long long o = 0;
  while (cnt < n) {
    if (!used[o]) {
      used[o]++, cnt++, ans++;
      it = st.end(), it--;
      used[*it]--;
      st.erase(it);
    } else {
      cnt += used[o];
    }
    o++;
  }
  cout << ans;
  return 0;
}

n,s = map(int,input().split())
A = list(map(int,input().split()))
if A[s-1] != 0:
    per = 1
    A[s-1] = 0
else:
    per = 0
A.sort()
maxs = max(A)
ans = [0] * (maxs + 1)
answer = maxs + 1
o = -1
for j in range(n):
    if A[j] == 0:
        o += 1

    if ans[A[j]] == 0:
        ans[A[j]] = 1
        answer -= 1
an = per + max(o, answer)

for j in range(n-2,-1,-1):

    for t in range(A[j+1]-1, A[j] -1,-1):
        if ans[t] == 0:
            answer -= 1

    an = min(an, per + max(answer,o+n - j - 1))
print(an)


#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
int table[5007][5007], n, m, k;
bool frq[5007][2];
struct q {
  int t, x, c;
} mem[N], a;
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < k; i++) scanf("%d%d%d", &mem[i].t, &mem[i].x, &mem[i].c);
  for (int i = k - 1; i >= 0; i--) {
    a = mem[i];
    if (a.t == 1) {
      if (frq[a.x][0]) continue;
      frq[a.x][0] = 1;
      for (int j = 1; j <= m; j++) {
        if (!table[a.x][j]) table[a.x][j] = a.c;
      }
    } else {
      if (frq[a.x][1]) continue;
      frq[a.x][1] = 1;
      for (int j = 1; j <= n; j++) {
        if (!table[j][a.x]) table[j][a.x] = a.c;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) printf("%d ", table[i][j]);
    puts("");
  }
  return 0;
}

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

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter printWriter = new PrintWriter(System.out);
        Solve TaskSolve = new Solve();
        TaskSolve.main(bufferedReader, printWriter);
        bufferedReader.close();
        printWriter.close();
    }

	static class Solve {

        public void main(BufferedReader bufferedReader, PrintWriter printWriter) throws IOException {

            StringTokenizer stringTokenizer = new StringTokenizer(bufferedReader.readLine());

            int n = Integer.parseInt(stringTokenizer.nextToken());
            int m = Integer.parseInt(stringTokenizer.nextToken());
            int k = Integer.parseInt(stringTokenizer.nextToken());

            int table[][] = new int[n][m];
            int query[][] = new int[k][3];

            for(int i = 0; i < k; i++) {
                stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                query[i][0] = Integer.parseInt(stringTokenizer.nextToken());
                query[i][1] = Integer.parseInt(stringTokenizer.nextToken()) - 1;
                query[i][2] = Integer.parseInt(stringTokenizer.nextToken());
            }

            int string[] = new int[n];
            int column[] = new int[m];

            for(int i = k - 1; i >= 0; i--) {
                if(query[i][0] == 1) {
                    if (string[query[i][1]] == 0) {
                        string[query[i][1]] = 1;
                        for(int j = 0; j < m; j++) {
                            if(table[query[i][1]][j] == 0) {
                                table[query[i][1]][j] = query[i][2];
                            }
                        }
                    }
                }
                else {
                    if (column[query[i][1]] == 0) {
                        column[query[i][1]] = 1;
                        for(int j = 0; j < n; j++) {
                            if(table[j][query[i][1]] == 0) {
                                table[j][query[i][1]] = query[i][2];
                            }
                        }
                    }
                }
            }

            for(int i = 0; i < n; i++) {
                for(int j = 0; j < m; j++) {
                    if(j > 0) {
                        printWriter.print(" ");
                    }
                    printWriter.print(table[i][j]);
                }
                printWriter.print("\n");
            }

            bufferedReader.close();
            printWriter.close();
        }
    }
}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = sc.nextIntArray(n);
		int[]seq = new int[n];
		for(int i=0; i<n/2; i++)
		{
			seq[i]=(i)%(n/2)+1;
			seq[n-1-i]=seq[i];
		}
		if(n%2==1)seq[n/2] = n/2+1;
		int [] fre = new int[(int)1e5];
		int tot = 0;
		for(int i=0;i<n; i++){
			int dif = arr[i]-seq[i];
			if(dif<0)tot++;
			else
				fre[dif]++;
		}
		int max =0;
		for(int i=0; i<fre.length; i++){
			if(fre[i]>max){
				tot +=max;
				max = fre[i];
			}
			else
				tot+=fre[i];
		}
		System.out.println(tot);

	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> save(1e5 + 1);
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    int x = a - min(i, n - 1 - i);
    assert(x < (int)save.size());
    if (x > 0) ++save[x];
  }
  int ans = 1e9;
  for (int i = 1; i < save.size(); ++i) {
    ans = min(ans, n - save[i]);
  }
  cout << ans << '\n';
  return 0;
}


//package codeforce.a20j.under1300;

import java.util.Scanner;

/**
 * @author pribic (Priyank Doshi)
 * @since 20/02/21
 */
public class practiceunder1300 {

  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      int T = 1;
      //sc.nextInt();
      int ans = 0;
      for (int tt = 1; tt <= T; tt++) {
        String borze = sc.next();
        StringBuilder num = new StringBuilder();
        for (int i = 0; i < borze.length(); i++) {
          switch (borze.charAt(i)) {
            case '.':
              num.append('0');
              break;
            case '-':
              num.append(borze.charAt(i + 1) == '-' ? '2' : '1');
              i++;
              break;

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

// 0, 0 , new origin -5,3 -> 5+5, 3-3 means i have to do +5, -3 from each cordinate


n = int(input())
if n % 2 == 0:
  print(-1)
else:
  print(*range(n))
  print(*range(n))
  print(*map(lambda x: x * 2 % n, range(n)))

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


#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 9;
int a[MAX], n, ans;
vector<int> l;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    while (l.size() && a[i] >= l.back()) l.pop_back();
    if (l.size()) ans = max(ans, l.back() ^ a[i]);
    l.push_back(a[i]);
  }
  for (int i = n - 1; i >= 0; i--) {
    while (l.size() && a[i] >= l.back()) l.pop_back();
    if (l.size()) ans = max(ans, l.back() ^ a[i]);
    l.push_back(a[i]);
  }
  cout << ans;
}

#http://codeforces.com/problemset/problem/281/D

#SC = TC = o(n)

n = int(input())
a = list(map(int, input().strip().split()))

stack = []	#decreasing stack

max_xor = 0

for k in range(n):
	#if stack empty
	if not stack:
		stack.append(a[k])
	#if less than top of stack
	elif a[k]<stack[-1]:
		max_xor = max(max_xor, a[k]^stack[-1])
		stack.append(a[k])
	#input will be distinct so no equal condition
	#if greater than top of stack
	elif a[k]>stack[-1]:
		#pop and xor
		while stack and a[k]>stack[-1]:
			popped = stack.pop()
			max_xor = max(max_xor, a[k]^popped)
		#now if stack is not empty means below element is greater
		#so xor will it and push	#case 9 8 3 5 7
		if stack:
			max_xor = max(max_xor, a[k]^stack[-1])
		stack.append(a[k])

print(max_xor)


import java.util.*;

public class Main {

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

		System.out.println(Math.max(n, m)-1 + " " + Math.min(n, m));
		sc.close();
	}

}

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  while (cin >> n >> m) {
    if (n < m) swap(n, m);
    int a = m - 1, b = m;
    if (m & 1) {
      int x = (n - m > 0) ? (n - m) : 0;
      a += x;
    } else {
      int x = (n - m > 0) ? (n - m) : 0;
      a += x;
    }
    cout << a << " " << b << endl;
  }
  return 0;
}


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

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

class TaskC {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        int count = in.readInt();
        int k = in.readInt();
        int[] A = new int[count];
        for (int i = 0; i < count; i++)
            A[i] = in.readInt() + 1000000000;

        A = radixSort(A);

        long[] sum = new long[count + 1];
        for (int i = 1; i <= count; i++)
            sum[i] = sum[i - 1] + A[i - 1];

        int p = 0;
        long maxIndex = 0;
        long maxValue = 0;

        for (int i = 0; i < count; i++) {
            while (p <= i) {
                long v = (long)A[i] * (i - p + 1) - (sum[i + 1] - sum[p]);
                if (v <= k)
                    break;
                p++;
            }

            if (i - p + 1 > maxValue) {
                maxValue = i - p + 1;
                maxIndex = A[i];
            }
        }

        out.printLine(maxValue + " " + (maxIndex - 1000000000));
    }

    private int[] radixSort(int[] f) {
        int[] to = new int[f.length];
        {
            int[] b = new int[65537];
            for(int i = 0;i < f.length;i++)b[1+(f[i]&0xffff)]++;
            for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
            for(int i = 0;i < f.length;i++)to[b[f[i]&0xffff]++] = f[i];
            int[] d = f; f = to;to = d;
        }
        {
            int[] b = new int[65537];
            for(int i = 0;i < f.length;i++)b[1+(f[i]>>>16)]++;
            for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
            for(int i = 0;i < f.length;i++)to[b[f[i]>>>16]++] = f[i];
            int[] d = f; f = to;to = d;
        }
        return f;
    }
}

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

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

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

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

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

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

    }

class OutputWriter {
    private final PrintWriter writer;

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

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

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

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

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

}

import sys
import math as mt
input=sys.stdin.buffer.readline
#t=int(input())
t=1
for __ in range(t):
    #n=int(input())
    n,k=map(int,input().split())

    l=list(map(int,input().split()))
    l.sort()
    maxn,maxl=l[0],1
    suma=[0]*(n+2)
    suma[0]=0
    for i in range(n):
        suma[i+1]=suma[i]+l[i]
    to=0
    for i in range(1,n):
        while((i-to)*l[i]-(suma[i]-suma[to]))>k:
            to+=1
        if maxl<i-to+1:
            maxl=i-to+1
            maxn=l[i]

    print(maxl,maxn)


#include <bits/stdc++.h>
using namespace std;
int main() {
  long double s;
  cin >> s;
  long double a, b, c;
  cin >> a >> b >> c;
  if (a == 0 && b == 0 && c == 0) {
    cout << 0 << " " << 0 << " " << 0;
    return 0;
  }
  long double n1 = s * a, n2 = s * b, n3 = s * c, d1 = a + b + c,
              d2 = a + b + c, d3 = a + b + c;
  n1 /= d1;
  n2 /= d2;
  n3 /= d3;
  cout << fixed << setprecision(20) << n1 << " " << n2 << " " << n3;
  return 0;
}

a=int(input())
b=list(map(int,input().split()))
if sum(b)==0:print(' '.join([str(a/3)]*3))
else:print(' '.join(map(str,map(lambda x:a*x/sum(b),b))))


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

import java.util.*;

public class Main {
    static int mod=1_000_000_007;
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        int n = in.nextInt();
        int m = in.nextInt();
        long right_a = 2L;
        long right_b = 0L;
        long b_a = 0L;
        long b_b = 0L;
        for (int i=1;i<n;i++) {
            b_a = right_a;
            b_b = right_b;
            right_a = (b_a + b_b)%mod;
            right_b = b_a%mod;
        }
        // out.println("right_a: " + right_a + " right_b: " + right_b);
        out.println(((right_a+right_b-2)%mod + 2*fib(m))%mod);
        // out.println(fib(n));
        out.close();
    }
    static long fib(int n) {
        long fn=0;
        long f0=0;
        long f1=1;
        for (int i=0;i<n;i++) {
            fn = (f0 + f1)%mod;
            f0 = f1;
            f1 = fn;
        }
        return fn;
    }
    static long pow(long a,int n) {
        long res=1;
        while (n>0) {
            if ((n-n/2*2)==1) {
                res=res*a%mod;
            }
            a=a*a%mod;
            n>>=1;
        }
        return res;
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

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

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

    }
}

N = int(1e5+3)
MOD = int(1e9+7)
memo = [0] * N

def dp():
    memo[0] = 2
    memo[1] = 2
    for i in range(2, N):
        memo[i] = (memo[i-1] + memo[i-2]) % MOD

n, m = map(int, input().split())
dp()
print((memo[n] + - 1 + memo[m] - 1) % MOD)


#include <bits/stdc++.h>
using namespace std;
const long long MAX = 2e5 + 9;
const long long INF = 1e12;
long long N, M, f, s, res;
signed main() {
  ios_base::sync_with_stdio(false);
  cin >> N >> M;
  for (int A = 1; A <= M; A++) {
    for (int B = 1; B <= M; B++) {
      if (((A * A) % M + (B * B) % M) % M) continue;
      if (N - A < 0 or N - B < 0) continue;
      f = (N - A) / M + 1;
      s = (N - B) / M + 1;
      res += f * s;
    }
  }
  cout << res;
  return 0;
}

n,m=map(int,input().split())
s=list()
for i in range(1,m+1):
    for j in range(1,m+1):
        if (i**2+j**2)%m==0:
            s.append([i,j])
ans=0
for k in s:
    #print(k)
    ky=(n-k[0])//(m)+1
    my=(n-k[1])//(m)+1
    ans+=ky*my
print(ans)


n, k, l = map(int, input().split())
sl = [int(i) for i in input().split()]
vx = min(sl)
vy = vx + l
fl = sorted([i for i in sl if vx <= i <= vy])
if len(fl) < n:
    print('0')
else:
    ans = 0
    i = 0
    um = n
    while um > 0:
        ans += fl[i]
        um -= 1
        i = min(i + k, len(fl) - um)
        #print(i)
    print(ans)

#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int a[maxn];
int main() {
  int n, k, l;
  scanf("%d %d %d", &n, &k, &l);
  for (int i = 1; i <= n * k; i++) scanf("%d", &a[i]);
  sort(a + 1, a + 1 + n * k);
  int idx = upper_bound(a + 1, a + 1 + n * k, a[1] + l) - a;
  int num = idx - 1;
  if (num < n) {
    puts("0");
    return 0;
  } else {
    long long ans = 0;
    int now = 1;
    for (int i = 1; i <= n; i++) {
      ans += a[now];
      now++;
      int left = num - now + 1;
      int have = 1;
      while (have < k && left > n - i) now++, left--, have++;
    }
    cout << ans << endl;
  }
}


#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
const int N = 5e3 + 10;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  map<int, int> mc;
  for (auto &x : v) {
    cin >> x;
    mc[x]++;
  }
  sort(v.begin(), v.end());
  if (v.back() - v.front() < 2) {
    cout << n << endl;
    for (auto &x : v) cout << x << ' ';
    return 0;
  }
  int a, b, c;
  a = mc[v.front()];
  c = mc[v.back()];
  b = n - a - c;
  int x = a + b / 2, z = c + b / 2, y = b % 2;
  tuple<int, int, int> ans = {INF, 0, 0};
  for (; x >= 0 && z >= 0; y += 2, x--, z--) {
    ans = min(ans, {min(x, a) + min(y, b) + min(z, c), x, y});
  }
  int res;
  tie(res, x, y) = ans;
  z = n - x - y;
  cout << res << endl;
  while (x--) cout << v.front() << ' ';
  while (y--) cout << v.front() + 1 << ' ';
  while (z--) cout << v.back() << ' ';
  return 0;
}

R = lambda : map(int, input().split())
n = int(input())
v = list(R())
mn = min(v); mx = max(v);
from collections import Counter
c = Counter(v)

if mn==mx or mn==mx-1:
    print(len(v)); print(" ".join(map(str,v))); exit();

if mn==mx-2 and len(c)==2:
    c[mn+1]=0

k = sorted(list(c.keys()))
ck0 = c[k[0]]; ck1 = c[k[1]]; ck2 = c[k[2]];
if (2*min(ck0,ck2)<=2*(ck1//2)):
    i = [i for i in range(len(v)) if v[i]==k[1]]
    for j in range(ck1//2):
        v[i[2*j]],v[i[2*j+1]] = v[i[2*j]]-1,v[i[2*j+1]]+1
    print(len(v)-2*(ck1//2))
    print(" ".join(map(str,v)))
else:
    mni = [i for i in range(len(v)) if v[i]==mn]
    mxi = [i for i in range(len(v)) if v[i]==mx]
    for i in range(min(ck0,ck2)):
        v[mni[i]],v[mxi[i]]=v[mni[i]]+1,v[mxi[i]]-1
    print(len(v)-2*(min(ck0,ck2)))
    print(" ".join(map(str,v)))


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

public class Main {
    public class Room implements Comparable<Room>{
        int lvl, num;

        Room(int a, int b){
            lvl = b;
            num = a;
        }
        @Override
        public int compareTo(Room o) {
            return Integer.compare(lvl, o.lvl);
        }
    }
    public void solve() throws IOException {
        char s[] = nextToken().toCharArray();
        int n = s.length;
        int cnt = 0, cnt1 = 0;
        char last = 0;
        for (int i = 0; i < n; i++) {
            if(s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u'){
                out.print(s[i]);
                cnt = 0;
                cnt1 = 0;
            }else if(cnt > 1){
                if(last == s[i] && cnt == cnt1){
                    cnt++;
                    cnt1++;
                    out.print(s[i]);
                }else{
                    out.print(" ");
                    out.print(s[i]);
                    last = s[i];
                    cnt = 1;
                    cnt1 = 1;
                }
            }else{
                out.print(s[i]);
                if(last == s[i]) {
                    cnt1++;
                } else{
                    cnt1 = 1;
                }
                last = s[i];
                cnt++;

            }
        }

    }

    BufferedReader br;
    StringTokenizer sc;
    PrintWriter out;

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

    void run() throws IOException {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

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

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

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

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

}

abcc xxxxxxxxxzzzzzzzzzzzz acbcccbcc acbbbcc acbcccbcc acbbccc abacaba abcccb aabbc abcbccc aabcc bbbccccc acc xxxxx abccc acbcccbccc hellno cccccccc abcbcc aaccc abccccc acbbc abcccbb aac abcccbcc abcbccc aaabbc acbccc abcccbccc acbcccbccc acbbb aabccc bbbbbbbb abcb acbbbccc aaaccc cccccc moyaoborona aacc acb acbcccb bbbcccc bbbbb acbc acbcc acbccc asdfasdf bccccc ac abccc

abc cccc
abacaba
acb
abc cc b
abc bc cc
acb ccc bc c
abc bc c
abc cc bc c
abc bc cc
acb bb ccc
bbb cccc
acb ccc bc cc
bc cccc
abc cc
xxxxx
abc cc bc cc
acb ccc bc cc
acb ccc
cccccc
xxxxxxxxx zzzzzzzzzzzz
abc cc
acb bc
hell no
aabc cc
asd fasd f
aacc
abc b
acb ccc bc c
aaaccc
bbbbbbbb
acb ccc b
ac
aabb c
abc c
acb bb cc
moyaoborona
aaccc
acb ccc
bbb ccccc
cccccccc
aabc c
aaabb c
acb bb
aac
acb cc
acb bc cc
abc cc bb
acb c
acc
bbbbb


#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int n;
  cin >> n;
  int res = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x > b && x < c) res++;
  }
  cout << res;
  return 0;
}

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

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

    static class TaskA {
        public void solve(int testNumber, MyReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int n = in.nextInt();
            int count = 0;
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
            }
            Arrays.sort(arr);
            for (int i = 0; i < n; i++) {
                if (arr[i] > b && arr[i] < c) count++;
            }
            out.println(count);
        }

    }

    static class MyReader {
        private BufferedReader buffReader;
        private StringTokenizer strTokenizer;
        private static final int SIZE = 32768;

        public MyReader(InputStream inputStream) {
            buffReader = new BufferedReader(new InputStreamReader(inputStream), SIZE);
        }

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

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

    }
}


import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class xor{
public static void main(String args[]) throws IOException{
BufferedReader lector = new BufferedReader(new InputStreamReader(System.in));
BigInteger a = new BigInteger(lector.readLine());
BigInteger b = new BigInteger(lector.readLine());
String aa = bin(a),bb=bin(b);
BigInteger x = BigInteger.ZERO,y=BigInteger.ZERO;
while(bb.length()<aa.length())bb = "0"+bb;
//if(aa.length()<bb.length()){System.out.println("-1");return;}
//System.out.println(aa+"\n"+bb);
boolean ac = false,jo = false;
for(int n = 0;n<bb.length();n++){
//System.out.println(aa.charAt(aa.length()-bb.length()+n)+"  "+bb.charAt(n)+" "+ac+" "+bin(x)+" "+bin(y));
if(bb.charAt(n)=='1'){
//if(ac){jo=true;break;}
y=y.add((BigInteger.ONE).shiftLeft(bb.length()-n-1));
if(aa.charAt(n)=='0')ac = true;
else
ac = false;
}else{
if(ac){
x=x.add((BigInteger.ONE).shiftLeft(bb.length()-n-1));
y=y.add((BigInteger.ONE).shiftLeft(bb.length()-n-1));
//if(aa.charAt(aa.length()-bb.length()+n)=='1')ac = true;
//else ac = false;
}
if(aa.charAt(n)=='1')ac = true;
else ac = false;
//if(aa.charAt(aa.length()-bb.length()+n)=='0')ac=true;
}
}
if(jo)System.out.println("-1");
int u = bb.length()-1;
//System.out.println("Parc "+x+" "+y);
//if(a-(x+y)==2 && ((x+1)^(y+1))==b){
//System.out.println(x+1+" "+(y+1));
//return;
//}
/*while(a>(x+y) && (++u)>0){
y+=(1<<u);
x+=(1<<u);
}*/
//if(a-(x+y)==2 && (x+1)^(y+1)==b)
//System.out.println(x+1+" "+y+1);
//System.out.println("Parc1 "+x+" "+y);
if(a.compareTo(x.add(y))==0)
System.out.println(x+" "+y);
else
System.out.println(-1);
}
public static String bin(BigInteger a){
String res = "";
do{
res = (a.and(BigInteger.ONE))+res;
}while((a=a.shiftRight(1)).compareTo(BigInteger.ZERO)>0);
return res;
}
}

a, b = int(input()), int(input())
x, y = (a - b) >> 1, (a - b) // 2 + b
if a < b or (a + b) & 1 or x & (a - x) != x:
    print("-1")
else: print(x, y)


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

import java.util.Scanner;

/**
 *
 * @author asus
 */
public class sizemonitor {

    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int size = in.nextInt();
        int width = Integer.MAX_VALUE;
        int height = Integer.MAX_VALUE;
        int raznica = Integer.MAX_VALUE;
        for (int i = 1; i <= size; i++) {
            if (size == i * (size / i)) {
                int temp = raznica;
                raznica = Math.min(raznica, Math.abs(i - (size / i)));
                if (temp != raznica) {
                    height = Math.min(i, (size / i));
                    width = Math.max(i, (size / i));

                }
            }
        }
        System.out.println(height + " " + width);

    }
}

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  long long n;
  cin >> n;
  long long bestA = 1, bestB = n;
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      bestA = i;
      bestB = n / i;
    }
  }
  cout << bestA << " " << bestB;
}


function main() {

    var n = Number(readline());

    var str = readline();

    var numL = 0;
    var numR = 0;

    for ( var i = 0;i < n;i++){
        if(str[i] === "<"){
            numL ++;
        }else {
            break;
        }
    }

    for (var j = n-1;j>=0;j--){
        if(str[j] === ">"){
            numR ++;
        }else {
            break;
        }
    }

    print(numL+numR);

}

main();

n=int(input())
s=input()
k=s[0]
res=i=0
while i<=n-1 and s[i]==k:
    i+=1
else:
    if k=='<':
        res+=i
k='>'
i=n-1
while i>=0 and s[i]==k:
    i-=1
else:
    res+=n-i-1
print(res)


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

public class HelloWorld
{
  public static void main(String[] args)
  {
    Scanner reader = new Scanner(System.in);
    int n = reader.nextInt();
    int cMisha,cChris;
    int cM=0;
    int cC=0;

    while(reader.hasNext()){
        cMisha = reader.nextInt();
        cChris = reader.nextInt();
        if(cMisha>cChris)
            cM++;
        else if(cChris>cMisha)
            cC++;
        else
            continue;
    }
    if(cC<cM)
        System.out.println("Mishka");
    else if(cM<cC)
        System.out.println("Chris");
    else
        System.out.println("Friendship is magic!^^");
  }

}

Mishka
Mishka
Friendship is magic!^^
Chris
Friendship is magic!^^
Chris
Mishka
Mishka

n = int(input())
k = 0
l = 0
for i in range(n):
    m,c = map(int,input().split())
    if m > c:
        k +=1
    elif c > m:
        l +=1
if k > l:
    print("Mishka")
elif l > k:
    print("Chris")
else:
    print("Friendship is magic!^^")


import java.util.Scanner;
public class ayhbl
{
	public static void main(String[] args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int a=in.nextInt();
		int[] x=new int[n];
		int i=a-2;
		int j=a,c=0;
		for(int k=0;k<n;k++)
		{
			x[k]=in.nextInt();
		}
		if(x[a-1]==1) c++;
		while(i>=0||j<n)
		{
			if (i>=0 &&j<n&&x[i]==x[j]&&x[i]==1)
			{
					c+=2;i--;j++;
			}
			else if(i>=0&&x[i]==1&&j>=n) {i--;c++;}
			else if(j<n&&x[j]==1&&i<0) {c++;j++;}
			else {i--;j++;}
		}
		System.out.print(c);
	}

}

#include <bits/stdc++.h>
using namespace std;
unsigned short max(unsigned short a, unsigned short b) { return a > b ? a : b; }
unsigned short min(unsigned short a, unsigned short b) { return a < b ? a : b; }
int main() {
  std::ios::sync_with_stdio(false);
  unsigned short n, a, nCought, crA, upsteps, lwsteps;
  short i, j;
  cin >> n;
  cin >> a;
  unsigned short t[3 * n];
  for (i = 0; i < n; ++i) t[i] = 1;
  for (i; i < 2 * n; ++i) cin >> t[i];
  for (i; i < 3 * n; ++i) t[i] = 1;
  crA = a + n - 1;
  if (t[crA] == 1)
    nCought = 1;
  else
    nCought = 0;
  upsteps = max(n - a, a - 1);
  lwsteps = min(n - a, a - 1);
  for (i = 1; (i < (upsteps + 1)) && (i < n); ++i) {
    if (t[crA - i] && t[crA + i])
      if (i > lwsteps)
        ++nCought;
      else if (i != 0)
        nCought += 2;
  }
  cout << nCought;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int kitten, F, I, T;
  string tmp;
  cin >> F >> I >> T;
  vector<vector<int> > M(F, vector<int>(I));
  for (int f = 0; f < F; ++f) {
    cin >> tmp;
    for (int i = 0; i < I; ++i) {
      M[f][i] = (tmp[i] == 'Y');
    }
  }
  int ans = 0;
  for (int i = 0; i < I; ++i) {
    int S = 0;
    for (int f = 0; f < F; ++f) {
      S += M[f][i];
    }
    if (S >= T) {
      ++ans;
    }
  }
  cout << ans;
  return 0;
}

9 8 7
NYYNNNYY
YYYNYNNN
YNYNYNNY
NYYYNNNY
NYYYYNYN
NNNNYYNN
YNYYYYYY
NNYNYNYY
NYYNNYYY

8 4 1
YYYN
NNNN
NYNY
YNNY
YNYY
YNYN
YNNY
NNYN

10 4 5
NNYN
YYNY
YYNY
NYYN
YNYY
YNYY
YYNN
YNYN
YYYY
YYNY

6 9 6
NYYNNYNYN
YNYNYNNNN
NNYNNYYYY
NNYNNNYNY
NYYYNNYNY
NNYYNNNYN

from functools import reduce
f,o,t = map(int, input().split(' '))
res = [0 for i in range(o)]
for i in range(f):
    s = input()
    for j in range(o):
        res[j]+=(s[j]=='Y')
print(reduce(lambda x,y: x+(y>=t), res,0))
#kitten


import java.util.Scanner;

public class Main{

	public static boolean isLucky(int n){
		String s=n+"";

		for(int i=0;i<s.length();i++)
			if(s.charAt(i)!='8' && s.charAt(i)!='7')
				return false;

		return true;
	}

	public static void main(String[] args){

		Scanner input=new Scanner(System.in);

		int n=input.nextInt();
		long sum=0;
		for(int i=1;i<=n;i++)
			sum+=(long)Math.pow(2, i);
		System.out.println(sum);
	}
}


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

public class Main
{
	/********************************************** a list of common variables **********************************************/
	private MyScanner scan = new MyScanner();
	private PrintWriter out = new PrintWriter(System.out);
	private final double PI = Math.acos(-1.0);
	private final int SIZEN = (int)(1e5);
	private final int MOD = (int)(1e9 + 7);

	public void foo()
	{
		int n = scan.nextInt();
		if(1 == n)
		{
			out.println("YES");
			out.println(1);
			return;
		}
		else if(4 == n)
		{
			out.println("YES");
			out.println(1);
			out.println(3);
			out.println(2);
			out.println(4);
			return;
		}
		for(int i = 2;i * i <= n;++i)
		{
			if(0 == n % i)
			{
				out.println("NO");
				return;
			}
		}
		out.println("YES");
		out.println(1);
		long[] inv = new long[n + 1];
		inv[1] = 1;
		for(int i = 2;i < n;++i)
		{
			inv[i] = inv[n % i] * (n - n / i) % n;
			out.println(inv[i - 1] * i % n);
		}
		out.println(n);
	}

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

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

	/**
	 * get greatest common divisor
	 * @param a : first number
	 * @param b : second number
	 * @return greatest common divisor
	 */
	public long gcd(long a, long b)
	{
		return 0 == b ? a : gcd(b, a % b);
	}

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

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

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

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

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

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

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

#include <bits/stdc++.h>
using namespace std;
int mod;
bool prime(int n) {
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) return 0;
  }
  return 1;
}
int fastpower(int b, int p) {
  int res = 1;
  int v = b;
  while (p) {
    if (p & 1) res = (1ll * v * res) % mod;
    v = (1ll * v * v) % mod;
    p /= 2;
  }
  return res;
}
int main() {
  scanf("%d", &mod);
  if (mod == 1) {
    puts("YES\n1");
    return 0;
  } else if (mod == 4) {
    puts("YES\n1\n3\n2\n4");
    return 0;
  } else {
    if (!prime(mod)) {
      puts("NO");
      return 0;
    }
    puts("YES\n1");
    for (int i = 2; i < mod; ++i) {
      printf("%lld\n", (1ll * i * fastpower(i - 1, mod - 2)) % mod);
    }
    printf("%d\n", mod);
  }
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int co = 0;
  int j = 0;
  string val;
  cin >> val;
  while (j < n) {
    if (val[j] == '1') {
      co++;
      j++;
    } else {
      co++;
      break;
    }
  }
  cout << co;
  return 0;
}

import java.io.*;

public class main
{
	public static void main(String[] args) throws Exception{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int len = Integer.parseInt(reader.readLine());
		String st = reader.readLine();

		int count = 0;
		for(int i =0;i<len;i++)
		{
			if(st.charAt(i) == '0')
				break;
			else
				count++;
		}

		if(count < len)
			count++;

		System.out.println(count);
	}
}


m,n=map(int,input().split())
a=[]
for i in range(m):
    p=[int(j) for j in input().split()]
    a.append(p)

for j in range(1,m):
    a[j][0]+=a[j-1][0]

for i in range(1,n):
    a[0][i]+=a[0][i-1]
    #print(a)
    for j in range(1,m):
        a[j][i]+=max(a[j-1][i],a[j][i-1])

#print(a)
for i in range(m):
    p=int(a[i][n-1])
    print(p)

import java.util.*;

public class ArtUnion {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        int p[][] = new int[m][n];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++)
                p[i][j] = sc.nextInt();
        }
        int tt[] = new int[m];
        for (int i = 0; i < n; i++) {
            int done = 0;
            for (int j = 0; j < m; j++) {
                int t = (int) (Math.max(done, tt[j]));
                tt[j] = t + p[j][i];
                done = tt[j];
            }
        }
        for (int i = 0; i < m; i++)
            System.out.print(tt[i] + " ");
    }
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  string t;
  cin >> t;
  long long a = 0, b = 0, c = 0, d = 0, q;
  for (long long i = 0; i < t.size(); i++) {
    if (t[i] == 'n') {
      a++;
    } else if (t[i] == 'i') {
      b++;
    } else if (t[i] == 'e') {
      c++;
    } else if (t[i] == 't') {
      d++;
    }
  }
  if (a < 5) {
    q = (a / 3);
  } else {
    q = ((a - 1) / 2);
  }
  long long ans = 10000000;
  ans = min(ans, q);
  ans = min(ans, (c / 3));
  ans = min(ans, b);
  ans = min(ans, d);
  cout << ans;
  return 0;
}


import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	static BigInteger intSqrt(BigInteger n) {
		BigInteger x, y = n;

		if (n.equals(BigInteger.ZERO)) return n;
		do {
			x = y;
			y = x.add(n.divide(x)).shiftRight(1);
		} while (y.compareTo(x) < 0);

		return x;
	}

	static BigInteger check(BigInteger n, int t) {
		BigInteger b = BigInteger.valueOf(2).pow(t + 1).subtract(BigInteger.valueOf(3));
		BigInteger c = n.multiply(BigInteger.valueOf(2));
		BigInteger x = b.multiply(b).add(c.multiply(BigInteger.valueOf(4)));
		BigInteger k;

		if (x.compareTo(BigInteger.ZERO) < 0) return BigInteger.valueOf(-1);
		BigInteger d = intSqrt(x);
		if (!d.multiply(d).equals(x)) return BigInteger.valueOf(-1);
		if ((d.subtract(b).and(BigInteger.ONE)).equals(BigInteger.ONE)) return BigInteger.valueOf(-1);
		k = d.subtract(b).shiftRight(1);
		if ((k.and(BigInteger.ONE)).equals(BigInteger.ZERO)) return BigInteger.valueOf(-1);

		return k;
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner cin = new Scanner(System.in);
		long n, x = 1;
		int i;
		BigInteger cur;
		ArrayList<BigInteger> ans = new ArrayList<BigInteger>();

		while (cin.hasNext()) {
			n = cin.nextLong();
			ans.clear();
			for (i = 0; (x << i) - 1 <= n; ++i) {
				cur = check(BigInteger.valueOf(n), i);
				if (!cur.equals(BigInteger.valueOf(-1))) ans.add(cur.shiftLeft(i));
			}

			if (ans.size() == 0) System.out.println(-1);
			else {
				Collections.sort(ans);
				for (BigInteger e : ans) {
					System.out.println(e);
				}
			}
		}
	}

}

import sys

def isqrt(n):
    l = -1
    h = n
    while l + 1 < h:
        m = (l + h) // 2
        if m * m <= n:
            l = m
        else:
            h = m
    return l

with sys.stdin as fin, sys.stdout as fout:
    n = int(next(fin))

    ans = []
    for i in range(64 + 1):
        a = 2 ** i - 1
        q = 1 - 4 * a + 4 * a ** 2 + 8 * n
        rt = isqrt(q)
        if rt ** 2 != q:
            continue
        res = 1 - 2 * a + rt
        if res % 2 != 0 or res % 4 == 0:
            continue
        ans.append(res // 2 * 2 ** i)

    if not ans:
        print(-1, file=fout)
    else:
        for i in ans:
            print(i, file=fout)


from collections import defaultdict
import math
n=int(input())
d=defaultdict(int)
o=defaultdict(int)
for i in range(n):
    x,y=map(int,input().split())
    o[x]+=1
    d[x]+=1
    if y!=x:
        d[y]+=1
mi=10**5+1
for i in d:
##    print(d[i])
    if d[i]>=math.ceil(n/2):
        mi=min(mi,max(math.ceil(n/2)-o[i],0))
if mi==10**5+1:
    print(-1)
else:
    print(mi)

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

public class Eelephant {
	static final int EPS = (int) 1e10;

public static void main(String[] args) {
	Scanner sc   = new Scanner(System.in);
	int n = sc.nextInt();
	HashMap<Integer, Integer> front = new HashMap<>();
	HashMap<Integer, Integer> back = new HashMap<>();
	ArrayList<Integer> a = new ArrayList<>();

	for (int i = 0; i < n; i++) {
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (front.get(x) == null) {
			front.put(x, 0);
			a.add(x);

		}
		if (front.get(y) == null) {
			front.put(y, 0);
			a.add(y);

		}
		front.put(x, front.get(x) + 1);
		if (back.get(y) == null) {
			a.add(y);
			back.put(y, 0);
		}

		if (back.get(x) == null) {
			a.add(x);
			back.put(x, 0);
		}
		if (x != y)
			back.put(y, back.get(y) + 1);
	}

	int min = EPS;
	for (int i = 0; i < a.size(); i++) {
		int x = a.get(i);
		if(front.get(x) >= (n+1)/2)
		{
			min = 0;
			break;
		}else{

			if( back.get(x) + front.get(x) >= (n + 1) / 2){
				int b = (n + 1) / 2 - front.get(x);
				if(b < min)
					min = b;
			}

		}

	}

	if(min == EPS)
		System.out.println(-1);
	else
		System.out.println(min);

}
}


n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

d={}
for i in range(n):
	d[a[i]]=b[i]

for i in range(1,n+1):
	print(d[i],end=" ")
print()

4 2 1 4 3 4 1 3 2
```

Each sample input consists of 4 lines: the first line contains the integer `n`, the second line contains the sequence `a`, the third line contains the sequence `b`, and the fourth line is blank. The values in each sequence are separated by a single space.

#include <bits/stdc++.h>
using namespace std;
int arr[100005];
int ans[100005];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> arr[i];
  }
  for (int i = 1; i <= n; ++i) {
    cin >> ans[arr[i]];
  }
  for (int i = 1; i <= n; ++i) cout << ans[i] << " ";
  return 0;
}


import math
for t in range(int(input())):
    a,b,n=map(int,input().split())
    attack=list(map(int,input().split()))
    health=list(map(int,input().split()))
    val=[]
    for i in range(n):
        val+=[[attack[i],health[i]]]
    val.sort()
    poss=True
    for i in range(n):
        times=math.ceil(val[i][1]/a)
        if i==n-1:
            if b-((times-1)*val[i][0])>0:
                b-=times*val[i][0]
                continue
            else:
                poss=False
                continue
        b-=times*val[i][0]
        if b<=0:
            poss=False
    if poss:
        print("YES")
    else:
        print("NO")

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

public class HelloWorld {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int t = input.nextInt();
		for(int j = 0;j<t;j++){
			long x = input.nextLong();
			long y = input.nextLong();
			int n = input.nextInt();
			long[] a = new long[n];
			long[] b = new long[n];

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

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

			int i = 0;
			long max = 0;
			while(i < n){
				long times = (b[i] + x-1)/x;
				y-= times*a[i];
				max = Math.max(max,a[i]);
				i++;
			}

			System.out.println(y+max > 0? "YES": "NO");

		}
	}
}


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

import static java.lang.Math.log;
import static java.lang.Math.min;

public class First {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        int t;
        //t = in.nextInt();
        t = 1;
        while (t > 0) {
            solver.call(in,out);
            t--;
        }
        out.close();
    }

    static class TaskA {
        public void call(InputReader in, PrintWriter out) {
            int index , a = 0;
            long t = 0 , ans = 0 , l , r;
            l = in.nextInt();
            r = in.nextInt();

            ArrayList<Long> arrayList = new ArrayList<>();
            arrayList.add(4L);
            arrayList.add(7L);

            index = 0;
            while(t<10000000000L){
                t = arrayList.get(index)*10;
                arrayList.add(t+4);
                arrayList.add(t+7);
                index++;
            }
            index = 0;
            while(arrayList.get(index)<l){
                index++;
            }
            while(arrayList.get(a)<r){
                a++;
            }

            for (int i = index; i <= a; i++) {
                if (arrayList.get(i) < r) {
                    ans += arrayList.get(i) * (arrayList.get(i) - l + 1);
                    l = arrayList.get(i) + 1;
                }
                else{
                    ans+= arrayList.get(i)*((r-l) +1);
                }
            }
            out.println(ans);

        }
    }

    static class answer implements Comparable<answer> {
        int a, b;

        public answer(int a, int b) {
            this.a = a;
            this.b = b;
        }

        @Override
        public int compareTo(answer o) {
            return this.a - o.a;
        }
    }

    static long gcd(long a, long b)
    {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }

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

    static final Random random=new Random();

    static void shuffleSort(int[] arr) {
        int n=arr.length;
        for (int i=0; i<n; i++) {
            int a=random.nextInt(n), temp=arr[a];
            arr[a]=arr[i];
            arr[i]=temp;
        }
        Arrays.sort(arr);
    }

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

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

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

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong(){
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }
}

#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long int INF = 1e18;
const int N = 100005;
const int MOD = 1e9 + 7;
const double EPS = 1e-6;
const double PI = acos(-1.0);
vector<long long int> V;
void dfs(long long int x) {
  V.push_back(x);
  if (x > inf) return;
  dfs(10 * x + 4);
  dfs(10 * x + 7);
}
long long int Binary_Search(long long int val) {
  long long int lo = 0, hi = V.size() - 1;
  long long int ret = 0;
  while (lo <= hi) {
    long long int mid = (lo + hi) >> 1;
    if (V[mid] >= val) {
      ret = V[mid];
      hi = mid - 1;
    } else
      lo = mid + 1;
  }
  return ret;
}
int main(int argc, char const *argv[]) {
  dfs(0);
  sort(V.begin(), V.end());
  long long int l, r;
  cin >> l >> r;
  long long int ans = 0;
  while (l <= r) {
    long long int val = Binary_Search(l);
    ans += (min(val, r) - l + 1) * val;
    l = min(val, r) + 1;
  }
  cout << ans << endl;
  return 0;
}


n = int(input())
s = input()

i,p=0,1
ans = ''
while i<(n-1):
    if p%2 == 1:
        if s[i] != s[i+1]:
            ans = ans + s[i]
            p += 1
    else:
        ans = ans + s[i]
        p += 1

    i += 1

if len(ans)%2 == 1:
    ans += s[-1]
print(len(s)-len(ans))
print(ans)

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

public class ggg {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		String eg=scan.next();
		int cost=0;
		String ans="";
		Stack<Character> stk=new Stack<Character>();
		ArrayList<Character> anss=new ArrayList<Character>();
		for(int i=0;i<n;i++)
		{
//			System.out.println(eg.charAt(i));
			int j=i+1;
			int x=0;
			while(j<n &&eg.charAt(i)==eg.charAt(j))
			{
				j++;
				x++;
				cost++;
			}
			if(j>=n)
			{
				cost++;
				break;
			}
//			System.out.print(eg.charAt(i));
//			System.out.print(eg.charAt(j));
			anss.add(eg.charAt(i));
			anss.add(eg.charAt(j));
			i+=x+1;
		}
		System.out.println(cost);
//		System.out.println(ans);
		for(char x:anss)
		{
			System.out.print(x);;
		}
	}
}