#include <bits/stdc++.h>
using namespace std;
long long t, n, i, j, k, x, y, z, l, r, mid, ans, mod = 1e9 + 7, m, h;
vector<long long> v, u;
long long a[200005], b[200005];
long long ax, bx, ay, by;
string s;
char ch;
map<long long, vector<long long> > mp;
bool ok(long long l, long long r, long long t) {
  return a[r] - a[l] + b[r] - b[l] <= t;
}
long long bs(long long l, long long r, long long t) {
  long long ans = l;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (ok(j, mid, t)) {
      ans = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  return ans;
}
long long bs2(long long l, long long r, long long t) {
  long long ans = r;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (ok(mid, j, t)) {
      ans = mid;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(NULL);
  cin.tie(0);
  cout.tie(0);
  cin >> a[0] >> b[0] >> ax >> ay >> bx >> by >> x >> y >> t;
  while (abs(a[i] * ax + bx - a[i]) + abs(b[i] * ay + by - b[i]) <= 5e16) {
    i++;
    a[i] = a[i - 1] * ax + bx;
    b[i] = b[i - 1] * ay + by;
  }
  for (j = 0; j <= i; j++)
    if (abs(a[j] - x) + abs(b[j] - y) <= t) {
      ans = max(ans, bs(j, i, t - abs(a[j] - x) - abs(b[j] - y)) - j + 1);
    }
  for (j = i; j >= 0; j--)
    if (abs(a[j] - x) + abs(b[j] - y) <= t) {
      ans = max(ans, j + 1 - bs2(0, j, t - abs(a[j] - x) - abs(b[j] - y)));
    }
  cout << ans;
}
