#include <bits/stdc++.h>
using namespace std;
const unsigned long long inf = 1e17;
vector<pair<unsigned long long, unsigned long long> > toc;
inline unsigned long long dist(pair<unsigned long long, unsigned long long> a,
                               pair<unsigned long long, unsigned long long> b) {
  unsigned long long pr;
  if (a.first > b.first) {
    pr = a.first - b.first;
  } else {
    pr = b.first - a.first;
  }
  if (a.second > b.second) {
    pr += a.second - b.second;
  } else {
    pr += b.second - a.second;
  }
  return pr;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  unsigned long long x, y, a1, a2, b1, b2;
  cin >> x >> y >> a1 >> a2 >> b1 >> b2;
  unsigned long long po1, po2, lim;
  cin >> po1 >> po2 >> lim;
  while (x < inf && y < inf) {
    toc.push_back({x, y});
    x = x * a1 + b1;
    y = y * a2 + b2;
  }
  int n = toc.size();
  int sol = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      if (dist({po1, po2}, toc[i]) + dist(toc[i], toc[j]) <= lim) {
        sol = max(sol, j - i + 1);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = i; j > -1; j--) {
      if (dist({po1, po2}, toc[i]) + dist(toc[i], toc[j]) <= lim) {
        sol = max(sol, i - j + 1);
      }
    }
  }
  cout << sol << '\n';
  return 0;
}
