#include <bits/stdc++.h>

using namespace std;

int H, W, K;

int V(int x, int y) { return y * W + x; }

struct Hand {
  int x, y, v, t;
  Hand(int x_, int y_, int v_, int t_) : x(x_), y(y_), v(v_), t(t_) {}
};

const int L = 0;
const int R = 1;
const int U = 2;
const int D = 3;

int main() {
  cin >> H >> W >> K;
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  x1--;
  y1--;
  x2--;
  y2--;
  swap(x1, y1);
  swap(x2, y2);
  vector<string> C(H);
  for (int i = 0; i < H; i++) {
    cin >> C[i];
  }

  vector<vector<int>> turns(H * W, vector<int>(4, numeric_limits<int>::max()));
  vector<int> T(H * W, numeric_limits<int>::max());
  queue<Hand> q;
  int v0 = V(x1, y1);
  q.push(Hand{x1, y1, v0, 0});
  turns[v0][0] = 0;
  turns[v0][1] = 0;
  turns[v0][2] = 0;
  turns[v0][3] = 0;
  T[v0] = 0;

  vector<vector<int>> max_moves(H * W, vector<int>(4, 0));
  {
    // left
    for (int y = 0; y < H; y++) {
      for (int x = 0; x < W; x++) {
        int v = V(x, y);
        if (x == 0 || C[y][x - 1] == '@') {
          max_moves[v][L] = 0;
        } else {
          int v2 = V(x - 1, y);
          max_moves[v][L] = min(K, max_moves[v2][L] + 1);
        }
      }
    }
    // right
    for (int y = 0; y < H; y++) {
      for (int x = W - 1; x >= 0; x--) {
        int v = V(x, y);
        if (x == W - 1 || C[y][x + 1] == '@') {
          max_moves[v][R] = 0;
        } else {
          int v2 = V(x + 1, y);
          max_moves[v][R] = min(K, max_moves[v2][R] + 1);
        }
      }
    }
    // up
    for (int y = 0; y < H; y++) {
      for (int x = 0; x < W; x++) {
        int v = V(x, y);
        if (y == 0 || C[y - 1][x] == '@') {
          max_moves[v][U] = 0;
        } else {
          int v2 = V(x, y - 1);
          max_moves[v][U] = min(K, max_moves[v2][U] + 1);
        }
      }
    }
    // down
    for (int y = H - 1; y >= 0; y--) {
      for (int x = 0; x < W; x++) {
        int v = V(x, y);
        if (y == H - 1 || C[y + 1][x] == '@') {
          max_moves[v][D] = 0;
        } else {
          int v2 = V(x, y + 1);
          max_moves[v][D] = min(K, max_moves[v2][D] + 1);
        }
      }
    }
  }

  while (!q.empty()) {
    Hand h = q.front();
    q.pop();

    if (h.x == x2 && h.y == y2) {
      cout << h.t << endl;
      return 0;
    }

    {  // left
      int x2 = max(0, h.x - max_moves[h.v][L]);
      int y2 = h.y;
      for (; x2 < h.x; x2++) {
        int v2 = V(x2, y2);
        if (turns[v2][L] <= h.t) break;
        turns[v2][L] = h.t + 1;
        if (T[v2] > h.t + 1) {
          T[v2] = h.t + 1;
          q.push(Hand{x2, y2, v2, h.t + 1});
        }
      }
    }
    {  // right
      int x2 = min(W - 1, h.x + max_moves[h.v][R]);
      int y2 = h.y;
      for (; x2 > h.x; x2--) {
        int v2 = V(x2, y2);
        if (turns[v2][R] <= h.t) break;
        turns[v2][R] = h.t + 1;
        if (T[v2] > h.t + 1) {
          T[v2] = h.t + 1;
          q.push(Hand{x2, y2, v2, h.t + 1});
        }
      }
    }
    {  // up
      int x2 = h.x;
      int y2 = max(0, h.y - max_moves[h.v][U]);
      for (; y2 < h.y; y2++) {
        int v2 = V(x2, y2);
        if (turns[v2][U] <= h.t) break;
        turns[v2][U] = h.t + 1;
        if (T[v2] > h.t + 1) {
          T[v2] = h.t + 1;
          q.push(Hand{x2, y2, v2, h.t + 1});
        }
      }
    }
    {  // down
      int x2 = h.x;
      int y2 = min(H - 1, h.y + max_moves[h.v][D]);
      for (; y2 > h.y; y2--) {
        int v2 = V(x2, y2);
        if (turns[v2][D] <= h.t) break;
        turns[v2][D] = h.t + 1;
        if (T[v2] > h.t + 1) {
          T[v2] = h.t + 1;
          q.push(Hand{x2, y2, v2, h.t + 1});
        }
      }
    }
  }

  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 119860