import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
import java.util.StringTokenizer;

public class Main {
    Scanner in;
    PrintWriter out;

    void setIn(String fI) {

        try {
            in = new Scanner(new FileInputStream(new File(fI)));
        } catch (FileNotFoundException e) {
            throw new Error(e);
        }
    }

    void setIn() {
        in = new Scanner(System.in);
    }

    void setOut(String fO) {
        try {
            out = new PrintWriter(new FileWriter(fO));
        } catch (IOException e) {
            throw new Error(e);
        }
    }

    void setOut() {
        out = new PrintWriter(System.out);
    }

    class Scanner {
        StringTokenizer st;
        BufferedReader in;
        String del;

        Scanner(InputStream is) {
            in = new BufferedReader(new InputStreamReader(is));
            st = null;
            del = " \t\n\r\f";
        }

        void setDelimiters(String del) {
            this.del = del;
        }

        String next() {
            if (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(nextLine(), del);
            }
            return st.nextToken();
        }

        String nextLine() {
            try {
                st = null;
                return in.readLine();
            } catch (IOException e) {
                throw new Error(e);
            }
        }

        boolean hasNext() {
            try {
                return in.ready() || (st != null && st.hasMoreTokens());
            } catch (IOException e) {
                throw new Error(e);
            }
        }

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

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

        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }

        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }

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

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

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

    void run() {
        setIn();
        setOut();
        try {
            solve();
        } finally {
            out.close();
        }
    }

    MathContext pr = new MathContext(15);

    BigDecimal pow(BigDecimal a, int n) {
        if (n == 0) {
            return BigDecimal.ONE;
        }
        if (a.compareTo(new BigDecimal(1e-8)) < 0) {
            return BigDecimal.ZERO;
        }
        BigDecimal res = BigDecimal.ONE;
        while (n > 0) {
            if ((n & 1) == 1) {
                res = res.multiply(a, pr);
            }
            a = a.multiply(a, pr);
            n >>= 1;
        }
        return res;
    }

    BigDecimal f(int a, int b, double s, double x) {
        return pow(new BigDecimal(x), a).multiply(pow(new BigDecimal(s - x), b), pr);
    }

    BigDecimal t2(double s, int a, int b) {
        double l = 0;
        double r = s;
        double eps = 1e-6;
        while (r - l > eps) {
            double m1 = l + (r - l) / 2.5;
            double m2 = r - (r - l) / 2.5;
            if (f(a, b, s, m1).compareTo(f(a, b, s, m2)) < 0) {
                l = m1;
            } else {
                r = m2;
            }
        }
        r2 = l;
        r3 = s - l;
        return f(a, b, s, l);

    }

    double r1, r2, r3;

    BigDecimal t1(double s, int a, int b, int c) {
        double l = 0;
        double r = s;
        double eps = 1e-6;
        while (r - l > eps) {

            double m1 = l + (r - l) / 2.5;
            double m2 = r - (r - l) / 2.5;
            if (pow(new BigDecimal(m1), a).multiply(t2(s - m1, b, c), pr).compareTo(
                    pow(new BigDecimal(m2), a).multiply(t2(s - m2, b, c), pr)) < 0) {
                l = m1;
            } else {
                r = m2;
            }
        }
        r1 = l;
        return pow(new BigDecimal(l), a).multiply(t2(s - l, b, c), pr);
    }

    void solve() {
        long t = System.currentTimeMillis();
        double s = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        t1(s, a, b, c);
        out.println(r1 + " " + r2 + " " + r3);
        // out.println(System.currentTimeMillis() - t);

    }
}

S = int(input())
v = [int(x) for x in input().strip().split()]
zeroes = v.count(0)
total = sum(v)
ans = []
if zeroes == 0:
    ans = [S * v[i] / total for i in range(3)]
elif zeroes == 1:
    for i in range(3):
        if v[i] == 0:
            total -= v[i]
    for i in range(3):
        if v[i] != 0:
            ans.append(S * v[i] / total)
        else:
            ans.append(0)
else:
    # 2 or more
    for i in range(3):
        if v[i] == 0:
            ans.append(0)
        else:
            ans.append(S)
print(*ans)


def main():
    k, s = lie(), input()
    n = len(s)
    dp = [-1]
    for i in range(n):
        if s[i] == '1':
            dp.append(i)
    dp.append(n)
    if len(dp) - 2 < k:
        print(0)
    elif k == 0:
        ans = 0
        for i in range(1, len(dp)):
            ans += (dp[i] - dp[i - 1] - 1) * (dp[i] - dp[i - 1]) // 2
        print(ans)
    else:
        ans = 0
        for i in range(k, len(dp) - 1):
            ans += (dp[i + 1] - dp[i]) * (dp[i - k + 1] - dp[i - k])
        print(ans)

def fun(n, m, k):
    pass

from sys import *
import inspect
import re
from math import *
import threading
from collections import *
from pprint import pprint as pp
mod = 998244353
MAX = 10**5

def lie():
    return int(input())

def liee():
    return map(int, input().split())

def array():
    return list(map(int, input().split()))

def deb(p):
    for line in inspect.getframeinfo(inspect.currentframe().f_back)[3]:
        m = re.search(r'\bdeb\s*\(\s*([A-Za-z_][A-Za-z0-9_]*)\s*\)', line)
        print('%s %d' % (m.group(1), p))

def vector(size, val=0):
    vec = [val for i in range(size)]
    return vec

def matrix(rowNum, colNum, val=0):
    mat = []
    for i in range(rowNum):
        collumn = [val for j in range(colNum)]
        mat.append(collumn)
    return mat

def dmain():
    sys.setrecursionlimit(100000000)
    threading.stack_size(40960000)
    thread = threading.Thread(target=main)
    thread.start()

if __name__ == '__main__':
    main()
    # dmain()

#include <bits/stdc++.h>
using namespace std;
const int N = 1000001;
string s;
int cnt, dp[N], k;
long long ans, c0;
int main() {
  cin >> k >> s;
  int n = s.length();
  for (int i = 0; i < n; i++) {
    if (s[i] == '1')
      cnt++, dp[cnt] = i, ans += (c0 * (c0 + 1)) / 2, c0 = 0;
    else
      c0++;
  }
  ans += (c0 * (c0 + 1)) / 2;
  if (k == 0) {
    cout << ans;
    return 0;
  }
  ans = 0;
  for (int i = k; i <= cnt; i++) {
    int l, r;
    if (i - k == 0)
      l = dp[1] + 1;
    else
      l = dp[i - k + 1] - dp[i - k];
    if (i == cnt)
      r = n - dp[cnt];
    else
      r = dp[i + 1] - dp[i];
    ans += (1ll * l * 1ll * r);
  }
  cout << ans;
  return 0;
}


import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String fgfg[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        int k=Integer.parseInt(br.readLine());
        pw.println("2 3");
        pw.println(((int)Math.pow(2,17)+k)+" "+(int)Math.pow(2,17)+" 0");
        pw.println(k+" "+((int)Math.pow(2,17)+k)+" "+k);
        pw.flush();
        pw.close();
    }
}


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

public class Main {

    public static void main( String[] args ) {

        BufferedReader bis = new BufferedReader(new InputStreamReader(System.in));
        // BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));

        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        int n = in.nextInt();
        if (n == 1){
            out.println("YES");
            out.print("1 2");
        }else{
            if (n % 2 == 0){
                out.println("NO");
            }else{
                out.print("YES\n");
                int[] answ = new int[2 * n];
                answ[0] = 1;
                for (int i = 1; i < n; i++){
                    if (i % 2 == 1){
                        answ[i] = answ[i - 1] + 3;
                    }else{
                        answ[i] = answ[i - 1] + 1;
                    }
                }
                for (int i = n; i < 2 * n; i++){
                    if (i % 2 == 1){
                        answ[i] = answ[i - n] + 1;
                    }else{
                        answ[i] = answ[i - n] - 1;
                    }
                }
                for (int i = 0; i < 2 * n; i++){
                    out.print(answ[i] + " ");
                }
            }
        }

        out.flush();
    }

    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(input())
if n%2==0:
    print('NO')
else:
    print('YES')
    ans=1
    c=3
    for i in range(n):
        if i==0:
            print(ans,end=' ')
        else:
            print(ans+c,end=' ')
            ans=ans+c
            c=1 if c==3 else 3
    ans=2
    c=1
    for i in range(n):
        if i==0:
            print(ans,end=' ')
        else:
            print(ans+c,end=' ')
            ans=ans+c
            c=1 if c==3 else 3


#include <bits/stdc++.h>
using namespace std;
const int N = 3e6 + 10;
int n, m, a, b, x, y, sum, sum1, sum2, sum3, a1[N], a2[N];
int main() {
  scanf("%d%d%d%d", &n, &m, &x, &y);
  sum1 = sum = 1;
  for (int i = 1; i < m; i++) {
    scanf("%d%d", &a, &b);
    if (a == x || b == x)
      sum++;
    else
      sum2 = max(sum2, max(++a1[a], ++a1[b]));
    if (a == y || b == y)
      sum1++;
    else
      sum3 = max(sum3, max(++a2[a], ++a2[b]));
  }
  if (sum + sum2 == m || sum1 + sum3 == m)
    puts("YES");
  else
    puts("NO");
  return 0;
}

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

bound, m = [int(x) for x in input().split()]

if m == 1:
    print("YES")
    exit(0)

pairs_uniq = set()
for _ in range(m):
    x = [int(x) for x in input().split()]
    x.sort()
    pairs_uniq.add((x[0], x[1]))

if len(pairs_uniq) == 1:
    print("YES")
    exit(0)

pairs = [x for x in pairs_uniq]

# Choose the first one as our x
for x in pairs[0]:
    no_x_pairs = [n for n in pairs if n[0] != x and n[1] != x]

    x_pairs_count = 0
    d = {}
    for (i, j) in pairs:
        if i != x and j != x:
            if i not in d:
                d[i] = 0
            d[i] += 1
            if j not in d:
                d[j] = 0
            d[j] += 1
        else:
            x_pairs_count += 1

    max_ = 0 if len(d.values()) == 0 else sorted(d.values())[-1]
    if max_ + x_pairs_count == len(pairs):
        print("YES")
        exit(0)

print("NO")


n=int(input())
a=list(map(int,input().split()))
if len(set(a))==n:
    a.append(n)
    print(*a)
else:
    a.insert(0,0)
    b=[n]
    x=n
    while x!=1:
        b.append(a[x-1])
        x=a[x-1]
    print(*b[::-1])

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

public class bmail{

	static void path(Stack<Integer> s)
	{
		while(!s.isEmpty())
		{
			System.out.print(s.pop() + " ");
		}
	}

	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int n= sc.nextInt();
		int arr[]=new int[n+1];
		Stack<Integer> stack=new Stack<Integer>();
		for(int i=1; i<n; i++)
		{
			arr[i]= sc.nextInt();
		}
		int j=n;
		while(j>1)
		{
			stack.add(j);
			j=arr[j-1];
		}
		stack.add(1);
		path(stack);
	}
}


/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
     public static void main (String[] args) throws java.lang.Exception
     {
     	Scanner in =new Scanner(System.in);
		int n,j,t=1,i,m,p=0,h;
		String st,s,s1="";
		//substring( //toCharArray();
		//Arrays.sort();
		s=in.next();
		n=s.length();
		char c[]=s.toCharArray();
		for(i=0;i<n;i++)
		{
		     if(c[i]=='a' || c[i]=='i'|| c[i]=='e'|| c[i]=='o'|| c[i]=='u' || c[i]=='1'|| c[i]=='3'|| c[i]=='5'|| c[i]=='7'|| c[i]=='9')
		          p++;
		}
		System.out.println(p);
     }
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int N[3];
  cin >> N[0] >> N[1] >> N[2];
  sort(N, N + 3);
  int res = N[1] - N[0] + N[2] - N[1];
  cout << res << endl;
  return 0;
}

import java.util.*;
public class MeetingFriends {
    public static void main(String args[]){
        Scanner scannerin=new Scanner(System.in);
        int firstperson_position=scannerin.nextInt();
        int secondperson_position=scannerin.nextInt();
        int thirderson_position=scannerin.nextInt();
        int[] arr_position={firstperson_position,secondperson_position,thirderson_position};
        Arrays.sort(arr_position);
        int answer=arr_position[2]-arr_position[0];
        System.out.println(answer);
    }
}


n = int(input())
s = map(int, input().split())
l = []
a = 'NO'
for i in s:
    if i not in l:
        l += [i]
l = sorted(l)
if len(l) >= 3:
    for i in range(len(l) - 2):
        if l[i] + 2 == l[i + 1] + 1 == l[i + 2]:
            a = 'YES'
print(a)

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[1000 + 20] = {}, x, y = 0;
  bool ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    y = max(x, y);
    a[x - 1]++;
  }
  for (int i = 0; i < (y - 2); i++) {
    if (a[i] && a[i + 1] && a[i + 2]) {
      ans = 1;
      break;
    }
  }
  if (ans)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Iterator;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.NoSuchElementException;
import java.io.InputStream;

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

    static class AGennadyTheDentist {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.readInt();
            int[] v = new int[n];
            int[] d = new int[n];
            int[] p = new int[n];
            for (int i = 0; i < n; i++) {
                v[i] = in.readInt();
                d[i] = in.readInt();
                p[i] = in.readInt();
            }
            boolean[] inQueue = new boolean[n];
            IntList answer = new IntArrayList();
            Arrays.fill(inQueue, true);
            for (int i = 0; i < n; i++) {
                if (inQueue[i]) {
                    answer.add(i + 1);
                    IntList runAway = new IntArrayList();
                    inQueue[i] = false;
                    int current = v[i];
                    for (int j = i + 1; j < n && current > 0; j++) {
                        if (inQueue[j]) {
                            p[j] -= current--;
                            if (p[j] < 0) {
                                inQueue[j] = false;
                                runAway.add(j);
                            }
                        }
                    }
                    for (int l = 0; l < runAway.size(); l++) {
                        int j = runAway.get(l);
                        for (int k = j + 1; k < n; k++) {
                            if (inQueue[k]) {
                                p[k] -= d[j];
                                if (p[k] < 0) {
                                    inQueue[k] = false;
                                    runAway.add(k);
                                }
                            }
                        }
                    }
                }

            }
            out.printLine(answer.size());
            out.printLine(answer);
        }

    }

    static interface IntList extends IntReversableCollection {
        public abstract int get(int index);

        public abstract void addAt(int index, int value);

        public abstract void removeAt(int index);

        default public IntIterator intIterator() {
            return new IntIterator() {
                private int at;
                private boolean removed;

                public int value() {
                    if (removed) {
                        throw new IllegalStateException();
                    }
                    return get(at);
                }

                public boolean advance() {
                    at++;
                    removed = false;
                    return isValid();
                }

                public boolean isValid() {
                    return !removed && at < size();
                }

                public void remove() {
                    removeAt(at);
                    at--;
                    removed = true;
                }
            };
        }

        default public void add(int value) {
            addAt(size(), value);
        }

    }

    static abstract class IntAbstractStream implements IntStream {
        public String toString() {
            StringBuilder builder = new StringBuilder();
            boolean first = true;
            for (IntIterator it = intIterator(); it.isValid(); it.advance()) {
                if (first) {
                    first = false;
                } else {
                    builder.append(' ');
                }
                builder.append(it.value());
            }
            return builder.toString();
        }

        public boolean equals(Object o) {
            if (!(o instanceof IntStream)) {
                return false;
            }
            IntStream c = (IntStream) o;
            IntIterator it = intIterator();
            IntIterator jt = c.intIterator();
            while (it.isValid() && jt.isValid()) {
                if (it.value() != jt.value()) {
                    return false;
                }
                it.advance();
                jt.advance();
            }
            return !it.isValid() && !jt.isValid();
        }

        public int hashCode() {
            int result = 0;
            for (IntIterator it = intIterator(); it.isValid(); it.advance()) {
                result *= 31;
                result += it.value();
            }
            return result;
        }

    }

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

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

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

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

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

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

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

        }

    }

    static interface IntCollection extends IntStream {
        public int size();

        default public void add(int value) {
            throw new UnsupportedOperationException();
        }

        default public IntCollection addAll(IntStream values) {
            for (IntIterator it = values.intIterator(); it.isValid(); it.advance()) {
                add(it.value());
            }
            return this;
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

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

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

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

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

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

        public void printLine(int i) {
            writer.println(i);
        }

    }

    static interface IntIterator {
        public int value() throws NoSuchElementException;

        public boolean advance();

        public boolean isValid();

    }

    static interface IntStream extends Iterable<Integer>, Comparable<IntStream> {
        public IntIterator intIterator();

        default public Iterator<Integer> iterator() {
            return new Iterator<Integer>() {
                private IntIterator it = intIterator();

                public boolean hasNext() {
                    return it.isValid();
                }

                public Integer next() {
                    int result = it.value();
                    it.advance();
                    return result;
                }
            };
        }

        default public int compareTo(IntStream c) {
            IntIterator it = intIterator();
            IntIterator jt = c.intIterator();
            while (it.isValid() && jt.isValid()) {
                int i = it.value();
                int j = jt.value();
                if (i < j) {
                    return -1;
                } else if (i > j) {
                    return 1;
                }
                it.advance();
                jt.advance();
            }
            if (it.isValid()) {
                return 1;
            }
            if (jt.isValid()) {
                return -1;
            }
            return 0;
        }

    }

    static interface IntReversableCollection extends IntCollection {
    }

    static class IntArrayList extends IntAbstractStream implements IntList {
        private int size;
        private int[] data;

        public IntArrayList() {
            this(3);
        }

        public IntArrayList(int capacity) {
            data = new int[capacity];
        }

        public IntArrayList(IntCollection c) {
            this(c.size());
            addAll(c);
        }

        public IntArrayList(IntStream c) {
            this();
            if (c instanceof IntCollection) {
                ensureCapacity(((IntCollection) c).size());
            }
            addAll(c);
        }

        public IntArrayList(IntArrayList c) {
            size = c.size();
            data = c.data.clone();
        }

        public IntArrayList(int[] arr) {
            size = arr.length;
            data = arr.clone();
        }

        public int size() {
            return size;
        }

        public int get(int at) {
            if (at >= size) {
                throw new IndexOutOfBoundsException("at = " + at + ", size = " + size);
            }
            return data[at];
        }

        private void ensureCapacity(int capacity) {
            if (data.length >= capacity) {
                return;
            }
            capacity = Math.max(2 * data.length, capacity);
            data = Arrays.copyOf(data, capacity);
        }

        public void addAt(int index, int value) {
            ensureCapacity(size + 1);
            if (index > size || index < 0) {
                throw new IndexOutOfBoundsException("at = " + index + ", size = " + size);
            }
            if (index != size) {
                System.arraycopy(data, index, data, index + 1, size - index);
            }
            data[index] = value;
            size++;
        }

        public void removeAt(int index) {
            if (index >= size || index < 0) {
                throw new IndexOutOfBoundsException("at = " + index + ", size = " + size);
            }
            if (index != size - 1) {
                System.arraycopy(data, index + 1, data, index, size - index - 1);
            }
            size--;
        }

    }
}

#include <bits/stdc++.h>
using namespace std;
struct P {
  int v;
  int d;
  int p;
  P(const int v, const int d, const int p) : v(v), d(d), p(p) {}
};
int main() {
  int n;
  scanf("%d", &n);
  vector<P> vec;
  for (int i = 0; i < n; i++) {
    int v, d, p;
    scanf("%d%d%d", &v, &d, &p);
    vec.push_back(P(v, d, p));
  }
  vector<int> nom;
  for (int i = 0; i < n; i++) {
    int t = 0;
    int m = vec[i].p;
    if (m < 0) continue;
    nom.push_back(i);
    int k = vec[i].v;
    for (int j = i + 1; j < n; j++) {
      if (vec[j].p < 0) continue;
      vec[j].p = vec[j].p - k - t;
      if (vec[j].p < 0) t += vec[j].d;
      if (t > 1e7) t = 1e7;
      if (k) k--;
    }
  }
  n = (int)nom.size();
  printf("%d\n", n);
  for (int i = 0; i < n; i++) printf("%d ", nom[i] + 1);
}


#include <bits/stdc++.h>
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  if (m % 2 == 0)
    printf("%d", n * m / 2);
  else
    printf("%d", n * (m / 2) + n / 2);
  return 0;
}

import java.util.Scanner;
public class Domino {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner domi = new Scanner(System.in);
       //System.out.println("Introduce la primera medida");
       int M = domi.nextInt();
       //System.out.println("Introduce la segunda medida");
       int N = domi.nextInt();
       int a = M*N/2;
       if (M<1 || M>16 ){
    	   System.out.println();
       }
        if (N<1 || N>16 ){
    	   System.out.println();
       }

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

	}

}


#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 4;
int n, m;
long long int a[N];
long long ans = 0;
bool cmp(long long a, long long b) { return a > b; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%I64d", a + i);
  sort(a + 1, a + n + 1);
  if (n == 1) {
    cout << a[1];
    return 0;
  }
  if (n == 2) {
    cout << 2 * (a[1] + a[2]);
    return 0;
  }
  ans = 1LL * a[n] * n;
  for (int i = n - 1; i >= 1; --i) ans += 1LL * a[i] * (i + 1);
  cout << ans;
}

import java.io.*;
import java.util.*;
public class Toastman
{
    public static void main(String[]args)throws IOException
    {
        BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        String s[]=br.readLine().split(" ");
        long a[]=new long[n];
        int i;
        long sum=0;
        for(i=0;i<n;i++)
        {
            a[i]=Long.parseLong(s[i]);
        }
        Arrays.sort(a);
        for(i=0;i<n-1;i++)
        {
            sum+=((i+2)*(a[i]));
        }
        sum+=(a[n-1]*n);
        System.out.println(sum);

    }
}


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

public class MainClass {

    private static BufferedReader br = null;
	private static StringTokenizer st = null;

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

	private static String str() throws IOException {
		return br.readLine();
	}

	private static int ints() throws IOException {
		return Integer.parseInt(br.readLine());
	}

	private static int[] ints(int N) throws IOException {
		st = new StringTokenizer(br.readLine());
		int[] nums = new int[N];
		for(int i = 0; i < N; i += 1) {
			nums[i] = Integer.parseInt(st.nextToken());
		}
		return nums;
	}

	public static void main(String[] args) throws IOException {
	    long N = ints();
	    int[] epi = ints((int)(N - 1));
		Solution obj = new Solution();
	    System.out.println(obj.forgottenEpisode(epi, N));
		br.close();
    }
}

class Solution {

    public long sum(int[] nums) {
        long sum = 0;
        for(int num : nums) sum += num;
		return sum;
    }

	public long forgottenEpisode(int[] nums, long N) {
	   long sum_upto_N = (N * (N + 1)) / 2;
	   long sum = sum(nums);
	   return (sum_upto_N - sum);
	}
}

#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, epo;
  vector<int> epos;
  cin >> n;
  for (i = 1; i < n; i++) {
    cin >> epo;
    epos.push_back(epo);
  }
  sort(epos.begin(), epos.end());
  epo = 1;
  for (i = 0; i < n; i++, epo++) {
    if (epos[i] != epo) {
      cout << epo;
      break;
    }
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
template <class T, class L>
bool smax(T &x, L y) {
  return x < y ? (x = y, 1) : 0;
}
template <class T, class L>
bool smin(T &x, L y) {
  return y < x ? (x = y, 1) : 0;
}
const int maxn = 2e3 + 17, mod = 1e9 + 7;
int n, dp[maxn][2048], ans, s[maxn], a[maxn], k;
void go(int i, int mask, int ad) {
  if ((mask & -mask) < ad)
    (dp[i + 1][ad] += dp[i][mask]) %= mod;
  else if (mask + ad == 1 << k)
    (ans += (long long)dp[i][mask] * s[i + 1] % mod) %= mod;
  else
    (dp[i + 1][mask + ad] += dp[i][mask]) %= mod;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n >> k, k--;
  for (int i = 0; i < n; i++) cin >> a[i], a[i] /= 2;
  s[n] = 1;
  for (int i = n - 1; ~i; i--) s[i] = s[i + 1] * (a[i] ? 1 : 2) % mod;
  dp[0][0] = 1;
  for (int i = 0; i < n; i++)
    for (int mask = 0; mask < 1 << k; mask++) {
      if (a[i] != 1) go(i, mask, 2);
      if (a[i] != 2) go(i, mask, 1);
    }
  cout << ans << '\n';
  return 0;
}

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

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

class TaskD {
    final static long MOD = 1000000000 + 7;
    public void solve(@SuppressWarnings("UnusedParameters") int testNumber, TokenizerReader in, PrintWriter out) {
        int n = in.nextInt(), k = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = in.nextInt() / 2;
        }

        int MAX_MASK = 1 << (k+1);
        long[][] dp = new long[n+1][MAX_MASK];
        for (int mask = 0; mask < MAX_MASK; ++mask)
            if ((mask & (1<<k)) > 0)
                dp[n][mask] = 1;

        for (int i = n-1; i >= 0; --i) {
            for (int mask = 0; mask < MAX_MASK; ++mask) {
                if (a[i] == 0)
                    dp[i][mask] = f(dp, i, mask, 1, k) + f(dp, i, mask, 2, k);
                else
                    dp[i][mask] = f(dp, i, mask, a[i], k);
                dp[i][mask] %= MOD;
            }
        }

        out.println(dp[0][0]);
    }

    private long f(long[][] dp, int n, int mask, int incoming, int k) {
        if ((mask & (1<<k)) == 0) {
            while (Integer.lowestOneBit(mask) == (1 << incoming)) {
                mask ^= (1 << incoming);
                ++incoming;
            }
            if (Integer.lowestOneBit(mask) < (1<<incoming))
                mask = 1<<incoming;
            else
                mask ^= (1<<incoming);
        }
        return dp[n+1][mask];
    }
}

class TokenizerReader extends StreamTokenizer {
    public TokenizerReader(InputStream in) {
        super(new BufferedReader(new InputStreamReader(in)));
        defaultConfig();
    }

    public String nextString() {
        try {
            nextToken();
        } catch (IOException e) {
            throw new RuntimeException("nextString: exception in line " + lineno(), e);
        }
        return sval;
    }

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

    public void defaultConfig() {
        resetSyntax();
        wordChars(33, 126);
        whitespaceChars(0, ' ');
    }

}


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

public class minFolder
{
	public static void main(String[] args) throws IOException
	{
		PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(reader.readLine().trim());

		int cnt = 0, res = 0;
		ArrayList<Integer> folder = new ArrayList<Integer>();

		StringTokenizer st = new StringTokenizer(reader.readLine());

		for(int i = 0; i < n; i++)
		{
			res++;
			int num = Integer.parseInt(st.nextToken());

			if(num < 0)
				cnt++;

			if(cnt == 3)
			{
				folder.add(res-1);
				res = cnt = 1;
			}
		}
		if(res != 0)
			folder.add(res);

		writer.println(folder.size() == 0 ? 1 : folder.size());

		for(int i = 0; i < folder.size(); i++)
			writer.print(folder.get(i) + (i != folder.size()-1 ? " ": "\n"));

		writer.flush();
		writer.close();

	}
}

#include <bits/stdc++.h>
using namespace std;
const long long int N = 2e5 + 5, MOD = 1000000007;
int n, a[111], c, c1;
vector<int> ans;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  for (int i = 0; i < n; ++i) {
    c1++;
    if (a[i] < 0) c++;
    if (c == 3) {
      ans.push_back(c1 - 1);
      c = 0;
      c1 = 0;
      i--;
    }
    if (i == n - 1) ans.push_back(c1);
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); ++i) printf("%d ", ans[i]);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long MOD, L, R, d, k, ans;
map<long long, long long> F;
long long fib(long long x) {
  if (x < 2) return 1 % MOD;
  if (F.count(x)) return F[x];
  long long k = x / 2;
  if (x % 2)
    return F[x] = (fib(k) * fib(k + 1) % MOD + fib(k) * fib(k - 1) % MOD) % MOD;
  return F[x] = (fib(k) * fib(k) % MOD + fib(k - 1) * fib(k - 1) % MOD) % MOD;
}
void cmon(long long x) {
  if (x && R / x - (L - 1) / x >= k) ans = max(ans, x);
}
void check(long long x) {
  long long l, r;
  for (l = 1; l <= x; l = r + 1) {
    r = x / (x / l);
    cmon(l - 1);
    cmon(l);
    cmon(l + 1);
    cmon(r - 1);
    cmon(r);
    cmon(r + 1);
  }
}
int main() {
  scanf("%lld %lld %lld %lld", &MOD, &L, &R, &k);
  d = R - L + 1;
  ans = d / k;
  check(R);
  check(L - 1);
  printf("%lld\n", fib(ans - 1));
  return 0;
}

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

public class C226 {

	class InputReader {

		public BufferedReader reader;
		public StringTokenizer tokenizer;

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

		public InputReader() throws FileNotFoundException {
			reader = new BufferedReader(new FileReader("d:/input.txt"));
			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());
		}

	}

	long mod;
	long base[][] = new long[][] { { 1, 1 }, { 1, 0 } };
	long[][] a = new long[][] { { 1, 1 }, { 1, 0 } };

	public long[][] mul(long a[][], long b[][]) {
		long re[][] = new long[2][2];
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < 2; j++) {
				for (int k = 0; k < 2; k++) {
					re[i][j] = (re[i][j] % mod + a[i][k] % mod
							* (b[k][j] % mod))
							% mod;
				}
			}
		}
		return re;
	}

	public long[][] pow(long a[][], long b) {

		long r[][] = new long[2][2];
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < 2; j++) {
				if (i == j)
					r[i][j] = 1;
				else
					r[i][j] = 0;
			}
		}
		long base[][] = a;
		while (b != 0) {
			if (b % 2 > 0)
				r = mul(r, base);
			base = mul(base, base);
			b /= 2;
		}
		return r;

	}

	public boolean judge(long p, long l, long r, long k) {
		return (r / p - (l - 1) / p) >= k;
	}

	public void run() {
		InputReader reader = new InputReader(System.in);
		mod = reader.nextLong();
		long l = reader.nextLong();
		long r = reader.nextLong();
		long k = reader.nextLong();
		long max = 0;
		for(int i = 1 ; (long)i*i <= r ; i ++){
			if(judge(i,l,r,k))
				max = Math.max(max, i);
			if(judge(r/i,l,r,k))
				max = Math.max(r/i, max);
		}
		long re[][] = pow(a,max-1);
		System.out.println(re[0][0]%mod);
	}

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

}


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

public class Solution {
    public static void main(String[] args)  {
       	Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int t = scan.nextInt();
		int ans = 0;
		ArrayList<Integer> list = new ArrayList();
		for (int i = 0; i < n; i++){
			int center = scan.nextInt()*2;
			int storona = scan.nextInt();
			list.add(center-storona);
			list.add(center+storona);
		}
		Collections.sort(list);
		for (int i = 1; i < n*2 - 1 ; i+=2){
			if (list.get(i+1)-list.get(i)>t*2){
				ans+=2;
			}
			else if (list.get(i+1)-list.get(i)==t*2){
			   ans+=1;
			}

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

n,t=list(map(int,input().split()))
amount=2
houses=[]
for i in range(n):
    c,l=list(map(int,input().split()))
    l=l/2
    start,end=c-l,c+l
    houses.append([start,end])

houses.sort(key=lambda x:x[0])
prev_end=houses[0][0]
for start,end in houses:
    gap=start-prev_end
    if gap>t:
        amount+=2
    elif gap==t:
        amount+=1
    prev_end=end

print(amount)


#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, R, r;
  cin >> n >> R >> r;
  if (r > R) {
    cout << "NO\n";
    return 0;
  }
  if (n == 1) {
    cout << "YES";
    return 0;
  }
  if (r > R - r) {
    cout << "NO";
    return 0;
  }
  double al = asin(1.0 * r / (R - r)) * n;
  if (al - 1e-10 <= acos(-1.0)) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}

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

import math
x=[int(i) for i in input().split()]
n,R,r=x[0],x[1],x[2]

if r>R:
    print('NO')
    raise SystemExit

if 2*r>R:
    if n>1:
        print('NO')
        raise SystemExit
    else:
        print('YES')
        raise SystemExit
z=2*n*math.asin(r/(R-r))
if z>2*math.pi+0.0000000001:
    print('NO')
else:
    print('YES')


import java.util.Scanner;
import java.lang.*;

public class B {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        long k  = in.nextLong();
        String s = "s";
        String o = "o";
        String c = "c";
        String d = "d";
        String f = "f";
        String e = "e";
        String r = "r";
        int[] freq = new int[10];
        for(int i=0; i<10; i++){
            freq[i] = 1;
        }
        long mul = 1;
        int idx = 0;
        while(mul < k){
            freq[idx]++;
            if(idx == 9){
                idx = 0;
            }
            else{
                idx ++;
            }
            mul = getmul(freq);
        }
        System.out.println(c.repeat(freq[0]) + o.repeat(freq[1]) + d.repeat(freq[2]) + e.repeat(freq[3]) + f.repeat(freq[4]) + o.repeat(freq[5]) + r.repeat(freq[6]) + c.repeat(freq[7]) + e.repeat(freq[8]) + s.repeat(freq[9]));
    }
    static long getmul(int[] freq){
        long num = 1;
        for(int i=0; i<freq.length; i++){
            num *= freq[i];
        }
        return num;
    }
}

xxx"
Each sample input must conform to the input data format, and the length of each sample input must not exceed 40 tokens.
Please give the inputs directly without any explanation.

Input:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50
input data format: [k
]
Please give me 50 sample inputs based on the description of the problem in the format "

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int main() {
  long long n;
  cin >> n;
  int p = 1;
  while ((long long)pow(p + 1, 10) <= n) {
    p++;
  }
  int z = 0;
  if ((long long)pow(p, 10) != n) {
    z++;
  }
  string s = "codeforces";
  string ans = "";
  int xp = 0;
  long long zp = (long long)pow(p, 10);
  while (zp < n) {
    xp++;
    zp = (long long)pow(p + z, xp) * (long long)pow(p, 10 - xp);
  }
  for (int i = 0; i < 10; ++i) {
    if (i < xp) {
      for (int j = 0; j < p + z; ++j) {
        ans += s[i];
      }
    } else {
      for (int j = 0; j < p; ++j) {
        ans += s[i];
      }
    }
  }
  cout << ans;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, i, j, k, x, y, t;
  long long int a, b;
  cin >> t;
  while (t--) {
    cin >> k >> n >> a >> b;
    k -= n * a;
    if (k > 0) {
      cout << n << endl;
      continue;
    }
    k = -k;
    k++;
    x = a - b;
    m = (k + x - 1) / x;
    if (m > n) {
      cout << -1 << endl;
    } else {
      cout << n - m << endl;
    }
  }
}

import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		HashSet<String> hs = new HashSet<>();
		for(int test_case = 1; test_case <= T; test_case++)
		{
			long K = sc.nextLong();
			long N = sc.nextLong();
			long a = sc.nextLong();
			long b = sc.nextLong();

			long res = -1;
			long l = 0, h = 2 * N, mid;
			while(l <= h)
			{
				mid = (l + h) / 2;
				if(mid > N)
				{
					h = mid - 1;
					continue;
				}
				long num = a * mid;

				if(K - num > b * (N - mid))
				{
					res = mid;
					l = mid + 1;
				}
				else h = mid - 1;
			}
			System.out.println(res);
		}
	}
}


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

public class D {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
//		Scanner seer = new Scanner(System.in);
		int n = Integer.parseInt(st.nextToken());
		int m = Integer.parseInt(st.nextToken());

		int[] sieve = new int[n+1];
		for(int i = 2; i <= n; i++){
			if(sieve[i] == 0){
				sieve[i] = i;
				if((long)i*(long)i > (long)n) continue;
				for(int j = i*i; j <= n; j+=i){
					sieve[j] = i;
				}
			}
		}
		ArrayList<Integer>[] ps = new ArrayList[n];
		for(int i = 0; i < n; i++){
			ps[i] = new ArrayList<>();
		}
		for(int i = 0; i < m; i++){
			st = new StringTokenizer(br.readLine());
			int a = Integer.parseInt(st.nextToken())-1;
			int b = Integer.parseInt(st.nextToken())-1;
			ps[a].add(b); ps[b].add(a);
		}
		for(int i = 0; i < n; i++){
			Collections.sort(ps[i]);
		}
		HashSet<Integer> divs = new HashSet<>();
		if(sieve[n] == n){
			divs.add(n);
		}
		else{
			int aux = n;
			while(aux > 1){
				divs.add(sieve[aux]);
				aux /= sieve[aux];
			}
		}
		boolean fits = false;
		for(int div: divs){
			int k = n/div;
			fits = true;
			for(int i = 0; i < n; i++){
				int s = (i+k)%n;
				int x = Integer.min(i, s);
				int y = Integer.max(i, s);
				if(ps[x].size() != ps[y].size()){
					fits = false; break;
				}
				int S = ps[i].size();
				if(S == 0) continue;
				int jy = 0;
				while(jy < S && (ps[y].get(jy) - ps[x].get(0) - (y-x) + n) % n != 0){
					jy++;
				}
				if(jy >= S){
					fits = false; break;
				}
				for(int j = 0; j < S; j++, jy++){
					if((ps[y].get(jy % S) - ps[x].get(j) - (y-x) + n) % n != 0){
						fits = false; break;
					}
				}
				if(!fits) break;
			}
			if(fits) break;
		}
		if(fits) System.out.println("Yes");
		else System.out.println("No");
	}
//	static class Pair{
//		int a, b;
//		public Pair(int a, int b){
//			this.a = a; this.b = b;
//		}
//		public String toString(){
//			return a+","+b;
//		}
//	}

}

n, m = map(int, input().split())

a = set()
for i in range(m):
	c, d = map(int, input().split())
	c %= n
	d %= n
	a.add((min(c, d), max(c, d)))

def comprobar(x):
	global a, n

	b = set()
	for c, d in a:
		c += x
		d += x
		c %= n
		d %= n
		if (min(c, d), max(c, d)) not in a:
			return False
		#print("COMPARACION", x)
		#print(a)
		#print(b)
	return True

for i in range(1, n):
	if n%i == 0:
		if comprobar(i):
			print("Yes")
			exit()

print("No")


# -*- coding: utf-8 -*-
"""
Created on Sun Feb 17 15:00:31 2019

@author: avina
"""

x,y,z = map(int, input().strip().split())

a,b,c = map(int,input().strip().split())
k=0
if a+b+c >= x+y+z:
    if a+b >= x+y:
        if a>=x:
            k+=1
if k != 0:
    print("YES")
else:
    print("NO")

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, x, y, z;
  scanf("%d%d%d", &x, &y, &z);
  scanf("%d%d%d", &a, &b, &c);
  if (x > a) {
    printf("NO");
    return 0;
  }
  a = a - x;
  if (y > a + b) {
    printf("NO");
    return 0;
  }
  if (z > a + b + c - y) {
    printf("NO");
    return 0;
  }
  printf("YES");
  return 0;
}


n, k, p = map(int, input().split())

for i in range(p):
    pos = int(input())
    if n % 2:
        if pos == n:
            print('X' if k > 0 else '.', end='')
        else:
            if k * 2 > n + 1:
                print('X' if (pos & 1) == 0 or (n - pos) // 2 \
                        + n // 2 + 1<= k else '.', end='')
            else:
                print('X' if (pos & 1) == 0 and \
                        (n + 1 - pos) // 2 < k else '.', end='')
    else:
        if k * 2 > n:
            print('X' if (pos & 1) == 0 or (n - pos + 1) // 2 + \
                    n // 2 <= k else '.', end='')
        else:
            print('X' if (pos & 1) == 0 and (n - pos + 2) // 2 <= k \
                    else '.', end='')


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Collection;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.OptionalInt;
import java.util.stream.Stream;
import java.util.Map;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, MyScan in, PrintWriter out) {
            int n = in.nextInt();
            String s1 = in.next();
            int m1 = v(s1);
            int m2 = v(in.next());
            int m3 = v(in.next());

            if (n != 1) {
                m1 = Math.min(s1.length(), m1 + n);
                m2 = Math.min(s1.length(), m2 + n);
                m3 = Math.min(s1.length(), m3 + n);
            } else {
                if (m1 == s1.length()) {
                    m1--;
                } else {
                    m1++;
                }

                if (m2 == s1.length()) {
                    m2--;
                } else {
                    m2++;
                }

                if (m3 == s1.length()) {
                    m3--;
                } else {
                    m3++;
                }
            }

            if (m1 > m2 && m1 > m3) {
                out.println("Kuro");
                return;
            }
            if (m2 > m1 && m2 > m3) {
                out.println("Shiro");
                return;
            }
            if (m3 > m1 && m3 > m2) {
                out.println("Katie");
                return;
            }
            out.println("Draw");
        }

        private int v(String next) {

            Map<Character, Integer> ret = new HashMap<>();

            for (char k : next.toCharArray()) {
                ret.merge(k, 1, Math::addExact);
            }

            return ret.values().stream().mapToInt(t -> t).max().getAsInt();

        }

    }

    static class MyScan {
        private final InputStream in;
        private byte[] inbuf = new byte[1024];
        public int lenbuf = 0;
        public int ptrbuf = 0;

        public MyScan(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (lenbuf == -1) throw new InputMismatchException();
            if (ptrbuf >= lenbuf) {
                ptrbuf = 0;
                try {
                    lenbuf = in.read(inbuf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0) return -1;
            }
            return inbuf[ptrbuf++];
        }

        public boolean isSpaceChar(int c) {
            return !(c >= 33 && c <= 126);
        }

        public int skip() {
            int b;
            while ((b = readByte()) != -1 && isSpaceChar(b)) ;
            return b;
        }

        public String next() {
            int b = skip();
            StringBuilder sb = new StringBuilder();
            while (!(isSpaceChar(b))) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public int nextInt() {
            int num = 0, b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = num * 10 + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

    }
}

5
@B¥d€F#IJklmnOpQ€StUvWxYz
€B¥d€F#IJklmnOpQ€StUvWxYz
€B¥d€F#IJklmnOpQ€StUvWxYz

50
aaaaABBBBcccCdddd
eeEEEfffFFggGGhh
HHIIJJJjjKKKkklll

7
treasurehunt
threefriends
hiCodeforces

15
ABCabcABCabcABC
abcABCabcABCabc
ABCabcABCabcABC

20
qwertyuiopQWERTYUIOP
ASDFGHJKLasdfghjklASDFGHJKL
zxcvbnmZXCVBNMzxcvbnmZXCVBNM

100
aBcDeFgHiJklmnOpQrStUvWxYzA
aBcDeFgHiJklmnOpQrStUvWxYzA
aBcDeFgHiJklmnOpQrStUvWxYzA

100
aBcDeFgHiJklmnOpQrStUvWxYz
aBcDeFgHiJklmnOpQrStUvWxYz
aBcDeFgHiJklmnOpQrStUvWxYz

Draw Kuro Draw Kuro Draw Draw Katie Draw Draw Draw Shiro Draw Draw Draw Draw Draw Katie Katie Draw Draw Draw Draw Draw Draw Draw Kuro Draw Draw Draw Katie Draw Kuro Draw Kuro

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7, mz = 1e9 + 7;
char s[N];
int p[5][255];
int main() {
  int n;
  cin >> n;
  int len[5];
  for (int i = 1; i <= 3; i++) {
    scanf("%s", s);
    len[i] = strlen(s);
    for (int j = 0; j < len[i]; j++) {
      p[i][s[j]]++;
      if (p[i][s[j]] > p[i][0]) p[i][0] = p[i][s[j]];
    }
  }
  int a = p[1][0];
  if (a == len[1] && n == 1)
    a = len[1] - 1;
  else
    a = min(a + n, len[1]);
  int b = p[2][0];
  if (b == len[2] && n == 1)
    b = len[2] - 1;
  else
    b = min(b + n, len[2]);
  int c = p[3][0];
  if (c == len[3] && n == 1)
    c = len[3] - 1;
  else
    c = min(c + n, len[3]);
  if (a == b && a > c || b == c && b > a || a == c && a > b ||
      a == b && b == c) {
    puts("Draw");
  } else if (a > b && a > c) {
    puts("Kuro");
  } else if (b > c) {
    puts("Shiro");
  } else {
    puts("Katie");
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int H = 1e5;
int a[H], s[H];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int h;
  cin >> h;
  for (int i = 0; i <= h; i++) cin >> a[i];
  s[0] = a[0];
  for (int i = 1; i <= h; i++) s[i] = s[i - 1] + a[i];
  bool ok = false;
  for (int i = 1; i <= h; i++)
    if (a[i - 1] >= 2 && a[i] >= 2) ok = true;
  if (!ok) cout << "perfect", exit(0);
  cout << "ambiguous\n";
  cout << 0 << " ";
  for (int i = 1; i <= h; i++)
    for (int j = 1; j <= a[i]; j++) cout << s[i - 1] << " ";
  cout << "\n" << 0 << " ";
  for (int i = 1; i <= h; i++)
    for (int j = 1; j <= a[i]; j++)
      if (a[i - 1] >= 2 && j >= 2)
        cout << s[i - 1] - 1 << " ";
      else
        cout << s[i - 1] << " ";
}

''' Hey stalker :) '''
INF = 10**10
def main():
    print = out.append
    ''' Cook your dish here! '''
    h = get_int()
    li = get_list()
    possible = False
    for i in range(h):
        if li[i]>1 and li[i+1]>1:
            possible = True
            break
    if not possible:
        print("perfect")
        return
    res1 = []
    res2 = []
    for index, i in enumerate(li):
        ele = len(res1)
        for _ in range(i):
            res1.append(ele)
            res2.append(ele)
        if index > 0 and li[index - 1] > 1 and i > 1: res2[-1] -= 1
    print("ambiguous")
    print(" ".join(map(str, res1)))
    print(" ".join(map(str, res2)))
    #print(" ".join(res2))

''' Pythonista fLite 1.1 '''
import sys
#from collections import defaultdict, Counter
#from bisect import bisect_left, bisect_right
#from functools import reduce
#import math
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()
#[main() for _ in range(int(input()))]
print(*out, sep='\n')


#include <bits/stdc++.h>
using namespace std;
int a[200005];
long long pre[200005];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int i;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    pre[i] = pre[i - 1] + a[i];
  }
  int kk = k;
  if (k > (n + 1) / 2) {
    k = k - (n + 1) / 2;
    k = n / 2 + 1 - k;
  }
  long long sum = 0;
  int lo, hi;
  lo = 1;
  hi = n;
  for (i = 1; i <= k; i++) {
    sum += pre[hi] - pre[lo - 1];
    lo++;
    hi--;
  }
  double ans = (sum * 1.0) / (n - kk + 1);
  printf("%.10f\n", ans);
}

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

public class B {

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

		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt(), k = sc.nextInt();
		long[] a = new long[n+1];
		for(int i = 1; i <= n; i++) a[i] = a[i-1] + sc.nextInt();
		long ans = 0;
		for(int i = k; i <= n; i++)
			ans += a[i] - a[i - k];
		out.println(1.0 * ans / (n - k + 1));
		out.flush();
		out.close();
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream System){	br = new BufferedReader(new InputStreamReader(System));	}
		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public String nextLine()throws IOException{return br.readLine();}
		public int nextInt() throws IOException {return Integer.parseInt(next());}
		public double nextDouble() throws IOException {return Double.parseDouble(next());}
		public char nextChar()throws IOException{return next().charAt(0);}
		public Long nextLong()throws IOException{return Long.parseLong(next());}
		public boolean ready() throws IOException{return br.ready();}
		public void waitForInput(){for(long i = 0; i < 3e9; i++);}
	}
}


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

public class A {
	FastScanner in;
	PrintWriter out;

	final long mod = (long) (1e9 + 7);

	void solve() {
		int n = in.nextInt(), k = in.nextInt();
		char[] c = in.next().toCharArray();
		long[] prev = new long[k];
		int[] last = new int[k];
		Arrays.fill(last, -1);
		long sum = 0;
		for (int i = 0; i < c.length; i++) {
			int id = c[i] - 'a';
			prev[id] = (1 + sum) % mod;
			last[id] = i;
			sum = 0;
			for (int j = 0; j < k; j++) {
				sum += prev[j];
			}
		}
		for (int i = c.length; i < c.length + n; i++) {
			int minId = 0;
			for (int j = 0; j < k; j++) {
				if (last[j] < last[minId]) {
					minId = j;
				}
			}
			prev[minId] = (1 + sum) % mod;
			last[minId] = i;
			sum = 0;
			for (int j = 0; j < k; j++) {
				sum += prev[j];
			}
		}
		out.println((1 + sum) % mod);
	}

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

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

		FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

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

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

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

#include <bits/stdc++.h>
using namespace std;
const int N = 100020;
const int mod = 1000000007;
int n;
int m;
int last[26];
int res[2000100];
int sum[2000100];
int k;
string s;
int main() {
  cin >> n >> k;
  cin >> s;
  n += (s.size());
  res[0] = 1;
  sum[1] = 1;
  for (int i = 1; i <= n; i++)
    if (i <= (s.size())) {
      res[i] = (sum[i] - sum[last[s[i - 1] - 'a']] + mod) % mod;
      sum[i + 1] = (sum[i] + res[i]) % mod;
      last[s[i - 1] - 'a'] = i;
    } else {
      int best = 0;
      for (int j = 0; j < k; j++)
        if (last[best] > last[j]) best = j;
      res[i] = (sum[i] - sum[last[best]] + mod) % mod;
      sum[i + 1] = (sum[i] + res[i]) % mod;
      last[best] = i;
    }
  printf("%d\n", sum[n + 1]);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long int d, l, v1, v2;
  float t;
  cin >> d >> l >> v1 >> v2;
  t = (l - d) / (v1 + v2);
  cout << fixed << setprecision(10) << (double)(l - d) / (v1 + v2);
  return 0;
}

import java.util.*;

public class Luke{

	public static double luke(double d, double l, double v){
		return (l-d)/v;
	}

	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		double d= in.nextDouble();
		double l= in.nextDouble();
		double v1= in.nextDouble();
		double v2= in.nextDouble();
		double v=v1+v2;

		System.out.println(luke(d,l,v));
	}
}


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

public class C {
	FastScanner in;
	PrintWriter out;

	public void solve() throws IOException {
		int n = in.nextInt(), m = in.nextInt();
		if (m == 1) {
			out.println(1);
			return;
		}
		int[] x = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			x[i] = in.nextInt();
			sum += x[i];
		}
		int maxCnt = n * m;
		double[][] p = new double[n + 1][maxCnt + 1];
		p[0][0] = 1;
		for (int i = 0; i < n; i++) {
			double cur = 0;
			for (int j = 1; j <= maxCnt; j++) {
				cur += p[i][j - 1];
				if (j > m) {
					cur -= p[i][j - m - 1];
				}
				if (j >= x[i]) {
					cur -= p[i][j - x[i]];
				}

				p[i + 1][j] += cur / (m - 1);

				if (j >= x[i]) {
					cur += p[i][j - x[i]];
				}
			}
		}
		double pp = 0;
		for (int i = 0; i < sum; i++) {
			pp += p[n][i];
		}
		out.println(pp * (m - 1) + 1);
	}

	public void run() {
		try {
			in = new FastScanner();
			out = new PrintWriter(System.out);

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

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

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				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());
		}
	}

	public static void main(String[] arg) {
		new C().run();
	}
}


import sys
readline = sys.stdin.readline

def main():
    N = int(input())
    itvs = []
    for _ in range(N):
        x, w = map(int, input().split())
        itvs.append((x - w, x + w))
    itvs.sort(key=lambda x: x[1])

    ans = 0
    end = -(10**9 + 1)
    for l, r in itvs:
        if end <= l:
            ans += 1
            end = r
    print(ans)

if __name__ == "__main__":
    main()

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long int t, i, j, k, n, m, a, b, c;
  cin >> n;
  set<pair<long long int, long long int> > arr;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    arr.insert(make_pair(a + b, a - b));
  }
  long long int prev = -50000000000ll;
  long long int ans = 0;
  for (__typeof((arr).begin()) X = (arr).begin(); X != (arr).end(); X++) {
    b = X->first;
    a = X->second;
    if (a >= prev) {
      prev = b;
      ans++;
    }
  }
  cout << ans << endl;
}


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

public class Main{
    static class Trial implements Comparable<Trial>{
        boolean[] t;
        int r;
        Trial(boolean[] t, int r){
            this.t = t;
            this.r = r;
        }
        public int compareTo(Trial b){
            return this.r-b.r;
        }
    }

    static Trial[] trial;
    static int n,m;
    static int cnt = 0;
    static int r;
    static int[] word;
    static void comb(int p1, int p2){
        if(p2==r){
            boolean[] temp = trial[0].t.clone();
            for(int i=0; i<temp.length; i++)
                temp[i] = !temp[i];
            for(int i=0; i<word.length; i++)
                temp[word[i]] = !temp[word[i]];
            // System.out.println(Arrays.toString(temp));
            int i;
            for(i=1; i<m; i++)
                if(!isValid(temp, trial[i].t, trial[i].r))
                    break;
            cnt = i==m?cnt+1:cnt;
            return;
        }
        for(int i=p1; i<=n-(r-p2); i++){
            word[p2] = i;
            comb(i+1, p2+1);
        }
    }

    static boolean isValid(boolean[] a, boolean[] b, int diff){
        int cnt = 0;
        for(int i=0; i<n; i++)
            if(a[i]==b[i])
                cnt++;
        return cnt==diff;
    }
    public static void main(String[] args)throws Throwable{
        Escanner sc = new Escanner();
        out = new PrintWriter(System.out);
        ///////////
        n = sc.nextInt();
        m = sc.nextInt();
        trial = new Trial[m];

        for(int i=0; i<m; i++){
            String s = sc.nextStr();
            boolean[] t = new boolean[n];
            for(int j=0; j<n; j++)
                t[j] = s.charAt(j)=='1';
            trial[i] = new Trial(t, sc.nextInt());
        }

        Arrays.sort(trial);
        r = trial[0].r;
        word = new int[r];
        comb(0,0);
        out.println(cnt);
        //////////
        out.close();
    }

    static class Escanner {
        BufferedReader in;
        StringTokenizer st;

        Escanner() throws Throwable {
            in = new BufferedReader(new InputStreamReader(System.in),32768);
            st = new StringTokenizer("");
        }

        String nextStr() throws Throwable {
            while(!st.hasMoreTokens())
                st = new StringTokenizer(in.readLine());
            return st.nextToken();
        }

        int nextInt() throws Throwable {
            return Integer.parseInt(nextStr());
        }

        long nextLong() throws Throwable {
            return Long.parseLong(nextStr());
        }

        BigInteger nextBigInt() throws Throwable {
            return new BigInteger(nextStr());
        }

        double nextDouble() throws Throwable {
            return Double.parseDouble(nextStr());
        }
    }
    static PrintWriter out;
}

#include <bits/stdc++.h>
using namespace std;
const int N = 50;
int x[N][N], y[N], True[N], False[N], ans;
int n, m;
bool flag = false;
void dfs(int pos) {
  if (pos > n) {
    ans++;
    return;
  }
  bool f = true;
  for (int i = 1; i <= m; i++) {
    if (!x[i][pos])
      True[i]++;
    else
      False[i]++;
    if (True[i] > y[i] || False[i] > n - y[i]) f = false;
  }
  if (f) dfs(pos + 1);
  f = true;
  for (int i = 1; i <= m; i++) {
    if (!x[i][pos])
      True[i]--, False[i]++;
    else
      False[i]--, True[i]++;
    if (True[i] > y[i] || False[i] > n - y[i]) f = false;
  }
  if (f) dfs(pos + 1);
  for (int i = 1; i <= m; i++) {
    if (!x[i][pos])
      False[i]--;
    else
      True[i]--;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) scanf("%1d", &x[i][j]);
    scanf("%d", &y[i]);
  }
  dfs(1);
  printf("%d", ans);
}


a = int(input())
s = input()
d = {}
for i in range(len(s)):
    for j in range(i, len(s)):
        if j == i: t = int(s[j])
        else: t += int(s[j])
        d[t] = d.get(t, 0) + 1
if a == 0:
    if 0 in d:
        cnt_pairs = (len(s) * (len(s) + 1)) // 2
        print((d[0] * cnt_pairs) + (d[0] * (cnt_pairs - d[0])))
    else:
        print(0)
else:
    c = 0
    for f in d:
        if f != 0  and a % f == 0 and (a//f) in d:
            c += d[f] * d[a//f]
    print(c)

#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int dp[40000];
std::map<long long, long long> freq;
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a;
  cin >> a;
  string second;
  cin >> second;
  for (int i = 0; i < second.length(); ++i) {
    dp[i + 1] = second[i] - '0';
    dp[i + 1] += dp[i];
  }
  for (int i = 1; i <= second.length(); ++i) {
    for (int j = i; j <= second.length(); ++j) {
      freq[dp[j] - dp[i - 1]]++;
    }
  }
  long long ans = 0;
  if (a == 0) {
    for (int i = 0; i <= 40000; ++i) {
      ans += freq[0] * 1LL * freq[i];
    }
  }
  for (int i = 1; i <= 40000; ++i) {
    if (a % i == 0) {
      ans += freq[i] * 1LL * freq[(int)a / i];
    }
  }
  cout << ans;
  return 0;
}


# METO Bot 0.9.9
n,m,k=map(int,input().split())
if k<m<=k+n:
	t=1
	for i in range(k+1):
		t*=(m-i)/(n+k-(i-1))
	print(1-t)
else:
	print(0 if m>n+k else 1)

#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const long long LLINF = 9223372036854775807LL;
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  double ans = 1;
  for (int i = 0; i <= k; ++i) ans *= (m - i + .0) / (n + i + 1.);
  ans = 1 - ans;
  ans = max(0., ans);
  printf("%.15lf\n", ans);
  return 0;
}


def maximum_wins(a1,a2,a3,rock,scissor,paper):
    ans=0
    mini1=min(a1,scissor)
    ans+=mini1
    scissor-=mini1
    mini2=min(a2,paper)
    ans+=mini2
    paper-=mini2
    mini3=min(a3,rock)
    rock-=mini3
    ans+=mini3
    return ans

def minimum_wins(rock,paper,scissor,a1,a2,a3):
    return max(0,a1-paper-rock)+max(0,a2-rock-scissor)+max(0,a3-paper-scissor)

n=int(input())
a1,a2,a3=map(int,input().split())
rock,scissor,paper=map(int,input().split())
print(minimum_wins(rock,paper,scissor,a1,a2,a3),maximum_wins(a1,a2,a3,rock,scissor,paper))
# print()

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

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

    static class Task1426e {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int a1 = in.nextInt();
            int a2 = in.nextInt();
            int a3 = in.nextInt();
            int b1 = in.nextInt();
            int b2 = in.nextInt();
            int b3 = in.nextInt();
            int max = Math.min(a1, b2) + Math.min(a2, b3) + Math.min(a3, b1);
            int min = Math.min(a1, b1 + b3) + Math.min(a2, b1 + b2) + Math.min(a3, b2 + b3);
            min = n - min;
            out.println(min + " " + max);

        }

    }
}


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

public class Main
{
	public static Scanner in;
	public static PrintStream out;

	public static void test()
	{
		String s = in.nextLine();
		long k = in.nextLong();
		int n = s.length();

		int cnt[] = new int[27];
		long substr_cnt[] = new long[27];
		int pos[][] = new int[27][];

		int[] c_pos = new int[n+1];
		int c_count = 0;

		int i,j;
		for (i=0; i<27; i++)
		{
			cnt[i] = 0;
			pos[i] = new int[n+1];
		}

		int c, h;
		for (i=0; i<n; i++)
		{
			c = s.charAt(i)-'a';
			pos[c][cnt[c]++] = i;
		}

		int p = 0;
		long sm;

		String pref = "";

		while (true)
		{
			sm = 0;
			for (i=0; i<26; i++)
			{
				substr_cnt[i] = 0;
				for (j=0; j<cnt[i]; j++)
				{
					substr_cnt[i] += (long)(n - pos[i][j] - p);
				}

				sm+= substr_cnt[i];

				if (sm > k)
				{
					break;
				}
			}

			i = 0;
			while ((i<26)&&(substr_cnt[i]<k))
			{
				k -= substr_cnt[i];
				i++;
			}

			if (i==26)
			{
				out.println("No such line.");
				return;
			}

			//pref =  pref + (char)(i+'a');
			p++;

			k-= cnt[i];

			if (k<=0)
			{
				out.println(s.substring(pos[i][0], pos[i][0]+p));
				return;
			}

			c = i;

			c_count = cnt[i];
			for (i=0;i<c_count;i++)
			{
				c_pos[i] = pos[c][i];
			}

			for (i=0; i<26;i++)
			{
				cnt[i] = 0;
			}

			for (j=0; j<c_count;j++)
			{
				if (c_pos[j]+p < n)
				{
					h = s.charAt(c_pos[j]+p) - 'a';
					pos[h][cnt[h]++] = c_pos[j];
				}
			}
		}
	}

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

			/*in = new Scanner(new File("in.txt"));
			out = new PrintStream(new File("out.txt"));*/

		}
		catch (Exception e)
		{
			return;
		}

		/*int t = in.nextInt();
		for (int i=0; i<t; i++)*/
		{
			test();
		}
	}
}

from heapq import *

l=input()

k=int(input())

n=len(l)

if k>n*(n+1)/2:

    print("No such line.")

    quit()

ss=[(l[i],i) for i in range(n)]

heapify(ss)

while k:

    k-=1

    t=heappop(ss)

    if k==0:

        print(t[0])

    else:

        if t[1]<n-1:

            heappush(ss,(t[0]+l[t[1]+1],t[1]+1))

# Made By Mostafa_Khaled


#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int value, count = 9;
  cin >> value;
  if (value < 10) {
    cout << 9;
    return 0;
  }
  count = count + 10 - (value % 10);
  value = value / 10;
  while (value >= 10) {
    count = count + 9 - (value % 10);
    value = value / 10;
  }
  cout << count;
  return 0;
}

def f(n):
    n = n + 1
    while n % 10 == 0:
        n = n // 10
    return n

n = int(input())
ctr = 0
nums = {}
while n not in nums:
    # print(n)
    nums[n] = True
    ctr += 1
    n = f(n)

print(ctr)


#include <bits/stdc++.h>
using namespace std;
int a[1100];
int main() {
  int n, m, h, sum, i, j;
  double ss;
  while (scanf("%d%d%d", &n, &m, &h) != EOF) {
    for (sum = 0, i = 1; i <= m; i++) {
      scanf("%d", &a[i]);
      sum += a[i];
    }
    if (sum < n) {
      printf("-1.0\n");
      continue;
    }
    ss = 1.0;
    j = a[h];
    if (n - 1 <= sum - j) {
      for (i = 0; i < n - 1; i++)
        ss *= (double)(sum - j - i) / (double)(sum - 1 - i);
    } else
      ss = 0;
    printf("%.10lf\n", 1.0 - ss);
  }
  return 0;
}

import java.util.Scanner;

public class D {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int h = in.nextInt() - 1;
        int[] D = new int[m];
        int sum = 0;
        for (int i = 0; i < m; i++) {
            D[i] = in.nextInt();
            if (i != h)
                sum += D[i];
        }
        if (sum + D[h] < n)
            System.out.println(-1);
        else {
            double prob = 1;
            D[h]--;
            for (int i = 1; i < n; i++) {
                prob *= (sum * 1.0) / (sum + D[h]);
                sum--;
            }
            System.out.println(1 - prob);
        }
    }
}


N, M, K, L = map(int, input().split())
if N < M or K + L > N:
    print(-1)
else:
    print((L + K - 1) // M + 1 if ((L + K - 1) // M + 1) * M <= N else -1)

//package ACM_code;

import java.util.Scanner;
public class Main{
    public static void main(String[] args){
    Scanner cin = new Scanner(System.in);
    long n = cin.nextLong();
    long m = cin.nextLong();
    long k = cin.nextLong();
    long l = cin.nextLong();
    long ans = (l+k)/m;
    if(ans*m<l+k) ans++;
    if(ans*m<=n||ans==0) System.out.println(ans);
    else System.out.println(-1);
    }
}


import java.io.*;
import java.util.*;
import java.util.function.IntConsumer;
import java.util.stream.Stream;

public class Solution {

    static MyScanner sc;
    private static PrintWriter out;
    static long M2 = 1_000_000_000L + 7;

    private static HashMap<Long, Long>[] mods;

    public static void main(String[] s) throws Exception {
        StringBuilder stringBuilder = new StringBuilder();
//        stringBuilder.append(" 10 1 1 ");
//        stringBuilder.append("7 3\n" +
//                "1 5 2 6 3 7 4\n" +
//                "2 5 3\n" +
//                "4 4 1\n" +
//                "1 7 3");

//
//        Random r = new Random(5);
//        stringBuilder.append("100000 5000 ");
//        for (int i = 0; i < 100000; i++) {
//            stringBuilder.append(" " + (r.nextInt(2000000000) - 1000000000) + " ");
//
//        }
//        for (int k = 0; k < 5000; k++) {
//            stringBuilder.append(" 1 100000 777 ");
//        }

        if (stringBuilder.length() == 0) {
            sc = new MyScanner(System.in);
        } else {
            sc = new MyScanner(new BufferedReader(new StringReader(stringBuilder.toString())));
        }

        out = new PrintWriter(new OutputStreamWriter(System.out));

        initData();
        solve();
        out.flush();
    }

    private static void initData() {

    }

    private static void solve() throws IOException {
        int s1 = sc.nextInt();
        int s2 = sc.nextInt();
        int s3 = sc.nextInt();
        int s4 = sc.nextInt();

        int l1 = s1 * 2;
        int l2 = s2 * 2;
        int l3 = Math.min(s3 * 2, s4 * 2);
        if (s4 * 2 >= l2 || s4 > l3 || s3 > l3) {
            out.println(-1);
            return;
        }
        out.println(l1);
        out.println(l2);
        out.println(l3);

    }

    private static final class AList {
        int[] data;
        int c = 0;

        public AList(int n) {
            this.data = new int[Math.max(Integer.highestOneBit(n - 1) << 1, 4)];
        }

        public AList() {
            this(4);
        }

        public AList(int[] data) {
            this(data.length);
            System.arraycopy(data, 0, this.data, 0, data.length);
        }

        public void sort() {
            if (c < 2) return;
            Arrays.sort(data, 0, c);
        }

        public void work(IntConsumer intConsumer) {
            for (int i = 0; i < c; i++) {
                intConsumer.accept(data[i]);
            }
        }

        public void add(int k) {
            if (c == data.length) {
                data = Arrays.copyOf(data, data.length << 1);
            }
            data[c++] = k;
        }

    }

    private static final class SparseMatrix {
        AList[] init;

        public SparseMatrix(int n) {
            init = new AList[n + 1];
            for (int i = 1; i <= n; i++) {
                init[i] = new AList();
            }
        }

        void sort() {
            for (AList l : init) {
                if (l != null)
                    l.sort();
            }
        }

        public void add(int row, int column) {
            while (row < init.length) {
                init[row].add(column);
                row += row & (-row);
            }
        }

        private long sum(int x, int y) {
            if (x >= init.length) x = init.length - 1;
            long sum = 0;
            while (x > 0) {
                sum += r(x, y);
                x -= x & (-x);
            }
            return sum;
        }

        private long r(int x, int y) {
            return biSearch(init[x].data, 0, init[x].c, y);
        }
    }

    static int biSearch(int[] k, int from, int to, int val) {
        int r = Arrays.binarySearch(k, from, to, val + 1);
        if (r < 0) r = -r - 1;
        return r;
    }

    private static boolean isset(long i, int k) {
        return (i & (1 << k)) > 0;
    }

    private static void solveT() throws IOException {
        int t = sc.nextInt();
        while (t-- > 0) {
            solve();
        }
    }

    private static long gcd(long l, long l1) {
        if (l > l1) return gcd(l1, l);
        if (l == 0) return l1;
        return gcd(l1 % l, l);
    }

    private static long pow(long a, long b, long m) {
        if (b == 0) return 1;
        if (b == 1) return a;
        long pp = pow(a, b / 2, m);
        pp *= pp;
        pp %= m;
        return (pp * (b % 2 == 0 ? 1 : a)) % m;
    }

    static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        MyScanner(BufferedReader br) {
            this.br = br;
        }

        public MyScanner(InputStream in) {
            this(new BufferedReader(new InputStreamReader(in)));
        }

        void findToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }

        String next() {
            findToken();
            return st.nextToken();
        }

        Integer[] nab(int n) {
            Integer[] k = new Integer[n];
            for (int i = 0; i < n; i++) {
                k[i] = sc.fi();
            }
            return k;
        }

        int[] na(int n) {
            int[] k = new int[n];
            for (int i = 0; i < n; i++) {
                k[i] = sc.fi();
            }
            return k;
        }

        long[] nl(int n) {
            long[] k = new long[n];
            for (int i = 0; i < n; i++) {
                k[i] = sc.nextLong();
            }
            return k;
        }

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

        int fi() {
            String t = next();
            int cur = 0;
            boolean n = t.charAt(0) == '-';
            for (int a = n ? 1 : 0; a < t.length(); a++) {
                cur = cur * 10 + t.charAt(a) - '0';
            }
            return n ? -cur : cur;
        }

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

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

}

sizes=[int(x) for x in str(input()).split(" ")]
l=(sizes[0],2*sizes[0])
m=(max(2*sizes[3]+1,sizes[1]),2*sizes[1])
s=(max(sizes[2],sizes[3]),min(2*sizes[2],2*sizes[3]))

if m[1]>=m[0] and s[1]>=s[0]:
    print(l[1])
    print(max(m[0],s[0])+1)
    print(s[0])
else:
    print(-1)


import java.util.*;
import java.io.*;
public class solution
{
	static int min(int a,int b)
	{
		if(a>b)
		{
			return b;
		}
		return a;
	}
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int l = 0;
		int r = 0;
		int u = 0;
		int d = 0;
		for(int i=0;i<s.length();i++)
		{
			char c = s.charAt(i);
			switch(c)
			{
				case 'L':
				l++;
				break;
				case 'R':
				r++;
				break;
				case 'U':
				u++;
				break;
				case 'D':
				d++;
				break;
			}
		}
		System.out.println(2*(min(u,d)+min(l,r)));
	}
}


l=['Aa','Ab','Ac','Ad','Ae','Af','Ag','Ah','Ai','Aj','Ak','Al','Am','An','Ao','Ap','Aq','Ar','As','At','Au','Av','Aw','Ax','Ay','Az','Aaa','Abb','Acc','Add','Aee','Aff','Agg','Ahh','Aii','Ajj','Akk','All','Amm','Ann','Aoo','App','Aqq','Arr','Ass','Att','Auu','Avv','Aww','Axx','Ayy']
n,k=map(int,input().split())
li=list(map(str,input().split()))
lc=l[:n]
for i in range(len(li)):
    if li[i]=="NO":
        lc[i+k-1]=lc[i]
for i in lc:
    print(i,end=" ")

19 3 NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO

23 3 NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO

20 3 NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO

30 3 NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO

18 3 NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO

12 3 NO NO NO NO NO NO NO NO NO NO NO NO

21 3 NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO

14 3 NO NO NO NO NO NO NO NO NO NO NO NO NO NO

26 3 NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO

17 3 NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO

25 3 NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO

28 3 NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO

31 3 NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO

24 3 NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO

15 3 NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO

50 4
YES YES YES YES YES NO YES YES YES YES NO NO YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES NO YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES

22 3 NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO

13 3 NO NO NO NO NO NO NO NO NO NO NO NO NO

50 3
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES NO

16 3 NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO

29 3 NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO

27 3 NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO

Aa Ba Ca Da Ea Fa Ga Ha Fa Ya Ab Bb Cb Ab Bb Fb Gb Hb Tb Yb Ac Bc Cc Dc Ec Fc Gc Hc Tc Yc Hc Bd Cd Dd Ed Fd Gd Hd Td Yd Ae Be Ce De Ee Fe Ge He Te Ye

Aa Ba Aa Ba Aa Ba Aa Ba Aa Ba Aa Ba Aa Ba Aa Ba Aa Ba Aa Ba Aa Ba Aa Ba Aa Ba Aa Ba Aa Ba Aa Ba Aa Ba Aa Ba Aa Ba Aa Ba Aa Ba Aa Ba Aa Ba Aa Ba Te Ba

Aa Ba Ca Da Ea Fa Ga Ha Ta Ya Ab Bb Cb Db Eb Fb Gb Hb Tb Yb Ac Bc Cc Dc Ec Fc Gc Hc Tc Yc Ad Bd Cd Dd Ed Fd Gd Hd Td Yd Ae Be Ce De Ee Fe Ge He Te Ye

import java.util.*;

public class Problem1 {

    LinkedList<String> li = new LinkedList<String>();

    String m[] = { "Aa","Ba","Ca","Da","Ea","Fa","Ga","Ha","Ta","Ya",
            "Ab","Bb","Cb","Db","Eb","Fb","Gb","Hb","Tb","Yb",
            "Ac","Bc","Cc","Dc","Ec","Fc","Gc","Hc","Tc","Yc",
            "Ad","Bd","Cd","Dd","Ed","Fd","Gd","Hd","Td","Yd",
            "Ae","Be","Ce","De","Ee","Fe","Ge","He","Te","Ye"};
    Scanner in;
    int t=0;
    int p=0;
    boolean[] flag;
    {
        flag = new boolean[55];
    }

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

    void run(){
        in =  new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        p=0;
        for (int i = 0; i < n-k+1; i++) {
            String s = in.next();
            if (s.equals("YES")) flag[i]=true; else flag[i]=false;
        }

        if (flag[0]==true){
            for (int j = 0; j < k; j++) {
               li.add(m[j]);
            }
        }
        if (flag[0]==false){

            for (int j = 0; j < k-1; j++) {
                li.add(m[j]);
            }
            li.add(m[0]);
            if (flag[1]==false) t++;
        }

        p=k;
         // p=0;
        while (p<n) {

            if (flag[p-k+1] == true){
                t=0;
                li.add(m[p]);
                p++;

            } else
            if (flag[p-k+1] == false){
                li.add(li.get(p-k+1));
                p++;
            }
        }

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

    }

}


#include <bits/stdc++.h>
using namespace std;
int main() {
  map<char, char> b;
  b['R'] = 'L';
  b['L'] = 'R';
  b['U'] = 'D';
  b['D'] = 'U';
  char s, p1, p2;
  int n, ans = 0;
  cin >> n;
  if (n == 1) {
    cout << 1;
    return 0;
  }
  int i = 0;
  set<char> a;
  while (i < n) {
    cin >> s;
    if (a.count(b[s]) == 0) {
      a.insert(s);
    } else {
      ans++;
      a.clear();
      a.insert(s);
    }
    i++;
  }
  cout << ans + 1;
  return 0;
}

n = int(input())
line = input()
moves = 'UDLR'
used = dict()
opp = dict()
opp['U'] = 'D'
opp['D'] = 'U'
opp['L'] = 'R'
opp['R'] = 'L'
for i in moves:
    used[i] = 0
i = len(line) - 1
ans = 0
while i >= 0:
    ans += 1
    for j in moves:
        used[j] = 0
    while i >= 0 and not used[opp[line[i]]]:
        used[line[i]] = 1
        i -= 1
print(ans)


import java.util.*;
import java.util.Map.Entry;
import java.util.regex.Pattern;
import java.lang.*;
import java.io.*;

public class sample2{
     static class FastReader  {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

    public static void main(String[] args)
    {
        FastReader sc = new FastReader();
        int n = sc.nextInt(), m = sc.nextInt();
        Set<Integer> set = new HashSet<>();
        for(int i = 0; i < n; i++) set.add(sc.nextInt());
        int sum = 0, cnt = 0;
        StringBuilder s = new StringBuilder();
        int index = 1;
        while(sum <= m){
            if(!set.contains(index)){
                sum += index;
                if(sum > m) break;
                cnt++;
                s.append(index + " ");
            }
            index++;
        }
        System.out.println(cnt);
        System.out.println(s);
    }
}

#include <bits/stdc++.h>
using namespace std;
bool sorty(const pair<string, long long int> &a,
           const pair<string, long long int> &b) {
  return a.second > b.second;
}
void initialize(bool flag[], long long int x) {
  for (long long int i = 0; i < x; i++) flag[i] = false;
}
long long int t, n, m;
long long int x, y;
long long int i, k;
string s1;
int main() {
  cin >> n >> m;
  set<long long int> s, ans;
  for (long long int i = 0; i < n; i++) {
    cin >> x, s.insert(x);
  }
  for (long long int j = 1; j <= m; j++) {
    if (!s.count(j)) {
      m -= j;
      ans.insert(j);
    }
  }
  cout << ans.size() << endl;
  for (auto p : ans) cout << p << " ";
  cout << endl;
  return 0;
}


def precalc(st, end):
    count = 0
    for i in range(st, end + 1):
        if not any(i % k == 0 for k in [2,3,5,7]):
            count += 1
    return count

n = int(input())

buckets = 2*3*4*5*6*7

c = int(n / buckets)

res = c * precalc(1, buckets) + precalc(c * buckets+1, n)

print(res)


#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool isLeap(T y) {
  return (y % 400 == 0) || (y % 100 ? y % 4 == 0 : false);
}
template <class T>
inline T gcd(T a, T b) {
  return (b) == 0 ? (a) : gcd((b), ((a) % (b)));
}
template <class T>
inline T lcm(T a, T b) {
  return ((a) / gcd((a), (b)) * (b));
}
template <class T>
inline T BigMod(T Base, T power, T M = 1000000007) {
  if (power == 0) return 1;
  if (power & 1)
    return ((Base % M) * (BigMod(Base, power - 1, M) % M)) % M;
  else {
    T y = BigMod(Base, power / 2, M) % M;
    return (y * y) % M;
  }
}
template <class T>
inline T ModInv(T A, T M = 1000000007) {
  return BigMod(A, M - 2, M);
}
int fx[] = {-1, +0, +1, +0, +1, +1, -1, -1, +0};
int fy[] = {+0, -1, +0, +1, +1, -1, +1, -1, +0};
int day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
  int n;
  scanf("%d", &n);
  if (n % 2 != 0) {
    printf("0\n");
  } else {
    n /= 2;
    printf("%d\n", (n - 1) / 2);
  }
  return 0;
}


//Author: net12k44
import java.io.*;
import java.util.*;
//public
class Main{//}

private void solve() {
    int result = 0, cur = 0;
    boolean[] inside = new boolean[(int)1e6];
    int n = in.nextInt();
    while (n-- > 0){
        String type = in.next(); int id = in.nextInt()-1;
        if (type.equals("+")){
            inside[id] = true;
            cur++;
            if (result < cur) result = cur;
        } else {
            if (inside[id]){
                inside[id] = false;
                cur--;
            } else {
                result++;
            }
        }
    }

    out.println(result);
}

public static void main (String[] args) throws java.lang.Exception {
    long startTime = System.currentTimeMillis();

    out = new PrintWriter(System.out);
    new Main().solve();
    //out.println((String.format("%.2f",(double)(System.currentTimeMillis()-startTime)/1000)));
    out.close();
}
static PrintWriter out;
static void println(int[] a){
    for(int i = 0; i < a.length; ++i){
        if (i != 0) out.print(' ');
        out.print(a[i]);
    }
    out.println();
}
static class in {
    static BufferedReader reader = new BufferedReader( new InputStreamReader(System.in) ) ;
    static StringTokenizer tokenizer = new StringTokenizer("");
    static String next() {
        while ( !tokenizer.hasMoreTokens() )
            try { tokenizer = new StringTokenizer( reader.readLine() ); }
            catch (IOException e){
                throw new RuntimeException(e);
            }
        return tokenizer.nextToken();
    }
    static int nextInt() { return Integer.parseInt( next() ); }
}
//////////////////////////////////////////////////
}//

'''input
2
+ 1
- 1
'''
m, p = 0, []
for _ in range(int(input())):
	i = input().split()
	if i[0] == "+":
		p.append(i[1])
	else:
		if i[1] in p:
			p.remove(i[1])
		else:
			m += 1
	m = max(m, len(p))
print(m)


#include <bits/stdc++.h>
using namespace std;
const int MAXC = 60;
int R, C;
int sum[MAXC][MAXC];
int getSum(int x1, int y1, int x2, int y2) {
  return sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1];
}
int test(int a, int b) {
  int ans = R * C;
  for (int i = (int)(1); i <= (int)(R); ++i)
    for (int j = (int)(1); j <= (int)(C); ++j)
      if (i + a - 1 <= R && j + b - 1 <= C)
        ans = min(ans, getSum(i, j, i + a - 1, j + b - 1));
  return ans;
}
int main() {
  cin >> R >> C;
  for (int i = (int)(1); i <= (int)(R); ++i)
    for (int j = (int)(1); j <= (int)(C); ++j) {
      int x;
      cin >> x;
      sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + x;
    }
  int a, b;
  cin >> a >> b;
  cout << min(test(a, b), test(b, a)) << endl;
  return 0;
}

n, m = map(int, input().split())
t = [[0] * (m + 1)] + [[] for i in range(n)]
t[1] = [0] + list(map(int, input().split()))
for j in range(2, m + 1): t[1][j] += t[1][j - 1]
for i in range(2, n + 1):
    t[i] = [0] + list(map(int, input().split()))
    for j in range(2, m + 1): t[i][j] += t[i][j - 1]
    for j in range(1, m + 1): t[i][j] += t[i - 1][j]
a, b = map(int, input().split())
if a <= n and b <= m:
    p = min(t[i + a][j + b] + t[i][j] - t[i + a][j] - t[i][j + b] for i in range(n - a + 1) for j in range(m - b + 1))
a, b = b, a
if a <= n and b <= m:
    q = min(t[i + a][j + b] + t[i][j] - t[i + a][j] - t[i][j + b] for i in range(n - a + 1) for j in range(m - b + 1))
    if b <= n and a <= m: p = min(p, q)
    else: p = q
print(p)


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

public class p417e
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x[] = solve(n);
        int y[] = solve(m);
        for (int i=0;i<n;i++)
        {
            for (int j=0;j<m;j++)
            {
                System.out.print(x[i]*y[j]+" ");
            }
            System.out.println();
        }
    }

    public static int[] solve(int n)
    {
        if(n==1) return new int[]{1};
        if(n==2) return new int[]{3,4};
        int[] a = new int[n];
        Arrays.fill(a,1);
        if(n%2==1)
        {
            a[0] = 2;
            a[n-1] = (n+1)/2;
        }
        else a[n-1] = (n-2)/2;
        return a;
    }
}


q = 10001
n, a = int(input()), list(map(int, input().split()))
a.sort()
for i in range(40000 // (n - 1) + 1):
    b = [a[j] - j * i for j in range(n)]
    u, v = max(b), min(b)
    p = (u - v + 1) // 2
    if p < q: q, s, d = p, v + p, i
print(q)
print(s, d)

import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class D {

	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);

    static void exit() {
    	sc.close();
    	out.close();
    	System.exit(0);
    }
    static int gcd(int a, int b) {
    	return b == 0 ? a : gcd(b, a%b);
    }
    public static void main(String[] args) {
    	int n = sc.nextInt();
    	int arr [] = new int [n];
    	for(int i = 0; i < n; i++) arr[i] = sc.nextInt();
    	Arrays.sort(arr);
    	int min_bun = Integer.MAX_VALUE;
    	int gmin=0, gmax=0, gstep = 0;
    	for(int step = 0; step <= arr[n-1]-arr[0]; step++) {
    		int min = 0;
        	int max = 0;
    		for(int i = 1; i < n; i++) {
    			min = Math.min(min, arr[0]+i*step-arr[i]);
    			max = Math.max(max, arr[0]+i*step-arr[i]);
    		}
    		int bun = (int) Math.ceil((max-min)/2.0);
    		//System.err.println(step + " " + min+" "+max + " " + bun);
    		if(min_bun > bun) {
    			min_bun = bun;
    			gmin = min;
    			gmax = max;
    			gstep = step;
    		}
    	}

    	out.println(min_bun);
    	out.println(arr[0] + (-min_bun-gmin) + " " + gstep);
        exit();
    }

}