#include <bits/stdc++.h>
using namespace std;
const int size1 = 4e5 + 500;
const long long mod = 1000 * 1000 * 1000 + 7;
long long sq(long long x, long long y, long long x1, long long y1) {
  return abs(x - x1) + abs(y - y1);
}
const long long INF = 20000LL * 10000 * 10000 * 10000 + 1000;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long x0, y0, ax, ay, bx, by, xs, ys, t;
  cin >> x0 >> y0 >> ax >> ay >> bx >> by >> xs >> ys >> t;
  long long x = x0, y = y0;
  vector<pair<long long, long long>> v;
  while (x < INF && y < INF) {
    v.push_back({x, y});
    x = x * ax + bx;
    y = y * ay + by;
  }
  int n = v.size();
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int l = 0; l <= i; ++l) {
      for (int r = i; r < n; ++r) {
        int cnt = 0;
        long long ras = t;
        long long curx = xs, cury = ys;
        bool res = true;
        ras -= sq(xs, ys, v[i].first, v[i].second);
        if (ras < 0) {
          res = false;
          continue;
        }
        ++cnt;
        long long fst = ras;
        long long sec = ras;
        for (int k = i + 1; k <= r; ++k) {
          fst -= sq(v[k - 1].first, v[k - 1].second, v[k].first, v[k].second);
          if (fst < 0) {
            res = false;
            break;
          }
        }
        if (res && l == i) {
          ans = max(ans, r - i + 1);
          continue;
        }
        if (l <= i - 1 && res) {
          fst -= sq(v[r].first, v[r].second, v[i - 1].first, v[i - 1].second);
          if (fst < 0) {
            res = false;
          }
          for (int k = i - 1; k >= l + 1; --k) {
            fst -= sq(v[k - 1].first, v[k - 1].second, v[k].first, v[k].second);
            if (fst < 0) {
              res = false;
              break;
            }
          }
          if (res) {
            ans = max(ans, r - l + 1);
            continue;
          }
        }
        res = true;
        for (int k = i - 1; k >= l; --k) {
          sec -= sq(v[k + 1].first, v[k + 1].second, v[k].first, v[k].second);
          if (sec < 0) {
            res = false;
            break;
          }
        }
        if (res && r == i) {
          ans = max(ans, i - l + 1);
          continue;
        }
        if (r >= i + 1 && res) {
          sec -= sq(v[l].first, v[l].second, v[i + 1].first, v[i + 1].second);
          if (sec < 0) {
            res = false;
          }
          for (int k = i + 1; k <= r - 1; ++k) {
            sec -= sq(v[k + 1].first, v[k + 1].second, v[k].first, v[k].second);
            if (sec < 0) {
              res = false;
              break;
            }
          }
          if (res) {
            ans = max(ans, r - l + 1);
            continue;
          }
        }
      }
    }
  }
  cout << ans;
  return 0;
}
