#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

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

  auto is_in = [&](int x, int y) {
    if (x < 0)
      return false;
    if (x >= H)
      return false;
    if (y < 0)
      return false;
    if (y >= W)
      return false;
    return true;
  };

  int MAXN = 10000000;
  vector<vector<int>> used(H, vector<int>(W, 0));
  vector<vector<vector<int>>> dist(H, vector<vector<int>>(W, vector<int>(4, MAXN)));
  dist[x1][y1][0] = 0;
  queue<PII> qu;
  qu.push(PII(x1, y1));
  used[x1][y1] = false;
  while (!qu.empty())
  {
    auto tp = qu.front();
    int x = tp.first, y = tp.second;
    qu.pop();
    if (used[x][y])
      continue;
    used[x][y] = true;
    int cur = dist[x][y][0];
    for (int i = 0; i < 4; i++)
      chmin(cur, dist[x][y][i]);
    vector<int> dx = {1, -1, 0, 0}, dy = {0, 0, 1, -1};
    for (int j = 0; j < 4; j++)
      for (int i = 1; i <= K; i++)
      {
        int nx = x + i * dx[j];
        int ny = y + i * dy[j];
        if (!is_in(nx, ny))
          break;
        if (dist[nx][ny][0] <= cur)
          break;
        if (dist[nx][ny][1] <= cur)
          break;
        if (dist[nx][ny][2] <= cur)
          break;
        if (dist[nx][ny][3] <= cur)
          break;
        if (dist[nx][ny][j] <= cur + 1)
          break;
        if (field[nx][ny] == '@')
          break;
        dist[nx][ny][j] = cur + 1;
        qu.push(PII(nx, ny));
      }
  }
  int ans = dist[x2][y2][0];
  for (int i = 0; i < 4; i++)
    chmin(ans, dist[x2][y2][i]);

  if (ans == MAXN)
    ans = -1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 117348