/**
 *    author:  tourist
 *    created: 28.06.2020 20:40:16       
**/
#undef _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

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

const int di[4] = {-1, 0, 1, 0};
const int dj[4] = {0, -1, 0, 1};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, k;
  cin >> h >> w >> k;
  int xa, ya, xb, yb;
  cin >> xa >> ya >> xb >> yb;
  --xa; --ya; --xb; --yb;
  vector<string> s(h);
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }
  vector<vector<vector<pair<int, int>>>> dist(h, vector<vector<pair<int, int>>>(w, vector<pair<int, int>>(4, make_pair((int) 2e9, -1))));
  vector<vector<vector<bool>>> inq(h, vector<vector<bool>>(w, vector<bool>(4)));
  vector<tuple<int, int, int>> que;
  for (int dir = 0; dir < 4; dir++) {
    que.emplace_back(xa, ya, dir);
    dist[xa][ya][dir] = make_pair(1, -k);
    inq[xa][ya][dir] = true;
  }
  for (int b = 0; b < (int) que.size(); b++) {
    int i = get<0>(que[b]);
    int j = get<1>(que[b]);
    int dir = get<2>(que[b]);
//    debug(i, j, dir);
    inq[i][j][dir] = false;
    {
      auto cur = dist[i][j][dir];
      if (cur.second == 0) {
        cur.first += 1;
        cur.second = -k;
      }
      cur.second += 1;
      int ni = i + di[dir];
      int nj = j + dj[dir];
      if (ni >= 0 && nj >= 0 && ni < h && nj < w && s[ni][nj] == '.') {
        if (cur < dist[ni][nj][dir]) {
          dist[ni][nj][dir] = cur;
          if (!inq[ni][nj][dir]) {
            inq[ni][nj][dir] = true;
            que.emplace_back(ni, nj, dir);
          }
        }
      }
    }
    for (int ndir = 0; ndir < 4; ndir++) {
      auto cur = dist[i][j][dir];
      cur.first += 1;
      cur.second = -k;
      if (cur < dist[i][j][ndir]) {
        dist[i][j][ndir] = cur;
        if (!inq[i][j][ndir]) {
          inq[i][j][ndir] = true;
          que.emplace_back(i, j, ndir);
        }
      }
    }
  }
  pair<int, int> ans = make_pair((int) 1e9, -1);
  for (int dir = 0; dir < 4; dir++) {
    ans = min(ans, dist[xb][yb][dir]);
  }
  if (ans.first == (int) 1e9) {
    cout << -1 << '\n';
  } else {
    cout << ans.first << '\n';
  }
  return 0;
}


Measured memory_bytes: 533708