#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const long long UP = 1e16 + 5;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
long long x[200], y[200], ax, ay, bx, by;
long long xs, ys, t;
int tot = 0;
long long ABS(long long x) {
  if (x >= 0)
    return x;
  else
    return -x;
}
int work(long long xtmp, long long ytmp, int pos) {
  long long tmp = t;
  int cnt = 0;
  for (int i = pos; i >= 0; i--) {
    if (tmp <= 0) break;
    long long time = ABS(xtmp - x[i]) + ABS(ytmp - y[i]);
    xtmp = x[i], ytmp = y[i];
    tmp -= time;
    if (tmp >= 0)
      cnt++;
    else
      break;
  }
  if (tmp > 0) {
    for (int i = pos + 1; i <= tot; i++) {
      if (tmp <= 0) break;
      long long time = ABS(xtmp - x[i]) + ABS(ytmp - y[i]);
      xtmp = x[i], ytmp = y[i];
      tmp -= time;
      if (tmp >= 0)
        cnt++;
      else
        break;
    }
  }
  return cnt;
}
int main() {
  cin >> x[0] >> y[0] >> ax >> ay >> bx >> by;
  cin >> xs >> ys >> t;
  for (int i = 1;; i++) {
    if (x[i - 1] >= UP || y[i - 1] >= UP) {
      tot = i - 1;
      break;
    }
    x[i] = x[i - 1] * ax + bx;
    y[i] = y[i - 1] * ay + by;
  }
  int pos = -1;
  for (int i = 0; i <= tot - 1; i++) {
    if (xs >= x[i] && xs <= x[i + 1]) {
      pos = i;
      break;
    }
  }
  int ans = 0;
  for (int i = 0; i <= tot; i++) ans = max(work(xs, ys, i), ans);
  cout << ans << endl;
  return 0;
}
