/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class FPondSkater {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll h, w, k; cin >> h >> w >> k;
      int x1, x2, y1, y2;
      cin >> x1 >> y1 >> x2 >> y2;
      x1--; x2--; y1--; y2--;
      vector<vector<bool>> mat(h, vector<bool>(w));
      rep(i, h) rep(j, w) {
        char c; cin >> c;
        mat[i][j] = (c == '.');
      }

      vector<vector<int>> cost(h, vector<int>(w, INT_MAX/2));

      set<int> row[h];
      set<int> col[w];
      rep(i, h) {
        rep(j, w) {
          row[i].insert(j);
          col[j].insert(i);
        }
      }


      cost[x1][y1] = 0;

      deque<P> que;
      que.emplace_back(x1, y1);
      row[x1].erase(y1);
      col[y1].erase(x1);
      while(!que.empty()) {
        auto pa = que.front(); que.pop_front();
        auto x = pa.first;
        auto y = pa.second;
        auto c = cost[x][y];

        auto it = row[x].lower_bound(y);
        while(it != row[x].end() && (*it) <= y+k && mat[x][(*it)]) {
          int ya = (*it);
          cost[x][ya] = c + 1;
          debug(x, y, ya, c);
          que.emplace_back(x, ya);
          col[ya].erase(x);
          it = row[x].erase(it);
        }

        it = row[x].lower_bound(y);
        while(it != row[x].begin()) {
          it--;
          if ((*it) >= y-k && mat[x][(*it)]) {
            int ya = (*it);
            cost[x][ya] = c + 1;
            debug(x, y, ya, c);
            que.emplace_back(x, ya);
            col[ya].erase(x);
            it = row[x].erase(it);
          } else {
            break;
          }
        }

        it = col[y].lower_bound(x);
        while(it != col[y].end() && (*it) <= x+k && mat[(*it)][y]) {
          int xa = *it;
          cost[xa][y] = c+1;
          debug(x, y, xa, c);
          que.emplace_back(xa, y);
          row[xa].erase(y);
          it = col[y].erase(it);
        }

        it = col[y].lower_bound(x);
        while(it != col[y].begin()) {
          it--;
          debug(x, y, *it);
          if ((*it) >= x-k && mat[*it][y]) {
            int xa = *it;
            cost[xa][y] = c+1;
            debug(x, y, xa, c);
            que.emplace_back(xa, y);
            row[xa].erase(y);
            it = col[y].erase(it);
          } else {
            break;
          }
        }
      }

      if (cost[x2][y2] == INT_MAX/2) {
        cout << -1 << endl;
      } else {
        cout << cost[x2][y2] << endl;
      }
    }
};

signed main() {
  FPondSkater solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 148008