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

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

    static class TaskC {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt(), r = in.nextInt();
            int[] f = new int[n], s = new int[n];
            double[] p = new double[n];
            int[] g = new int[n];
            int sum = 0;
            int sf = 0;
            for (int i = 0; i < n; i++) {
                f[i] = in.nextInt();
                s[i] = in.nextInt();
                p[i] = in.nextInt() / 100.0;
                g[i] = s[i] - f[i];
                sum += s[i];
                sf += f[i];
            }
            int needg = (sum - r);
            double lo = sf, hi = 1L << 50;
            for (int iter = 0; iter < 80; iter++) {
                double mid = (lo + hi) / 2.0;
                double[][] dp = new double[n + 1][needg + 1];
                for (int i = 0; i < needg; i++) {
                    dp[n][i] = mid;
                }
                dp[n][needg] = 0;
                for (int i = n - 1; i >= 0; i--) {
                    for (int have = 0; have <= needg; have++) {
                        // restart, try level
                        int nhave = Math.min(needg, have + g[i]);
                        dp[i][have] = Math.min(mid, (dp[i + 1][nhave] + f[i]) * p[i] + (1 - p[i]) * (dp[i + 1][have] + s[i]));
                    }
                }

                if (dp[0][0] < mid) {
                    hi = mid;
                } else {
                    lo = mid;
                }
            }
            out.printf("%.10f\n", (lo + hi) / 2.0);
        }

    }

    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 printf(String format, Object... objects) {
            writer.printf(format, objects);
        }

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

    }

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

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

        public int read() {
            if (this.numChars == -1) {
                throw new InputMismatchException();
            } else {
                if (this.curChar >= this.numChars) {
                    this.curChar = 0;

                    try {
                        this.numChars = this.stream.read(this.buf);
                    } catch (IOException var2) {
                        throw new InputMismatchException();
                    }

                    if (this.numChars <= 0) {
                        return -1;
                    }
                }

                return this.buf[this.curChar++];
            }
        }

        public int nextInt() {
            int c;
            for (c = this.read(); isSpaceChar(c); c = this.read()) {
                ;
            }

            byte sgn = 1;
            if (c == 45) {
                sgn = -1;
                c = this.read();
            }

            int res = 0;

            while (c >= 48 && c <= 57) {
                res *= 10;
                res += c - 48;
                c = this.read();
                if (isSpaceChar(c)) {
                    return res * sgn;
                }
            }

            throw new InputMismatchException();
        }

        public static boolean isSpaceChar(int c) {
            return c == 32 || c == 10 || c == 13 || c == 9 || c == -1;
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
import java.io.IOException;
import java.util.Random;
import java.io.UncheckedIOException;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastInput in = new FastInput(inputStream);
            FastOutput out = new FastOutput(outputStream);
            CPrairiePartition solver = new CPrairiePartition();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class CPrairiePartition {
        public void solve(int testNumber, FastInput in, FastOutput out) {
            int n = in.readInt();
            long[] a = new long[n];
            int[] cnts = new int[50];
            LongList special = new LongList(n);

            in.populate(a);
            for (long x : a) {
                if (Long.lowestOneBit(x) == x) {
                    cnts[Log2.floorLog(x)]++;
                } else {
                    special.add(x);
                }
            }
            special.sort();

            IntBinarySearch ibs = new IntBinarySearch() {

                public boolean check(int mid) {
                    int one = cnts[0] - mid;
                    int specialIndex = 0;

                    int flow = mid;
                    int taged = 0;
                    for (int i = 1; i < cnts.length; i++) {
                        int c = cnts[i];
                        if (c <= flow) {
                            int kickOut = flow - c;
                            int kickTaged = Math.min(taged, kickOut);
                            taged -= kickTaged;
                            int kickUnTaged = kickOut - kickTaged;
                            flow -= kickOut;

                            while (kickUnTaged > 0 && specialIndex < special.size() &&
                                    special.get(specialIndex) <= (1L << i)) {
                                kickUnTaged--;
                                specialIndex++;
                            }
                            while (kickUnTaged > 0 && one > 0) {
                                kickUnTaged--;
                                one--;
                            }
                        } else {
                            c -= flow;
                            taged += c;
                        }
                    }

                    int kickOut = flow - taged;
                    return kickOut >= special.size() - specialIndex + one;
                }
            };

            int ans = ibs.binarySearch(0, cnts[0]);
            if (!ibs.check(ans)) {
                out.println(-1);
                return;
            }

            for (int i = ans; i <= cnts[0]; i++) {
                out.append(i).append(' ');
            }
        }

    }

    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private StringBuilder cache = new StringBuilder(10 << 20);
        private final Writer os;

        public FastOutput append(CharSequence csq) {
            cache.append(csq);
            return this;
        }

        public FastOutput append(CharSequence csq, int start, int end) {
            cache.append(csq, start, end);
            return this;
        }

        public FastOutput(Writer os) {
            this.os = os;
        }

        public FastOutput(OutputStream os) {
            this(new OutputStreamWriter(os));
        }

        public FastOutput append(char c) {
            cache.append(c);
            return this;
        }

        public FastOutput append(int c) {
            cache.append(c);
            return this;
        }

        public FastOutput println(int c) {
            return append(c).println();
        }

        public FastOutput println() {
            cache.append(System.lineSeparator());
            return this;
        }

        public FastOutput flush() {
            try {
                os.append(cache);
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return this;
        }

        public void close() {
            flush();
            try {
                os.close();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        public String toString() {
            return cache.toString();
        }

    }

    static class SequenceUtils {
        public static boolean equal(long[] a, int al, int ar, long[] b, int bl, int br) {
            if ((ar - al) != (br - bl)) {
                return false;
            }
            for (int i = al, j = bl; i <= ar; i++, j++) {
                if (a[i] != b[j]) {
                    return false;
                }
            }
            return true;
        }

    }

    static class LongList implements Cloneable {
        private int size;
        private int cap;
        private long[] data;
        private static final long[] EMPTY = new long[0];

        public LongList(int cap) {
            this.cap = cap;
            if (cap == 0) {
                data = EMPTY;
            } else {
                data = new long[cap];
            }
        }

        public LongList(LongList list) {
            this.size = list.size;
            this.cap = list.cap;
            this.data = Arrays.copyOf(list.data, size);
        }

        public LongList() {
            this(0);
        }

        public void ensureSpace(int req) {
            if (req > cap) {
                while (cap < req) {
                    cap = Math.max(cap + 10, 2 * cap);
                }
                data = Arrays.copyOf(data, cap);
            }
        }

        private void checkRange(int i) {
            if (i < 0 || i >= size) {
                throw new ArrayIndexOutOfBoundsException();
            }
        }

        public long get(int i) {
            checkRange(i);
            return data[i];
        }

        public void add(long x) {
            ensureSpace(size + 1);
            data[size++] = x;
        }

        public void addAll(long[] x, int offset, int len) {
            ensureSpace(size + len);
            System.arraycopy(x, offset, data, size, len);
            size += len;
        }

        public void addAll(LongList list) {
            addAll(list.data, 0, list.size);
        }

        public void sort() {
            if (size <= 1) {
                return;
            }
            Randomized.shuffle(data, 0, size);
            Arrays.sort(data, 0, size);
        }

        public int size() {
            return size;
        }

        public long[] toArray() {
            return Arrays.copyOf(data, size);
        }

        public String toString() {
            return Arrays.toString(toArray());
        }

        public boolean equals(Object obj) {
            if (!(obj instanceof LongList)) {
                return false;
            }
            LongList other = (LongList) obj;
            return SequenceUtils.equal(data, 0, size - 1, other.data, 0, other.size - 1);
        }

        public int hashCode() {
            int h = 1;
            for (int i = 0; i < size; i++) {
                h = h * 31 + Long.hashCode(data[i]);
            }
            return h;
        }

        public LongList clone() {
            LongList ans = new LongList();
            ans.addAll(this);
            return ans;
        }

    }

    static class RandomWrapper {
        private Random random;
        public static RandomWrapper INSTANCE = new RandomWrapper(new Random());

        public RandomWrapper() {
            this(new Random());
        }

        public RandomWrapper(Random random) {
            this.random = random;
        }

        public int nextInt(int l, int r) {
            return random.nextInt(r - l + 1) + l;
        }

    }

    static abstract class IntBinarySearch {
        public abstract boolean check(int mid);

        public int binarySearch(int l, int r) {
            if (l > r) {
                throw new IllegalArgumentException();
            }
            while (l < r) {
                int mid = DigitUtils.floorAverage(l, r);
                if (check(mid)) {
                    r = mid;
                } else {
                    l = mid + 1;
                }
            }
            return l;
        }

    }

    static class FastInput {
        private final InputStream is;
        private byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastInput(InputStream is) {
            this.is = is;
        }

        public void populate(long[] data) {
            for (int i = 0; i < data.length; i++) {
                data[i] = readLong();
            }
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    bufLen = -1;
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

        public long readLong() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            long val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

    }

    static class DigitUtils {
        private DigitUtils() {
        }

        public static int floorAverage(int x, int y) {
            return (x & y) + ((x ^ y) >> 1);
        }

    }

    static class Randomized {
        public static void shuffle(long[] data, int from, int to) {
            to--;
            for (int i = from; i <= to; i++) {
                int s = nextInt(i, to);
                long tmp = data[i];
                data[i] = data[s];
                data[s] = tmp;
            }
        }

        public static int nextInt(int l, int r) {
            return RandomWrapper.INSTANCE.nextInt(l, r);
        }

    }

    static class Log2 {
        public static int floorLog(long x) {
            return 63 - Long.numberOfLeadingZeros(x);
        }

    }
}


//package arbuz;

import java.util.Scanner;

public class Arbuz {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] first = new int[n];
        int[] second = new int[n];
        int i;
        String s = sc.next();
        for (i = 0; i < n; i++) {
            first[i] = (byte) s.charAt(i) - 48;
            second[i] = (byte) s.charAt(n + i) - 48;
        }
        i = 0;
        while (i < n - 1) {
            if (first[i] > first[i + 1]) {
                int temp = first[i];
                first[i] = first[i + 1];
                first[i + 1] = temp;
                i = -1;
            }
            i++;
        }
        i = 0;
        while (i < n - 1) {
            if (second[i] > second[i + 1]) {
                int temp = second[i];
                second[i] = second[i + 1];
                second[i + 1] = temp;
                i = -1;
            }
            i++;
        }
        boolean less = false, bigger = false, equal = false, match = true;
        for (i = 0; i < n; i++) {
            if (first[i] == second[i]) {
                equal = true;
            }
            if (first[i] < second[i]) {
                less = true;
            }
            if (first[i] > second[i]) {
                bigger = true;
            }
            if ((less && bigger) || equal) {
                match = false;
                break;
            }
        }
        if (match) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


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

public class D {

	static final int INF = Integer.MAX_VALUE / 10;
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	int[] v1, v2;
	int[][] g;
	int[][] d;

	int n, m;

	int[] deg;

	double[] ps;
	int[] psList;
	int psPtr = 0;

	double[] maxP;
	int[] maxPList;
	int maxPPtr = 0;

	double go2(Integer[] vs, int from, int to) {
		double stupid = 1.0 / (to - from);

		double smart = 0;

		for (int i = from; i < to; i++) {

			int v = vs[i];

			for (int j = 0; j < deg[v]; j++) {
				int u = g[v][j];
				if (ps[u] < 0) {
					ps[u] = 0;
					psList[psPtr++] = u;
				}
				ps[u] += stupid / deg[v];
			}

		}

		for (int v2 = 0; v2 < n; v2++) {
			for (int i = 0; i < psPtr; i++) {
				int u = psList[i];
				int dst = d[v2][u];
				if (maxP[dst] < 0) {
					maxP[dst] = 0;
					maxPList[maxPPtr++] = dst;
				}
				maxP[dst] = Math.max(maxP[dst], ps[u]);
			}
			double here = 0;
			for (int i = 0; i < maxPPtr; i++) {
				here += maxP[maxPList[i]];
			}
			smart = Math.max(smart, here);

			while (maxPPtr > 0) {
				int v = maxPList[--maxPPtr];
				maxP[v] = -1;
			}
		}

		while (psPtr > 0) {
			int v = psList[--psPtr];
			ps[v] = -1;
		}

//		System.err.println(from + " " + to + " -> " + smart + " " + stupid);

		return Math.max(smart, stupid);

	}

	double go(int v) {
		final int[] dist = d[v];
		Integer[] a = new Integer[n];
		for (int i = 0; i < n; i++) {
			a[i] = i;
		}
		Arrays.sort(a, new Comparator<Integer>() {

			@Override
			public int compare(Integer o1, Integer o2) {
				return Integer.compare(dist[o1], dist[o2]);
			}

		});

		double ret = 0;

		for (int i = 0; i < n;) {
			int j = i;
			while (j < n && dist[a[i]] == dist[a[j]]) {
				j++;
			}

			ret += 1.0 * (j - i) / n * go2(a, i, j);
			i = j;
		}

		return ret;
	}

	void solve() throws IOException {
		n = nextInt();
		m = nextInt();

		v1 = new int[m];
		v2 = new int[m];
		deg = new int[n];

		d = new int[n][n];
		for (int i = 0; i < n; i++) {
			Arrays.fill(d[i], INF);
			d[i][i] = 0;
		}

		for (int i = 0; i < m; i++) {
			v1[i] = nextInt() - 1;
			v2[i] = nextInt() - 1;
			d[v1[i]][v2[i]] = d[v2[i]][v1[i]] = 1;
			deg[v1[i]]++;
			deg[v2[i]]++;
		}

		g = new int[n][];
		for (int i = 0; i < n; i++) {
			g[i] = new int[deg[i]];
		}

		int[] ptrDeg = deg.clone();

		for (int i = 0; i < m; i++) {
			int v = v1[i];
			int u = v2[i];
			g[v][--ptrDeg[v]] = u;
			g[u][--ptrDeg[u]] = v;
		}

		for (int k = 0; k < n; k++)
			for (int i = 0; i < n; i++)
				for (int j = 0; j < n; j++) {
					d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j]);
				}

		ps = new double[n];
		Arrays.fill(ps, -1);
		psList = new int[n];

		maxP = new double[n];
		Arrays.fill(maxP, -1);
		maxPList = new int[n];

		double ans = 0;
		for (int i = 0; i < n; i++) { // !!!
			ans = Math.max(ans, go(i));
		}

		out.println(ans);

	}

	D() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

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

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

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

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

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


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

    private static class Node {
        int HH;
        int MM;

        public Node(int h, int m) {
            this.HH = h;
            this.MM = m;
        }

        public static Node getNode(String s) {
            String[] w = s.split(":");
            int h = Integer.valueOf(w[0]);
            int m = Integer.valueOf(w[1]);

            return new Node(h, m);
        }

        private static int distanceInMinutes(Node s, Node e) {
            int d = getTotalMinutes(e) - getTotalMinutes(s);
            return d;
        }

        private static int getTotalMinutes(Node n) {

            return (n.HH * 60) + n.MM;
        }

        private static void addMinutes(Node n, int m) {

            n.MM += m;
            while (n.MM > 59) {
                n.MM = n.MM - 60;
                n.HH += 1;
            }
        }

        public static void output(Node sNode, Node eNode) {

            int d = Node.distanceInMinutes(sNode, eNode);

            Node.addMinutes(sNode, d / 2);

            String ms = String.valueOf(sNode.MM);
            if (sNode.MM < 10) {
                ms = String.valueOf("0" + sNode.MM);
            }

            String hs = String.valueOf(sNode.HH);
            if (sNode.HH < 10) {
                hs = String.valueOf("0" + sNode.HH);
            }
            System.out.println(hs + ":" + ms);
        }

        @Override
        public String toString() {
            return "Node{" +
                    "HH=" + HH +
                    ", MM=" + MM +
                    '}';
        }
    }

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

        String s = I.nextLine();
        String e = I.nextLine();

        Node sNode = Node.getNode(s);
        Node eNode = Node.getNode(e);

        Node.output(sNode, eNode);

    }

}


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

public class Main {

	static AReader scan = new AReader();
	static StringBuffer sb = new StringBuffer();
	static int N = 200010;
	static int MOD = (int)1e9+7;
	static long[] f = new long[N];
	static long[] g = new long[N];

	static void init(){
		f[0] = g[0] = 1;
		for(int i = 1;i<N;i++){
			f[i] = f[i-1] * i % MOD;
			g[i] = g[i-1] * qmi(i,MOD-2) % MOD;
		}
	}

	static long qmi(long a,int b){
		long res = 1;
		while(b>0){
			if((b & 1) == 1){
				res = res * a % MOD;
			}
			a = a * a % MOD;
			b >>=1;
		}
		return res % MOD;
	}

	static long C(int a,int b){
		return f[a] * g[b] % MOD * g[a-b] % MOD;
	}
	static void solve() {
		int n = scan.nextInt();
		int k = scan.nextInt();
		if(k == 0){
			System.out.println(1);
			return;
		}
		if(n % 2 == 1){
			long res = 0;
			// 枚举选几个1
			long t = 0;
			for(int i = 0;i<=n;i+=2){
				t = (t + C(n,i)) % MOD;
			}
			res = qmi(t + 1,k);
			System.out.println(res);
		}else{
			// 偶数情况
			long res = 0;

			long t = 0;
			// 每一位必须选偶数个1
			for(int i = 0;i<n;i+=2){
				t = (t + C(n,i)) % MOD;
			}

			// 左大于右 第i位左式为1 右式为0 前i位都是1 后面随便选
			for(int i = 1;i<=k;i++){
				res += qmi(t,i-1) * qmi(qmi(2,n),k-i) % MOD;
				res %=MOD;
			}

			res = (res + qmi(t,k)) % MOD;

			//res %= MOD;
			System.out.println(res);
		}

	}

	public static void main(String[] args)  {
		init();
		int T = scan.nextInt();
		while (T-- > 0) {
		solve();
		}
		//System.out.print(sb.toString());
	}
}

class AReader {
	private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	private StringTokenizer tokenizer = new StringTokenizer("");

	private String innerNextLine() {
		try {
			return reader.readLine();
		} catch (IOException ex) {
			return null;
		}
	}

	public boolean hasNext() {
		while (!tokenizer.hasMoreTokens()) {
			String nextLine = innerNextLine();
			if (nextLine == null) {
				return false;
			}
			tokenizer = new StringTokenizer(nextLine);
		}
		return true;
	}

	public String nextLine() {
		tokenizer = new StringTokenizer("");
		return innerNextLine();
	}

	public String next() {
		hasNext();
		return tokenizer.nextToken();
	}

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

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

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

class Pair {
	int x,y;

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


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

public class Main {

	static InputReader in = new InputReader(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	static int oo = (int)1e9;
//	static long oo = (long)1e15;
	static int mod = 1_000_000_007;

	static int[] dx = {1, 0, -1, 0};
	static int[] dy = {0, -1, 0, 1};

	static int M = 5001;
	static double EPS = 1e-13;
	static int num = 1;

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

		long n = in.nextLong();
		long m = in.nextLong();
		int k = in.nextInt();
		if(k == -1 && n % 2 != m % 2) {
			System.out.println(0);
		}
		else {
			long x = pow(2, m-1, mod);
			long y = pow(x, n-1, mod);
			System.out.println(y);
		}

		out.close();
	}

	static int find(int[] g, int x) {
		return g[x] = g[x] == x ? x : find(g, g[x]);
	}

	static void union(int[] g, int[] size, int x, int y) {
		x = find(g, x); y = find(g, y);
		if(x == y)
			return;
		if(size[x] < size[y]) {
			g[x] = y;
			size[y] += size[x];
		}
		else {
			g[y] = x;
			size[x] += size[y];
		}
	}

	static class Segment {
		Segment left, right;
		int size, minIdx;
//		int time, lazy;

		public Segment(int[] a, int l, int r) {
			super();
			if(l == r) {
				this.minIdx = l;
				this.size = 1;
				return;
			}
			int mid = (l + r) / 2;
			left = new Segment(a, l, mid);
			right = new Segment(a, mid+1, r);
			if(a[left.minIdx] <= a[right.minIdx])
				this.minIdx = left.minIdx;
			else
				this.minIdx = right.minIdx;
			this.size = left.size + right.size;
		}

		boolean covered(int ll, int rr, int l, int r) {
			return ll <= l && rr >= r;
		}

		boolean noIntersection(int ll, int rr, int l, int r) {
			return ll > r || rr < l;
		}

//		void lazyPropagation() {
//			if(lazy != 0) {
//				if(left != null) {
//					left.setLazy(this.time, this.lazy);
//					right.setLazy(this.time, this.lazy);
//				}
//				else {
//					val = lazy;
//				}
//			}
//		}

//		void setLazy(int time, int lazy) {
//			if(this.time != 0 && this.time <= time)
//				return;
//			this.time = time;
//			this.lazy = lazy;
//		}

		int querySize(int ll, int rr, int l, int r) {
//			lazyPropagation();
			if(noIntersection(ll, rr, l, r))
				return 0;
			if(covered(ll, rr, l, r))
				return size;
			int mid = (l + r) / 2;
			int leftSize = left.querySize(ll, rr, l, mid);
			int rightSize = right.querySize(ll, rr, mid+1, r);
			return leftSize + rightSize;
		}

		int query(int k, int l, int r) {
			Segment trace = this;
			while(l < r) {
				int mid = (l + r) / 2;
				if(trace.left.size > k) {
					trace = trace.left;
					r = mid;
				}
				else {
					k -= trace.left.size;
					trace = trace.right;
					l = mid + 1;
				}
			}
			return l;
		}

		void update(int ll, int rr, int l, int r) {
//			lazyPropagation();
			if(noIntersection(ll, rr, l, r))
				return;
			if(covered(ll, rr, l, r)) {
//				setLazy(time, knight);
				this.minIdx = -1;
				this.size = 0;
				return;
			}
			int mid = (l + r) / 2;
			left.update(ll, rr, l, mid);
			right.update(ll, rr, mid+1, r);
			this.size = left.size + right.size;
		}
	}

	static long pow(long a, long n, long mod) {
		if(n == 0)
			return 1;
		if(n % 2 == 1)
			return a * pow(a, n-1, mod) % mod;
		long x = pow(a, n / 2, mod);
		return x * x % mod;
	}

	static int[] getPi(char[] a) {
		int m = a.length;
		int j = 0;
		int[] pi = new int[m];
		for(int i = 1; i < m; ++i) {
			while(j > 0 && a[i] != a[j])
				j = pi[j-1];
			if(a[i] == a[j]) {
				pi[i] = j + 1;
				j++;
			}
		}
		return pi;
	}

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

	static BigInteger lcm2(long a, long b) {
		long g = gcd(a, b);
		BigInteger gg = BigInteger.valueOf(g);
		BigInteger aa = BigInteger.valueOf(a);
		BigInteger bb = BigInteger.valueOf(b);
		return aa.multiply(bb).divide(gg);
	}

	static boolean nextPermutation(int[] a) {
		for(int i = a.length - 2; i >= 0; --i) {
			if(a[i] < a[i+1]) {
				for(int j = a.length - 1; ; --j) {
					if(a[i] < a[j]) {
						int t = a[i];
						a[i] = a[j];
						a[j] = t;
						for(i++, j = a.length - 1; i < j; ++i, --j) {
							t = a[i];
							a[i] = a[j];
							a[j] = t;
						}
						return true;
					}
				}
			}
		}
		return false;
	}

	static void shuffle(Object[] a) {
		Random r = new Random();
		for(int i = a.length - 1; i > 0; --i) {
			int si = r.nextInt(i);
			Object t = a[si];
			a[si] = a[i];
			a[i] = t;
		}
	}

	static void shuffle(int[] a) {
		Random r = new Random();
		for(int i = a.length - 1; i > 0; --i) {
			int si = r.nextInt(i);
			int t = a[si];
			a[si] = a[i];
			a[i] = t;
		}
	}

	static void shuffle(long[] a) {
		Random r = new Random();
		for(int i = a.length - 1; i > 0; --i) {
			int si = r.nextInt(i);
			long t = a[si];
			a[si] = a[i];
			a[i] = t;
		}
	}

	static int lower_bound(int[] a, int n, int k) {
		int s = 0;
		int e = n;
		int m;
		while (e - s > 0) {
			m = (s + e) / 2;
			if (a[m] < k)
				s = m + 1;
			else
				e = m;
		}
		return e;
	}
	static int lower_bound(long[] a, int n, long k) {
		int s = 0;
		int e = n;
		int m;
		while (e - s > 0) {
			m = (s + e) / 2;
			if (a[m] < k)
				s = m + 1;
			else
				e = m;
		}
		return e;
	}

	static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}
	static long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}
	static BigInteger gcd(BigInteger a, BigInteger b) {
		return b.compareTo(BigInteger.ZERO) == 0 ? a : gcd(b, a.mod(b));
	}

	static class Pair implements Comparable<Pair> {
		int first, second;

		public Pair(int first, int second) {
			super();
			this.first = first;
			this.second = second;
		}

		@Override
		public int compareTo(Pair o) {
			return this.first != o.first ? this.first - o.first : this.second - o.second;
		}

//		@Override
//		public int compareTo(Pair o) {
//			return this.first != o.first ? o.first - this.first : o.second - this.second;
//		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + first;
			result = prime * result + second;
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Pair other = (Pair) obj;
			if (first != other.first)
				return false;
			if (second != other.second)
				return false;
			return true;
		}
	}
}

class InputReader {

	private final InputStream stream;
	private final byte[] buf = new byte[8192];
	private int curChar, snumChars;

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

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

	public int nextInt() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public long nextLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

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

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

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

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

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

}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.InputMismatchException;

//abzzzzzzzzabcdzzzzzzzcd
//abcd
public class D {
	private static int n, m;
	private static int[] a;
	private static String s, t;
	private static HashMap<Integer, ArrayList<Integer>> g;
	private static long pp, qq, rr;

	public static void main(String[] args) {
		s = ins();
		t = ins();
		n = s.length();
		m = t.length();
		int[][] mapRight = new int[n][26];
		for(int i=n-1; i>=0; i--) {
			for(int j=0; j<26; j++) {
				mapRight[i][j] = (i+1<n?mapRight[i+1][j]:-1);
			}
			mapRight[i][s.charAt(i)-'a'] = i;
		}
		int[][] mapLeft = new int[n][26];
		for(int i=0; i<n; i++) {
			for(int j=0; j<26; j++) {
				mapLeft[i][j] = (i-1>=0?mapLeft[i-1][j]:-1);
			}
			mapLeft[i][s.charAt(i)-'a'] = i;
		}

		//from right keep the highest index (to the right) which keeps the substring T[j:n]
		//map[j] = that index
		//so it is smallest index from right

		int done = m-1;

		int[] finalMap2 = new int[m];

		for(int i=n-1; i>=0; i--) {
			if (done==-1) {
				break;
			}
			if (s.charAt(i)==t.charAt(done)) {
				finalMap2[done] = i;
				done--;
			}
		}

		int[] finalMap1 = new int[m];
		done = 0;

		for(int i=0; i<n; i++) {
			if (done==m) break;
			if (s.charAt(i)==t.charAt(done)) {
				finalMap1[done] = i;
				done++;
			}
		}

		done = 0;

		int ans = 0;

		int i = 0;

		//i to j-1 -> j-1-i+1 -> j-i

		while(i<n) {
			ans = Math.max(ans, finalMap2[done]-i);
			i = finalMap1[done]+1;
			done++;
			if (done==m) {
				ans = Math.max(ans, n-1-i+1);
				break;
			}
		}

		println(ans);

		out.flush();
		out.close();

	}

	//NONPROBLEM CODE

	private static InputReader in = new InputReader(System.in);
	private static PrintWriter out = new PrintWriter(System.out);

	private static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;

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

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

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

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

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

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

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

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

	}

	//INPUT SHORTCUTS

	private static int[] ina(int n) {
		int[] temp = new int[n];
		for (int i = 0; i < n; i++) {
			temp[i] = in.nextInt();
		}
		return temp;
	}

	private static int ini() {
		return in.nextInt();
	}

	private static String ins() {
		return in.readString();
	}

	//OTHER SHORTCUTS
	public static void sort(int[] a) {
		Arrays.sort(a);
	}

	//PRINT SHORTCUTS

	private static void println(Object... o) {
		for (Object x : o) {
			out.write(x + " ");
		}
		out.write("\n");
	}

	private static void print(Object... o) {
		for (Object x : o) {
			out.write(x + "");
		}
	}

	private static void printAll(Object... o) {
		for (Object x : o) {
			out.write(x + " ");
		}
	}

	private static void debug(Object... o) {
		for (Object x : o) {
			out.write(x + " ");
		}
		out.write("\n");
		out.flush();
	}

	private static HashMap<Integer, ArrayList<Integer>> intree(int n) {

		HashMap<Integer, ArrayList<Integer>> g = new HashMap<>();
		for (int i = 0; i < n; i++) {
			g.put(i, new ArrayList<>());
		}

		for (int i = 0; i < n - 1; i++) {
			int u = ini() - 1;
			int v = ini() - 1;
			g.get(u).add(v);
			g.get(v).add(u);
		}

		return g;
	}
}


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

public class CF797A{
  public static int index;
  public static void main(String[] args)throws Exception {
    InputReader in = new InputReader(System.in);
    PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
    int n = in.nextInt(), k = in.nextInt();

    ArrayList<Integer> list = new ArrayList<>();

    while(list.size() < k && n > 1){

      if(list.size() == k-1 && n > 1){
        list.add(n);
        n = 1;
        break;
      }

      for(int i = 2; i <= n; i++){
        if(n%i == 0) {
          list.add(i);
          n /= i;
          break;
        }
      }

    }

    if(list.size() < k || n != 1) pw.println(-1);
    else{
      for(int i : list) pw.print(i+" ");
      pw.println();
    }

    pw.close();
  }

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

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

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

    public String nextLine()throws Exception {
      String line = null;
      tokenizer = null;
      line =  reader.readLine();
      return line;
    }

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

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

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

  }
}


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

public class D {

	static class Point {
		int x, y;

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

		@Override
		public String toString() {
			return "(" + x + ", " + y + ")";
		}
	}

	void submit() {
		int n = nextInt();
		int nn = n;
		Point[] a = new Point[n];
		long sx = 0;
		long sy = 0;
		for (int i = 0; i < n; i++) {
			int x = nextInt() * 2;
			int y = nextInt() * 2;
			a[i] = new Point(x, y);
			sx += x;
			sy += y;
		}

		boolean[] mark = new boolean[n];

		for (int i = 0; i < n; i++) {
			long ix = 2 * sx - (long)n * a[i].x;
			long iy = 2 * sy - (long)n * a[i].y;
			for (int j = i; j < n; j++) {
				if ((long)n * a[j].x == ix && (long)n * a[j].y == iy) {
					mark[j] = mark[i] = true;
					break;
				}
			}
		}

		{
			Point[] b = new Point[n];
			int ptr = 0;
			for (int i = 0; i < n; i++) {
				if (!mark[i]) {
					b[ptr++] = a[i];
				}
			}
			a = Arrays.copyOf(b, ptr);
		}

		n = a.length;

		if (n == 0) {
			out.println(-1);
			return;
		}

		BigInteger[] dx = new BigInteger[n];
		BigInteger[] dy = new BigInteger[n];

		for (int i = 0; i < n; i++) {
			int mx = (a[0].x + a[i].x) / 2;
			int my = (a[0].y + a[i].y) / 2;
			dx[i] = b((long)nn * my - sy);
			dy[i] = b(sx - (long)nn * mx);
		}

		BigInteger[] p = new BigInteger[n];

		int ans = 0;

		outer: for (int i = 0; i < n; i++) {
			for (int j = 0; j < i; j++) {
				if (dx[i].multiply(dy[j]).equals(dy[i].multiply(dx[j]))) {
					continue outer;
				}
			}
			for (int j = 0; j < n; j++) {
				p[j] = dx[i].multiply(b(a[j].x)).add(dy[i].multiply(b(a[j].y)));
			}
			Arrays.sort(p);
			BigInteger sum = p[0].add(p[n - 1]);
			for (int p1 = 1, p2 = n - 2; p1 <= p2; p1++, p2--) {
				if (!p[p1].add(p[p2]).equals(sum)) {
					continue outer;
				}
			}
			ans++;
		}
		out.println(ans);
	}

	BigInteger b(long x) {
		return BigInteger.valueOf(x);
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	D() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		// stress();
		// test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

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

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

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

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

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

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

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


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

public class A {

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

		String go = "go";
		String ogo = "ogo";

		int begin = 0;
		int end  = 0;

		boolean flag = false;

		String ss  = "";

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

			if(!flag){
			if(i <= s.length()-3 && s.substring(i, i+3).equals(ogo)){
				flag = true;
				begin = i;
				end = i+3;
				i = i+2;
				ss += "***";
			}else{

			ss += s.charAt(i);

			}

			}else{
				//System.out.println("3w");

				if(i <= s.length()-2 && s.substring(i,i+2).equals(go)){
					i++;
					end = i+1;

				}else{
					flag = false;
					//ss +=""+ s.charAt(i) +s.charAt(i+1);
					i = end-1;
				//System.out.println(i+1);
					//System.out.println(end);

				}

			}

		}

		//System.out.println(end);

		System.out.println(ss);

	}

}


/**
 * Created on 6/8/14
 *
 * @author: Anirudh Rayabharam <anirudh.rayabharam@gmail.com>
 * @handle: code_overlord
 */
import java.io.*;

public class KitaharaHarukiGift {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintStream out = System.out;

        int n = in.nextInt();
        int[] w = new int[n];

        int sum = 0;
        int oneH, twoH;
        oneH = twoH = 0;
        for (int i = 0; i < n; i++) {
            w[i] = in.nextInt();
            sum += w[i];
            if (w[i] == 100) oneH++;
            else twoH++;
        }

        int each = sum / 2;
        int x = sum / 100;

        if (x % 2 == 1) out.println("NO");
        else {
            boolean possible = false;
            for (int i = 0; i <= twoH; i++) {
                if (200 * i <= each && each - 200 * i <= oneH * 100) possible = true;
            }

            if (possible) out.println("YES");
            else out.println("NO");
        }
    }

    private static class InputReader {
        public BufferedReader reader;
        private int tokenCount, nextTokenIndex;
        private String[] tokens;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenCount = nextTokenIndex = 0;
        }

        public String next() {
            String nextLine;
            if (nextTokenIndex == tokenCount) {
                try {
                    nextLine = reader.readLine();
                    nextTokenIndex = 0;
                    tokens = nextLine.split("\\s");
                    tokenCount = tokens.length;
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokens[nextTokenIndex++];
        }

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


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.InputMismatchException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Writer;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Arthur Gazizov [2oo7] - Kazan FU
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        FastPrinter out = new FastPrinter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public static int cmpOne(Func a, Func b) {
            if (MathUtils.equals(a.x, 1)) {
                int cmp = Double.compare(a.x, b.x);
                return MathUtils.equals(cmp, 0) ? 0 : cmp;
            }
            if (MathUtils.equals(b.x, 1)) {
                int cmp = Double.compare(a.x, b.x);
                return MathUtils.equals(cmp, 0) ? 0 : cmp;
            }
            return 0;
        }

        public static int cmp(Func a, Func b) {
            int test = cmpOne(a, b);
            if (test != 0) return test;
            if ((a.x - 1) * (b.x - 1) < 0) return Double.compare(a.x, b.x);
            return MathUtils.equals(a.get(), b.get()) ? 0 : (MathUtils.sign(a.x - 1)) * Double.compare(a.get(), b.get());
        }

        public void solve(int testNumber, FastScanner in, FastPrinter out) {
            double x = in.nextDouble();
            double y = in.nextDouble();
            double z = in.nextDouble();
            Func[] funcs = new Func[12];
            funcs[0] = new Func(x, y, z, 0, 0);
            funcs[1] = new Func(x, z, y, 0, 1);
            funcs[2] = new Func(x, y, z, 1, 2);
            funcs[3] = new Func(x, z, y, 1, 3);
            funcs[4] = new Func(y, x, z, 0, 4);
            funcs[5] = new Func(y, z, x, 0, 5);
            funcs[6] = new Func(y, x, z, 1, 6);
            funcs[7] = new Func(y, z, x, 1, 7);
            funcs[8] = new Func(z, x, y, 0, 8);
            funcs[9] = new Func(z, y, x, 0, 9);
            funcs[10] = new Func(z, x, y, 1, 10);
            funcs[11] = new Func(z, y, x, 1, 11);
            int size = 12;
            Comparator<Func> fuck = new Comparator<Func>() {
                public int compare(Func a, Func b) {
                    int c = cmp(a, b);
                    return c == 0 ? -Integer.compare(a.index, b.index) : c;
                }
            };
            Arrays.sort(funcs, fuck);
            String ans = "";
            switch (funcs[11].index) {
                case 0:
                    ans = "x^y^z";
                    break;
                case 1:
                    ans = "x^z^y";
                    break;
                case 2:
                    ans = "(x^y)^z";
                    break;
                case 3:
                    ans = "(x^z)^y";
                    break;
                case 4:
                    ans = "y^x^z";
                    break;
                case 5:
                    ans = "y^z^x";
                    break;
                case 6:
                    ans = "(y^x)^z";
                    break;
                case 7:
                    ans = "(y^z)^x";
                    break;
                case 8:
                    ans = "z^x^y";
                    break;
                case 9:
                    ans = "z^y^x";
                    break;
                case 10:
                    ans = "(z^x)^y";
                    break;
                case 11:
                    ans = "(z^y)^x";
                    break;
            }
            out.print(ans);
        }

    }

    static class Func {
        public double x;
        public double y;
        public double z;
        public int type;
        public int index;

        public Func(double x, double y, double z, int type, int index) {
            this.x = x;
            this.y = y;
            this.z = z;
            this.type = type;
            this.index = index;
        }

        public double get() {
            return type == 0 ? Math.log(Math.abs(Math.log(x))) + z * Math.log(y) : Math.log(Math.abs(Math.log(x))) + Math.log(y * z);
        }

    }

    static class FastScanner extends BufferedReader {
        boolean isEOF;

        public FastScanner(InputStream is) {
            super(new InputStreamReader(is));
        }

        public FastScanner(InputStreamReader inputStreamReader) {
            super(inputStreamReader);
        }

        public int read() {
            try {
                int ret = super.read();
                if (isEOF && ret < 0) {
                    throw new InputMismatchException();
                }
                isEOF = ret == -1;
                return ret;
            } catch (IOException e) {
                throw new InputMismatchException();
            }
        }

        public static boolean isWhiteSpace(int c) {
            return c >= -1 && c <= 32;
        }

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

        public int nextInt() {
            int c = read();
            while (isWhiteSpace(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int ret = 0;
            while (!isWhiteSpace(c)) {
                if (c < '0' || c > '9') {
                    throw new NumberFormatException("digit expected " + (char) c
                            + " found");
                }
                ret = ret * 10 + c - '0';
                c = read();
            }
            return ret * sgn;
        }

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

        public String readLine() {
            try {
                return super.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }

    }

    static class FastPrinter extends PrintWriter {
        public FastPrinter(Writer writer) {
            super(writer);
        }

        public FastPrinter(OutputStream out) {
            super(out);
        }

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

    }

    static class MathUtils<T> {
        public static final double EPS = 1e-9;

        public static final double abs(double value) {
            return value >= 0 ? value : -value;
        }

        public static final int sign(double value) {
            if (value > EPS) return 1;
            if (value < -EPS) return -1;
            return 0;
        }

        public static final boolean equals(double a, double b) {
            return abs(a - b) < EPS;
        }

    }
}


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

public class Main {

	void solve(Scanner in, PrintWriter out) {

		int n = in.nextInt();
		out.println(3L * (1 + n) * n + 1);
	}

	void run() {
		try (Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out)) {
			solve(in, out);
		}

	}

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


//package com.company;

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

public class Main {

    public static void main(String[] args) {
        // write your code here
        StringBuilder sb = new StringBuilder();
        Scanner s=new Scanner(System.in);
    char[] a=s.next().toCharArray();StringBuilder power=new StringBuilder();int flag=0;char[] base=new char[a.length];
    for(int i=0;i<a.length;i++){
        if(a[i]=='e'){
            flag=1;continue;
        }
        if(flag==0){
            base[i]=(a[i]);
        }else{
            power.append(a[i]);
        }
    }flag=0;int p=Integer.parseInt(power.toString());int clur=0;
    for(int i=0;i<a.length;i++){
        if(a[i]=='e') break;
        if(flag==0){if(a[i]=='.') {
            flag=1;continue;
        }
            sb.append(a[i]);
        }else{if(a[i]=='0'&&a[i-1]=='.'&&(a[i+1]=='e')) {
            while(p>0){
                sb.append('0');p--;
            }
            break;}
            if(p>0){
                sb.append(a[i]);p--;
            }else{if(clur==0){
                sb.append('.'); clur=1;}sb.append(a[i]);
            }
        }
    }while(p>0){
        sb.append('0');p--;
        }
        System.out.println(sb.toString());
    }static int success=0,endi=0,endj=0;static char[][] a;static int n,m;static int[] [] vis;
static void dfs(int i,int j,char dir,int turns){
   //  vis[i][j]=1;
     if(turns>2) return;

       if(dir=='Z'){
           if(i+1<n&&a[i+1][j]=='T') {
              success=1;return;
           }if(success==1) return;
               if(i+1<n&&a[i+1][j]!='*'&&vis[i+1][j]==0){
               dfs(i+1,j,'D',turns);
           }if(success==1) return;if(i-1>=0&&a[i-1][j]=='T') {
               success=1;return;
           }if(success==1) return;
           if(i-1>=0&&a[i-1][j]!='*'&&vis[i-1][j]==0){
               dfs(i-1,j,'U',turns);
           }if(success==1) return;
           if(j+1<m&&a[i][j+1]=='T') {
               success=1;return;
           }if(success==1) return;
           if(j+1<m&&a[i][j+1]!='*'&&vis[i][j+1]==0){
               dfs(i,j+1,'R',turns);
           }if(success==1) return;
           if(j-1>=0&&a[i][j-1]=='T') {
               success=1;
           }if(success==1) return;
           if(j-1>=0&&a[i][j-1]!='*'){
               dfs(i,j-1,'L',turns);
           }if(success==1) return;
       }else{
           if(i+1<n&&a[i+1][j]=='T') {
               if(turns<2||'D'==dir)
                   success=1;
           }if(success==1) return;
           if(i+1<n&&a[i+1][j]!='*'&&vis[i+1][j]==0){
         if('D'!=dir)       dfs(i+1,j,'D',turns+1);else      dfs(i+1,j,'D',turns);

           }if(success==1) return;
           if(i-1>=0&&a[i-1][j]=='T') {
               if(turns<2||'U'==dir)

                   success=1;;
           }if(success==1) return;
           if(i-1>=0&&a[i-1][j]!='*'&&vis[i-1][j]==0){
             if('U'!=dir)
               dfs(i-1,j,'U',turns+1);else      dfs(i-1,j,'U',turns);

           }if(success==1) return;
           if(j+1<m&&a[i][j+1]=='T') {
               if(turns<2||'R'==dir)

                   success=1;;
           }if(success==1) return;
           if(j+1<m&&a[i][j+1]!='*'&&vis[i][j+1]==0){
              if('R'!=dir)
               dfs(i,j+1,'R',turns+1);
              else
                  dfs(i,j+1,'R',turns);

           }if(success==1) return;
           if(j-1>=0&&a[i][j-1]=='T') {
               if(turns<2||'L'==dir)
               success=1;

           }if(success==1) return;
           if(j-1>=0&&a[i][j-1]!='*'&&vis[i][j-1]==0){
               if('L'!=dir)
               dfs(i,j-1,'L',turns+1);
               else
                   dfs(i,j-1,'L',turns);

           }if(success==1) return;
       }
}

}


//I AM THE CREED
/* //I AM THE CREED
/* package codechef; // don't place package name! */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException
    {

        Scanner input = new Scanner(System.in);
        while(input.hasNext()){
            int n=input.nextInt();
            String s=input.next();
            int min=s.length();
            for(int i=0;i<s.length();i++){
                if((2)*(i+1)>s.length()){
                    break;
                }
                if(s.substring(0, i+1).equals(s.substring(i+1, (2*i)+2))){
                    min=Math.min(s.length()-(i), min);
                }
            }
            System.out.println(min);
        }

    }

}


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

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

    static class E802 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {

            int n = in.nextInt();
            int[] a = new int[250];

            for (int v = 1; v <= n; v++) {

                double sum = 0;
                for (int i = 0; i < 250; i++) {
                    a[i] = in.nextInt();
                    sum += a[i];
                }

                double mean = sum / 250;

                double variance = 0;

                for (int i = 0; i < 250; i++) {
                    double deviation = mean - a[i];
                    variance += deviation * deviation;
                }

                variance /= 250;

                int ans = 0;

                if (2 * mean >= variance) { //gaussian
                    ans = ((int) Math.round(mean));
                } else { //uniform
                    ans = arrays.max(a) + arrays.min(a);
                    ans = ((int) Math.round(ans / 2.));
                }

                out.println(ans);

            }
        }

    }

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

    }

    static class arrays {
        public static int max(int[] a) {
            int ans = a[0];
            for (int i : a) {
                ans = Math.max(ans, i);
            }
            return ans;
        }

        public static int min(int[] a) {
            int ans = a[0];
            for (int i : a) {
                ans = Math.min(ans, i);
            }
            return ans;
        }

    }
}


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

public class Main
{

    static Scanner p = new Scanner(System.in);
    public static void main(String[] args) {
        String[] nmab = p.nextLine().split(" ");
        int mb = Integer.parseInt(nmab[1]) * Integer.parseInt(nmab[3]);
        int na = Integer.parseInt(nmab[0]) * Integer.parseInt(nmab[2]);
        int n = Integer.parseInt(nmab[0]);
        int m = Integer.parseInt(nmab[1]);
        int a = Integer.parseInt(nmab[2]);
        int b = Integer.parseInt(nmab[3]);
        if(b / m < a){
            if(m == n){
                System.out.println(b);
                System.exit(0);
            }else if(m < n){
                if((n % m) % 2 == 0 && b < a){
                    System.out.println(b*((n + m - 1) / m));
                    System.exit(0);
                }else{
                    if(b < a){
                        System.out.println(b*(n/m)+(b*(n%m)));
                        System.exit(0);
                    }else{
                        System.out.println((b*(n/m))+((n%m)*a));
                        System.exit(0);
                    }
                }

        }else{
                if(b > a && (n*a) < b){
                    System.out.println(n*a);
                    System.exit(0);
                }else{
                    System.out.println(b);
                }
            }
        }else{
            System.out.println(n*a);
            System.exit(0);
        }
    }
}


import java.util.Scanner;

public class PointOnSpiral {

    public static int go(int x , int y){
        int step = 1;
        int flag = 0;
        int sx = 0 , sy = 0;
        int result = 0;
        while(true){
            int nx = sx , ny = sy;
            if(flag == 0){
                if(nx <= 0)
                    nx += step;
                else
                    nx -= step;
            }else{
                if(ny <= 0){
                    ny += step;
                }else
                    ny -= step;
            }

            if(sx == nx && x == sx && (y >= sy && y <= ny || y >= ny && y <= sy))
                return result;

            if(sy == ny && y == sy && (x >= sx && x <= nx || x >= nx && x <= sx))
                return result;

            flag ++;
            if(flag == 2){
                step ++;
                flag = 0;
            }
            result ++;
            sx = nx;
            sy = ny;
        }
    }

    public static void main(String args[]){
        Scanner s = new Scanner(System.in);
        int x = s.nextInt();
        int y = s.nextInt();
        System.out.println(go(x , y));
    }

}


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

/**
 * Created by hapsi on 11.10.2016.
 */
public class Main {
    private static class FastScanner {
        private BufferedReader br;
        private StringTokenizer st;
        public FastScanner(InputStream inputStream){
            br = new BufferedReader(new InputStreamReader(inputStream));
        }
        public String next() {
            while (st == null || !st.hasMoreTokens()){
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException ignored){}
            }
            return st.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    private static int binarySearch(int []a, int l, int r, int x){
        if (l >= r) return -1;
        int m = (l + r) / 2;
        if (a[m] > x || (a[m] == x && m > 0 && a[m-1] == x))
            return binarySearch(a, l, m, x);
        else if (a[m] < x)
            return binarySearch(a, m + 1, r, x);
        return m;
    }

    private static int nextSearch(int []a, int l, int r, int x){
        if (l >= r) return l;
        int m = (l + r) / 2;
        if (a[m] > x)
            return nextSearch(a, l, m, x);
        else if (a[m] < x || (m < a.length - 1 && a[m+1] == x))
            return nextSearch(a, m + 1, r, x);
        return m + 1;
    }

    private static int nearestSearch(int []a, int l, int r, int x) {
        if (l >= r) {
            if (a.length == 1) {
                return 0;
            }
            else if (l >= a.length) {
                return a.length - 1;
            }
            else if (l-1 >= 0) {
                int d1 = Math.abs(a[l-1] - x);
                int d2 = Math.abs(a[l] - x);
                if (d1 <= d2) {
                    return l-1;
                }
                return l;
            }
            else {
                return l;
            }
        }
        int m = (l + r) / 2;
        if (a[m] > x || (a[m] == x && m > 0 && a[m-1] == x)) {
            return nearestSearch(a, l, m, x);
        }
        else if (a[m] < x) {
            return nearestSearch(a, m + 1, r, x);
        }
        return m;
    }

    private static int compareString(String a, String b){
        if(a.length() > b.length()){
            return 1;
        }
        else if(a.length() < b.length()){
            return -1;
        }
        for(int i=0;i<a.length();i++){
            if(a.charAt(i) > b.charAt(i)){
                return 1;
            }
            else if(a.charAt(i) < b.charAt(i)){
                return -1;
            }
        }
        return 0;
    }

    public static void main(String args[]){
        FastScanner scanner = new FastScanner(System.in);
        PrintWriter printer = new PrintWriter(System.out);
        //printer.println((long)Math.pow(10,9) + " " + (long)Math.pow(10,9) + " " + ((long)((Math.pow(10,9) * Math.pow(10,9))) - 1));
        long n = scanner.nextLong(), m = scanner.nextLong(), k = scanner.nextLong();
        if (k <= n - 1) {
            printer.println((k+1) + " 1");
        }
        else {
            k-=n;
            if(k == 0) {
                printer.println(n + " 2");
            }
            else {
                long d = k / (m - 1);
                long x = n - d;
                k-=d;
                if (m-2 > 0) {
                    k = k - (k / ((m - 2) * 2)) * ((m - 2) * 2);
                }
                long y = 2;
                boolean r = true;
                while(true) {
                    if (k <= m - 2) {
                        if (r) {
                            y += k;
                        } else {
                            y -= k;
                        }
                        break;
                    } else {
                        y = m;
                        k -= m - 2;
                        r = !r;
                    }
                }
                printer.println(x + " " + y);
            }
        }

        printer.close();
    }
}


import java.util.Scanner;

public class CF552_C {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(),
            b = sc.nextInt(),
            c = sc.nextInt();

        int[] aW = new int[]{1,0,0,1,0,0,1};
        int[] bW = new int[]{0,1,0,0,0,1,0};
        int[] cW = new int[]{0,0,1,0,1,0,0};

        long best = 0;
        for(int day = 0; day < 7; day++){
            long aa = a, bb = b, cc = c;

            long counter = 0;

            for(int i = day; i < 7; i++){
                aa-=aW[i];
                bb-=bW[i];
                cc-=cW[i];
                if(aa < 0 || bb < 0 || cc < 0){
                    if(aa < 0) aa=0;
                    if(bb < 0) bb=0;
                    if(cc < 0) cc=0;
                    break;
                }
                counter++;
            }

            long daysA = aa/3;
            long daysB = bb/2;
            long daysC = cc/2;

            long fullWeeks = Math.min(daysA, Math.min(daysB, daysC));

            counter+= fullWeeks * 7;

            aa-=fullWeeks * 3;
            bb-=fullWeeks * 2;
            cc-=fullWeeks * 2;

            for(int i = 0; i < 7; i++){
                aa-=aW[i];
                bb-=bW[i];
                cc-=cW[i];
                if(aa < 0 || bb < 0 || cc < 0){
                    break;
                }
                counter++;
            }

            best = Math.max(counter, best);
        }

        System.out.println(best);

    }

}


import java.util.*;

public class Test {

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

        int count = 0;
        for(int i=0;i<=a;i+=2){
            int rem = n;
            rem = rem - i/2;
            for(int j=0;j<=b&&j<=rem;j++){
                int rem1 = rem - j;
                if(rem1%2==0&&rem1/2<=c)
                    count++;
            }
        }
        System.out.println(count);
    }
}


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

public class CF336A {
    public static void main(String[] args) {
        FastReader input = new FastReader();
        PrintWriter pw = new PrintWriter(System.out);

        int x = input.nextInt();
        int y = input.nextInt();

        if(x > 0 && y > 0)
            pw.println(0 + " " + (x+y) + " " + (x+y) + " " + 0);

        else if(x > 0 && y < 0){
            x = Math.abs(x);
            y = Math.abs(y);

            pw.println(0 + " " + ((-1) * (x+y)) + " " + (x+y) + " " + 0);
        }

        else if(x < 0 && y > 0){
            x = Math.abs(x);
            y = Math.abs(y);

            pw.println(((-1) * (x+y)) + " " + 0 + " " + 0 + " " + (x+y));
        }

        else if(x < 0 && y < 0){
            x = Math.abs(x);
            y = Math.abs(y);

            pw.println(((-1) * (x+y)) + " " + 0 + " " + 0 + " " + ((-1) * (x+y)));
        }

        // ****If sorting is required, use ArrayList
        pw.flush();
        pw.close();
    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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


    import java.io.IOException;

     import java.util.*;

        public class Training {

                public static void main(String[] args) throws IOException {
     		Scanner input = new Scanner(System.in);
                     int [][]a= new int[8][8];
                     String answer = "NO";
                   for(int i =2;i<6;i++){
                      String s= input.next();
                      for(int j=2;j<6;j++){
                          if(s.charAt(j-2)=='x'){
                              a[i][j]= 1;

                          }else if(s.charAt(j-2)=='o'){
                              a[i][j]= -1;
                          }else if(s.charAt(j-2)=='.'){
                              a[i][j]=10;
                          }
                      }
                   }

          for(int i =2;i<6;i++){
         for(int j =2;j<6;j++){

            if ( a[i][j] + a[i][j+1] + a[i][j+2] == 12 )
            {
              answer = "YES";
            }
            if ( a[i][j] + a[i+1][j+1] + a[i+2][j+2] == 12 )
            {
              answer = "YES";
            }
            if ( a[i][j] + a[i+1][j] + a[i+2][j] == 12)
            {
              answer = "YES";
            }
            if ( a[i][j] + a[i-1][j+1] + a[i-2][j+2] == 12 )
            {
              answer = "YES";
            }

             }
                    } // end for

          System.out.println(answer);

                 } // end main

        } // end Class


import java.util.*;
import java.util.concurrent.ForkJoinTask;
import java.util.concurrent.RecursiveAction;
import java.util.concurrent.RecursiveTask;
import java.util.concurrent.atomic.AtomicInteger;
import java.io.*;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.math.*;

import javax.swing.plaf.SliderUI;

import static java.lang.Math.*;

public class Solution implements Runnable {

	ArrayList<Integer> g [];
	ArrayList<Integer> topoSort = new ArrayList<>();

	int vars[];
	int topIndex [];
	int color [];
	int variables[];

	boolean used [];

	boolean findCycle(int v) {
		if (color[v] == 2)
			return false;
		if (color[v] == 1)
			return true;
		color[v] = 1;
		for (int i = 0; i < g[v].size(); i++)
			if (findCycle(g[v].get(i)))
				return true;
		color[v] = 2;
		return false;
	}

	void dfs(int v) {
		if (used[v])
			return;
		used[v] = true;
		variables[v] = 0;
		for (int i = 0; i < g[v].size(); i++) {
			dfs(g[v].get(i));
		}
		topoSort.add(v);
	}

	void findDivisonByZeroTypes(Node node) {
		if (node instanceof OperationNode) {
			OperationNode opNode = (OperationNode) node;
			VariableNode right = (VariableNode) opNode.right;
			if (opNode.operation == '/') {
				variables[right.variableType] = 1;
			}
			findDivisonByZeroTypes(opNode.left);
			findDivisonByZeroTypes(opNode.right);
		} else {
			return;
		}
	}

	interface Node {

		long eval (int[] variables);

	}

	class VariableNode implements Node {

		int variableIndex;
		int variableType;

		public VariableNode(int variableIndex, int variableType) {
			this.variableIndex = variableIndex;
			this.variableType = variableType;
		}

		@Override
		public long eval(int[] variables) {
			return variables[variableIndex];
		}

	}

	class OperationNode implements Node {

		char operation;
		Node left, right;

		public OperationNode(Node left, Node right, char operation) {
			this.left = left;
			this.right = right;
			this.operation = operation;
		}

		@Override
		public long eval(int[] variables) {
			long l = left.eval(variables);
			long r = right.eval(variables);
			switch (operation) {
				case '+':
					return l + r;
				case '-':
					return l - r;
				case '*':
					return l * r;
				case '/':
					return l / r;
			}
			return 0;
		}

	}

	class Parser {

		int it;
		String expression;

		int operationPriority[] = new int [256];

		int variables;
		ArrayList<Integer> variableTypes = new ArrayList<>();

		public Parser() {
			operationPriority['-'] = operationPriority['+'] = 0;
			operationPriority['*'] = operationPriority['/'] = 1;
		}

		public Parser(String expression) {
			super();
			this.expression = expression;
		}

		public Node parse() {
			it = 0;
			return parse(0);
		}

		public int[] getVars() {
			int[] vars = new int [variables];
			for (int i = 0; i < variables; i++) {
				vars[i] = variableTypes.get(i);
			}
			return vars;
		}

		private Node parseValue() {
			int variableType = 0;
			while (it < expression.length() && expression.charAt(it) == '_') {
				variableType++;
				it++;
			}
			variables++;
			variableTypes.add(variableType);
			return new VariableNode(variables - 1, variableType);
		}

		private Node parse(int prior) {
			if (prior == 2)
				return parseValue();
			Node result = parse(prior + 1);
			while (it < expression.length() && operationPriority[expression.charAt(it)] == prior) {
				char operation = expression.charAt(it);
				it++;
				Node right = parse(prior + 1);
				result = new OperationNode(result, right, operation);
			}
			return result;
		}

	}

	public void solve() throws Exception {
		color = new int [1024];
		g = new ArrayList[1024];
		for (int i = 0; i < 1024; i++)
			g[i] = new ArrayList<>();

		String a = sc.nextToken();
		StringBuilder sb = new StringBuilder();

		int lBracket = a.indexOf('(');
		int rBracket = a.indexOf(')');

		String expression = a.substring(lBracket + 1, rBracket);
		Parser parser = new Parser(expression);

		Node root = parser.parse();

		vars = parser.getVars();
		Integer varIndices[] = new Integer [vars.length];
		for (int i = 0; i < vars.length; i++)
			varIndices[i] = i;

		boolean usedTypes [] = new boolean[1024];
		for (int i = 0; i < vars.length; i++) {
			usedTypes[vars[i]] = true;
		}

		int colon = a.indexOf(":-");
		String inequalityString = a.substring(colon + 2, a.length() - 1);
		String[] inequalities = inequalityString.split(",");
		for (String inequality : inequalities) {
			char separator;
			int separatorIndex = -1;
			if (inequality.indexOf('>') != -1) {
				separator = '>';
				separatorIndex = inequality.indexOf('>');
			} else {
				separator = '<';
				separatorIndex = inequality.indexOf('<');
			}
			int typeLeft = separatorIndex;
			int typeRight = inequality.length() - separatorIndex - 1;
			if (separator == '>') {
				g[typeLeft].add(typeRight);
			} else {
				g[typeRight].add(typeLeft);
			}
		}

		for (int i = 0; i < 1024; i++) {
			if (color[i] == 0) {
				if (findCycle(i)) {
					out.println("false");
					return;
				}
			}
		}

		variables = new int [1024];
		used = new boolean [1024];
		Arrays.fill(variables, -1);
		for (int i = 0; i < 1024; i++) {
			if (usedTypes[i]) {
				dfs(i);
			}
		}

		findDivisonByZeroTypes(root);

		for (int type : topoSort) {
			int maxValue = 0;
			for (int to : g[type]) {
				maxValue = max (maxValue, variables[to] + 1);
			}
			variables[type] = maxValue;
			if (variables[type] > 9) {
				out.println("false");
				return;
			}
		}

		for (int i = 0; i < vars.length; i++) {
			out.print(variables[vars[i]]);
		}

	}

	static Throwable t;

	BufferedReader in;
	FastScanner sc;
	PrintWriter out;

	@Override
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			sc = new FastScanner(in);
			solve();
		} catch (Throwable t) {
			Solution.t = t;
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) throws Throwable {
		Thread thread = new Thread(null, new Solution(), "", 1 << 26);
		thread.start();
		thread.join();
		if (Solution.t != null)
			throw t;
	}

}

class FastScanner {

	BufferedReader in;
	StringTokenizer st;

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

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

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

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

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

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;

public class CF171G {

    private StreamTokenizer in;
    private PrintWriter out;

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

    int nextInt () throws IOException {
        in.nextToken();
        return (int)in.nval;
    }

    void soilve () throws IOException {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(new OutputStreamWriter(System.out));

        int a = nextInt();
        int b = nextInt();
        int c = nextInt();

        if (c == 1) {
            out.print(b);
            out.flush();
            return;
        }

        int res = 0;
        for (int i = 2; i <= c; i++) {
            res = a + b;
            a = b;
            b = res;
        }

        out.print(res);
        out.flush();
    }
}


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

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

public class C {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        //BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        Scanner in = new Scanner(System.in);
        int n  ,i,j,k,a,a0=0,a1=0;
        String s;
        int[][] f = new int[10][10];
        for (i=0;i<10;i++) for(j=0;j<10;j++) f[i][j] = 1;
        for (i = 0; i < 8; i++) {
            s = in.nextLine();
            for(j=0;j<s.length();j++) {
                switch (s.charAt(j)) {
                    case '.' : f[i+1][j+1] = 0; break;
                    case 'A' : f[i+1][j+1] = 0; break;
                    case 'M' : f[i+1][j+1] = 5; break;
                    case 'S' : f[i+1][j+1] = 13; break;
                }
            }
        }
        List<Integer> mm;
        int[] di = new int[]{0,0,1,-1,1,1,-1,-1};
        int[] dj = new int[]{1,-1,0,0,1,-1,1,-1};
        mm = new ArrayList<Integer>(64);
        for (a=0; a<8; a++) {
            mm.clear();
            for (i=0;i<10;i++) for(j=0;j<10;j++)
                if (f[i][j] == 5) mm.add(i*10+j);
            for (Integer m : mm) {
                i = m/10; j = m%10;
                for (k=0;k<8;k++)
                    if (f[i+di[k]][j+dj[k]]==0) f[i+di[k]][j+dj[k]]=5;
            }

            for (i=0;i<10;i++) for(j=8;j>0;j--)
                if (f[j-1][i]==13) {
                    f[j][i] = 13;
                    f[j-1][i] = 0;
                }
        }
        if (mm.size()==0) System.out.print("LOSE");
        else System.out.print("WIN");

    }
}
/*
.......A
........
........
........
........
.S......
S.......
M.......
 *
 *
 */


import java.util.*;
public class Vasya {

	public static void main(String[] args) {

Scanner sc = new Scanner(System.in);
int n,m;

n=sc.nextInt();
m=sc.nextInt();
int days=0;
while(n!=0) {
	n--;
	days++;
	if(days%m==0 && days!=0) {

		n++;
	}

}
System.out.println(days);

	}

}


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

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

class TaskC {
    Scanner in;
    PrintWriter out;

    public void solve(int testNumber, Scanner in, PrintWriter out) {
        this.in = in;
        this.out = out;
        run();
    }

    void run() {
        long c = in.nextInt();
        long hr = in.nextInt();
        long hb = in.nextInt();
        long wr = in.nextInt();
        long wb = in.nextInt();
        out.println(Math.max(go(c, hr, hb, wr, wb), go(c, hb, hr, wb, wr)));
    }

    private long go(long c, long hr, long hb, long wr, long wb) {
        long top = c / wr;
        long res = 0;
        for (int i = 0; i < 1000000; i++) {
            long y = top - i;
            long x = (c - y * wr) / wb;
            if (x >= 0 && y >= 0) res = Math.max(res, x * hb + y * hr);
        }
        return res;
    }
}

class Scanner {
    BufferedReader br;
    StringTokenizer st;

    public Scanner(InputStream in) {
        br = new BufferedReader(new InputStreamReader(in));
        eat("");
    }

    private void eat(String s) {
        st = new StringTokenizer(s);
    }

    public String nextLine() {
        try {
            return br.readLine();
        } catch (IOException e) {
            return null;
        }
    }

    public boolean hasNext() {
        while (!st.hasMoreTokens()) {
            String s = nextLine();
            if (s == null)
                return false;
            eat(s);
        }
        return true;
    }

    public String next() {
        hasNext();
        return st.nextToken();
    }

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

}


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

public class Main{

	    static String s1, s2, virus;
	    static int[][][] dp = new int[200][200][200];
	    static int[][] ch = new int[200][30];
	    static int[] fail = new int[200];
	    static int n, x, y;
	    static boolean[][][] vis = new boolean[200][200][200];

	    static void init() {
	        fail[0] = fail[1] = 0;
	        for (int i = 1; i < n; i++) {
	            int j = fail[i];
	            while (j != 0 && virus.charAt(i) != virus.charAt(j)) j = fail[j];
	            fail[i + 1] = (virus.charAt(i) == virus.charAt(j)) ? j + 1 : 0;
	        }

	        for (int i = 0; i < n; i++) ch[i][virus.charAt(i) - 'A'] = i + 1;
	        for (int i = 0; i < n; i++) {
	            for (int c = 0; c < 26; c++) {
	                if (ch[i][c] == 0)
	                    ch[i][c] = ch[fail[i]][c];
	            }
	        }
	    }

	    static int dfs(int i, int j, int k) {
	        if (vis[i][j][k] == true)
	            return dp[i][j][k];
	        vis[i][j][k] = true;
	        if (k >= n)
	            return dp[i][j][k] = -999999999;
	        if (i >= x || j >= y)
	            return dp[i][j][k] = 0;

	        dp[i][j][k] = Math.max(dfs(i + 1, j, k), dfs(i, j + 1, k));

	        if (s1.charAt(i) == s2.charAt(j)) {
	            dp[i][j][k] = Math.max(dp[i][j][k], dfs(i + 1, j + 1, ch[k][s1.charAt(i) - 'A']) + 1);
	        }

	        return dp[i][j][k];
	    }

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

	        s1 = in.next().trim();
	        s2 = in.next().trim();
	        virus = in.next().trim();

	        x = s1.length();
	        y = s2.length();
	        n = virus.length();
	        init();

	        if (dfs(0, 0, 0) != 0) {
	            int i = 0, j = 0, k = 0;
	            String ans = "";
	            while (i < x && j < y) {
	                if (dfs(i, j, k) == dfs(i + 1, j, k))
	                    i++;
	                else if (dfs(i, j, k) == dfs(i, j + 1, k))
	                    j++;
	                else {

	                    ans += s1.charAt(i);
	                    k = ch[k][s1.charAt(i) - 'A'];
	                    i++;
	                    j++;
	                }
	            }
	            System.out.println(ans);
	        } else {
	            System.out.println("0");
	        }
	    }
	}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class BB {

    static StringTokenizer st;
    static BufferedReader in;
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int n = nextInt();
        int inc = 0;
        if (n==1e9)
            inc = 1;
        Set<Integer> set = new HashSet<Integer>();
        for (int leng = 1; leng <= 9; leng++) {
            for (int i = 0; i <= 9; i++) {
                for (int j = i+1; j <= 9; j++) {
                    for (int j2 = 0; j2 < (1 << leng); j2++) {
                        int t = 0;
                        for (int k = leng-1; k >= 0; k--) {
                            t = t*10;
                            if ((j2 & (1 << k)) != 0)
                                t += i;
                            else
                                t += j;
                        }
                        if (t <= n && t != 0)
                            set.add(t);
                    }
                }
            }
        }
        System.out.println(set.size()+inc);
        pw.close();
    }
    private static int nextInt() throws IOException{
        return Integer.parseInt(next());
    }

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

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

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


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Comparator;
import java.util.Collections;
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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Graph solver = new Graph();
        solver.solve(1, in, out);
        out.close();
    }

    static class Graph {
        ArrayList<Edge>[] edges;
        ArrayList<Integer> component = new ArrayList<>();
        int need;
        Function[] functions;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int M = in.nextInt();
            functions = new Function[N];
            edges = new ArrayList[N];
            for (int i = 0; i < N; i++) {
                edges[i] = new ArrayList<>();
            }
            for (int i = 0; i < M; i++) {
                int a = in.nextInt() - 1;
                int b = in.nextInt() - 1;
                int c = in.nextInt() * 2;
                edges[a].add(new Edge(b, c));
                edges[b].add(new Edge(a, c));
            }
            ArrayList<Integer> necessary = new ArrayList<>();
            int[] ans = new int[N];
            for (int i = 0; i < N; i++) {
                if (functions[i] == null) {
                    component.clear();
                    need = Integer.MAX_VALUE;
                    functions[i] = new Function(1, 0);
                    dfs(i);
                    int x;
                    if (need == Integer.MIN_VALUE) {
                        out.println("NO");
                        return;
                    } else if (need == Integer.MAX_VALUE) {
                        Collections.sort(component, new Comparator<Integer>() {

                            public int compare(Integer integer, Integer t1) {
                                return Integer.compare(functions[integer].x * functions[integer].c, functions[t1].x * functions[t1].c);
                            }
                        });
                        x = -functions[component.get(component.size() / 2)].x * functions[component.get(component.size() / 2)].c;
                    } else {
                        x = need;
                    }
                    for (int j : component) {
                        ans[j] = functions[j].x * x + functions[j].c;
                    }
                }
            }
            out.println("YES");
            for (int i : ans) {
                out.println((double) (i) / 2);
            }
        }

        void dfs(int n) {
            component.add(n);
            for (Edge e : edges[n]) {
                if (functions[e.to] == null) {
                    functions[e.to] = functions[n].subtract(e.c);
                    dfs(e.to);
                } else {
                    int res = functions[n].is(functions[e.to], e.c);
                    if (res == Integer.MIN_VALUE) {
                        need = Integer.MIN_VALUE;
                    } else if (res != Integer.MAX_VALUE) {
                        if (need != Integer.MAX_VALUE && need != res) {
                            need = Integer.MIN_VALUE;
                        } else {
                            need = res;
                        }
                    }
                }
            }
        }

        class Function {
            int x;
            int c;

            Function(int x, int c) {
                this.x = x;
                this.c = c;
            }

            Function subtract(int c) {
                return new Function(-x, c - this.c);
            }

            int is(Function f, int c) {
                if (f.x == this.x) {
                    return (c - f.c - this.c) / (2 * f.x);
                }
                if (f.x != this.x && (this.c + f.c) != c) {
                    return Integer.MIN_VALUE;
                }
                return Integer.MAX_VALUE;
            }

        }

        class Edge {
            int to;
            int c;

            Edge(int to, int c) {
                this.to = to;
                this.c = c;
            }

        }

    }

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

    }
}