#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x0, y0, ax, ay, bx, by;
  cin >> x0 >> y0 >> ax >> ay >> bx >> by;
  long long xs, ys, t;
  cin >> xs >> ys >> t;
  if (ax == 1 && ay == 1) {
    cout << -1;
    return 0;
  }
  vector<pair<long long, long long> > d;
  long long curx = x0, cury = y0;
  for (; curx <= 2e16 && cury <= 2e16;) {
    d.push_back({curx, cury});
    curx = curx * ax + bx;
    cury = cury * ay + by;
  }
  int n = d.size();
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long cnt = 0;
    long long temp = t - abs(d[i].first - xs) - abs(d[i].second - ys);
    for (int j = i + 1; j < n; j++) {
      if (temp >= 0ll)
        cnt++;
      else
        break;
      temp -=
          abs(d[j].first - d[j - 1].first) + abs(d[j].second - d[j - 1].second);
    }
    if (temp >= 0) cnt++;
    ans = max(cnt, ans);
    temp = t - abs(d[i].first - xs) - abs(d[i].second - ys);
    cnt = 0;
    for (int j = i - 1; j >= 0; j--) {
      if (temp >= 0ll)
        cnt++;
      else
        break;
      temp -=
          abs(d[j + 1].first - d[j].first) + abs(d[j + 1].second - d[j].second);
    }
    if (temp >= 0) cnt++;
    ans = max(cnt, ans);
  }
  cout << ans << endl;
  cin >> n;
}
