[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu)

[KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives)

With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space.

The space can be considered a 2D plane, with an infinite number of data nodes, indexed from 0, with their coordinates defined as follows:

  * The coordinates of the 0-th node is (x_0, y_0) 
  * For i > 0, the coordinates of i-th node is (a_x ⋅ x_{i-1} + b_x, a_y ⋅ y_{i-1} + b_y) 



Initially Aroma stands at the point (x_s, y_s). She can stay in OS space for at most t seconds, because after this time she has to warp back to the real world. She doesn't need to return to the entry point (x_s, y_s) to warp home.

While within the OS space, Aroma can do the following actions:

  * From the point (x, y), Aroma can move to one of the following points: (x-1, y), (x+1, y), (x, y-1) or (x, y+1). This action requires 1 second. 
  * If there is a data node at where Aroma is staying, she can collect it. We can assume this action costs 0 seconds. Of course, each data node can be collected at most once. 



Aroma wants to collect as many data as possible before warping back. Can you help her in calculating the maximum number of data nodes she could collect within t seconds?

Input

The first line contains integers x_0, y_0, a_x, a_y, b_x, b_y (1 ≤ x_0, y_0 ≤ 10^{16}, 2 ≤ a_x, a_y ≤ 100, 0 ≤ b_x, b_y ≤ 10^{16}), which define the coordinates of the data nodes.

The second line contains integers x_s, y_s, t (1 ≤ x_s, y_s, t ≤ 10^{16}) – the initial Aroma's coordinates and the amount of time available.

Output

Print a single integer — the maximum number of data nodes Aroma can collect within t seconds.

Examples

Input


1 1 2 3 1 0
2 4 20


Output


3

Input


1 1 2 3 1 0
15 27 26


Output


2

Input


1 1 2 3 1 0
2 2 1


Output


0

Note

In all three examples, the coordinates of the first 5 data nodes are (1, 1), (3, 3), (7, 9), (15, 27) and (31, 81) (remember that nodes are numbered from 0).

In the first example, the optimal route to collect 3 nodes is as follows: 

  * Go to the coordinates (3, 3) and collect the 1-st node. This takes |3 - 2| + |3 - 4| = 2 seconds. 
  * Go to the coordinates (1, 1) and collect the 0-th node. This takes |1 - 3| + |1 - 3| = 4 seconds. 
  * Go to the coordinates (7, 9) and collect the 2-nd node. This takes |7 - 1| + |9 - 1| = 14 seconds. 



In the second example, the optimal route to collect 2 nodes is as follows: 

  * Collect the 3-rd node. This requires no seconds. 
  * Go to the coordinates (7, 9) and collect the 2-th node. This takes |15 - 7| + |27 - 9| = 26 seconds. 



In the third example, Aroma can't collect any nodes. She should have taken proper rest instead of rushing into the OS space like that.
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class test {
    final static int MOD = 1000000007;
    final static int intMax = 1000000000;
    final static int intMin = -1000000000;
    final static int[] dx = { 0, 0, -1, 1 };
    final static int[] dy = { -1, 1, 0, 0 };

    static int add(int a, int b) {
        return (a + b) % MOD;
    }

    static int sub(int a, int b) {
        return (a - b + MOD) % MOD;
    }

    static int mult(int a, int b) {
        return (int)((((long)(a)) * b) % MOD);
    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader() {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException {
            byte[] buf = new byte[360]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

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

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

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException {
            if (din == null)
                return;
            din.close();
        }
    }

    static class Sb_Output implements Closeable, Flushable{
        StringBuilder sb;
        OutputStream os;
        int BUFFER_SIZE;
        public Sb_Output(String s) throws Exception {
            os = new BufferedOutputStream(new FileOutputStream(new File(s)));
            BUFFER_SIZE = 1 << 16;
            sb = new StringBuilder(BUFFER_SIZE);
        }
        public void print(String s) {
            sb.append(s);
            if(sb.length() >= (BUFFER_SIZE>>1)) {
                flush();
            }
        }
        public void println(String s) {
            print(s);
            print("\n");
        }
        public void println(int i) {
            println("" + i);
        }
        public void println(long i) {
            println("" + i);
        }
        public void flush() {
            try {
                os.write(sb.toString().getBytes());
                sb = new StringBuilder(BUFFER_SIZE);
            }catch(IOException e) {
                e.printStackTrace();
            }
        }
        public void close() {
            flush();
            try {
                os.close();
            }catch(IOException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) throws Exception {
        Reader in = new Reader();
//		Reader in = new Reader("poetry.in");
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//        BufferedReader br = new BufferedReader(new FileReader("poetry.in"));
        StringTokenizer st = new StringTokenizer(br.readLine());
        long x0 = Long.parseLong(st.nextToken());
        long y0 = Long.parseLong(st.nextToken());
        long ax = Long.parseLong(st.nextToken());
        long ay = Long.parseLong(st.nextToken());
        long bx = Long.parseLong(st.nextToken());
        long by = Long.parseLong(st.nextToken());
        st = new StringTokenizer(br.readLine());
        long xs = Long.parseLong(st.nextToken());
        long ys = Long.parseLong(st.nextToken());
        long t = Long.parseLong(st.nextToken());
        ArrayList<pair> points = new ArrayList<pair>();
        long curx = x0, cury = y0;
        points.add(new pair(curx, cury));
        while(true){
            if(curx > 100000000000000000L / ax || cury > 100000000000000000L / ay) break;
            curx *= ax;
            cury *= ay;
            if(curx > 100000000000000000L - bx || cury > 100000000000000000L - by) break;
            curx += bx;
            cury += by;
            points.add(new pair(curx, cury));
        }/*
        for(pair i : points){
            System.out.println(i.x + " " + i.y);
        }*/
        int sz = points.size();
        int mx = 0;
        for(int i = 0; i < sz; ++i) {
            int cur = 0;
            long curt = t - Math.abs(xs - points.get(i).x) - Math.abs(ys - points.get(i).y);
            if(curt < 0) continue;
            //if(i == 0) System.out.println(curt);
            ++cur;
            curx = points.get(i).x;
            cury = points.get(i).y;
            for(int j = i - 1; j >= 0 && curt > 0; --j) {
                if(curt - Math.abs(curx - points.get(j).x) - Math.abs(cury - points.get(j).y) < 0) break;
                curt -= Math.abs(curx - points.get(j).x) + Math.abs(cury - points.get(j).y);
                curx = points.get(j).x;
                cury = points.get(j).y;
                ++cur;
            }
            for(int j = i + 1; j < sz; ++j){
                if(curt - Math.abs(curx - points.get(j).x) - Math.abs(cury - points.get(j).y) < 0) break;
                curt -= Math.abs(curx - points.get(j).x) + Math.abs(cury - points.get(j).y);
                curx = points.get(j).x;
                cury = points.get(j).y;
                ++cur;
            }
            //System.out.println(cur);
            mx = max(mx, cur);
        }
        System.out.println(mx);
        in.close();
        //out.close();
    }
    static class pair{
        long x, y;
        pair(long a, long b) {
            x = a; y = b;
        }
    }
}