#include <iostream>
#include <algorithm>
#include <utility>
#include <numeric>
#include <vector>
#include <array>

#include <tuple>
#include <queue>

template <class T, size_t N, size_t I = 0>
decltype(auto) gen_vec(const size_t (&list)[N], typename std::enable_if<(I == N), const T&>::type value = T()) { 
  return value; 
}

template <class T, size_t N, size_t I = 0>
decltype(auto) gen_vec(const size_t (&list)[N], typename std::enable_if<(I != N), const T&>::type value = T()) { 
  return std::vector(list[I], gen_vec<T, N, I + 1>(list, value)); 
}

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

constexpr i32 inf32 = (i32(1) << 30) - 1;
constexpr i64 inf64 = (i64(1) << 62) - 1;

constexpr i32 dx[] = { 1, 0, -1, 0 };
constexpr i32 dy[] = { 0, 1, 0, -1 };


#ifdef LOCAL
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <ctime>

struct debug_support {

  std::ofstream file;
  std::stringstream to_str_helper;
  clock_t start_time;
  size_t str_width;

  debug_support() {
    file.open("debug.txt");
    if (!file.is_open()) {
      std::cerr << "\033[31m failed to open the file 'debug.txt' \033[0m \n";
      std::exit(EXIT_FAILURE);
    }
    file << "\n<debug output file>\n\n";
    to_str_helper << std::boolalpha;
    to_str_helper << std::fixed;
    setwidth(3);
    setprecision(6);
    settime();
  }
  ~debug_support() {
    file.close(); 
  }

  void setwidth(size_t x) {
    str_width = x;
  }
  void setprecision(size_t x) {
    to_str_helper << std::setprecision(x);
  }
  void settime() {
    start_time = std::clock();
  }

  std::string to_str(char c) { 
    return std::string("'") + c + "'"; 
  }
  std::string to_str(const std::string &s) { 
    return std::string("\"") + s + "\""; 
  }
  std::string to_str(const char *s) { 
    return std::string("\"") + s + "\""; 
  }

  template <class T, class U>
  std::string to_str(const std::pair<T, U> &x) { 
    return "(" + to_str(x.first) + ", " + to_str(x.second) + ")"; 
  }
  template <class T, size_t I>
  typename std::enable_if<(I + 1 == std::tuple_size<T>::value), std::string>::type to_str_tuple(const T &x) { 
    return to_str(std::get<I>(x)); 
  } 
  template <class T, size_t I>
  typename std::enable_if<(I + 1 != std::tuple_size<T>::value), std::string>::type to_str_tuple(const T &x) { 
    return to_str(std::get<I>(x)) + ", " + to_str_tuple<T, I + 1>(x);
  } 
  template <class... Args>
  std::string to_str(const std::tuple<Args...> &x) {
    return "(" + to_str_tuple<std::tuple<Args...>, 0>(x) + ")";
  }

  template <class T>
  std::string to_str(const T &x) {
    to_str_helper << x;
    std::string s;
    std::getline(to_str_helper, s);
    to_str_helper.str("");
    to_str_helper.clear(std::stringstream::goodbit);
    return s;
  }
  template <class T, class U, class... Args>
  std::string to_str(const T &x, const U &y, const Args&... args) { 
    return x == y ? "__" : to_str(x, args...); 
  }

  std::string fix_str(const std::string &s) {
    if (s.size() >= str_width) return s;
    return std::string(str_width - s.size(), ' ') + s;
  }

  template<typename T, typename _ = void>
  struct has_iterator: public std::false_type {};
  template<typename T>
  struct has_iterator<T, typename std::conditional<false, typename T::iterator, void>::type>: public std::true_type {};

  template <class T, class... Args>
  typename std::enable_if<has_iterator<typename T::value_type>::value == true, std::string>::type 
  to_str_container(const T &x, const Args&... args) {
    std::string s;
    for (const auto &v: x) {
      s += to_str_container(v, args...);
    }
    return s + '\n';
  }
  template <class T, class... Args>
  typename std::enable_if<has_iterator<typename T::value_type>::value == false, std::string>::type 
  to_str_container(const T &x, const Args&... args) {
    std::string s = "{ ";
    bool f = false;
    for (const auto &v: x) {
      if (f) s += ", ";
      f = true;
      s += fix_str(to_str(v, args...));
    }
    return s + " }\n";
  }

  template <class T>
  void print(const T &x) { 
    file << to_str(x) << std::endl;
  }
  template <class T, class... Args>
  void print(const T &x, const Args&... args) {
    file << to_str(x) << ", ";
    print(args...);
  }

  template <class T, class... Args>
  void print_container(const T &x, const Args&... args) {
    file << to_str_container(x, args...) << std::endl;
    setwidth(3);
  }

} debugger;

#define show(...)\
  do {\
    debugger.file << "<line:" << std::setw(4) << __LINE__ << ">";\
    debugger.file << " [" << #__VA_ARGS__ << "]: ";\
    debugger.print(__VA_ARGS__);\
  } while (false)

#define show_c(x, ...)\
 do {\
    debugger.file << "\n<line:" << std::setw(4) << __LINE__ << ">";\
    debugger.file << " [" << #x << "]";\
    if (std::string(#__VA_ARGS__).empty()) debugger.file << ":\n";\
    else debugger.file << " (ignore " << #__VA_ARGS__ << "):\n";\
    debugger.print_container(x __VA_OPT__(,) __VA_ARGS__);\
 } while (false)

#define show_e()\
  do {\
    double d = static_cast<double>(std::clock() - debugger.start_time);\
    debugger.file << "<line:" << std::setw(4) << __LINE__ << ">";\
    debugger.file << " elapsed time: " << d * 1000 / CLOCKS_PER_SEC << "ms" << std::endl;\
  } while (false)

#else
#define show(...) ((void) 0)
#define show_c(...) ((void) 0)
#define show_e() ((void) 0)
#endif


int main() {
  i32 H, W, K;
  std::cin >> H >> W >> K;
  i32 x1, y1, x2, y2;
  std::cin >> x1 >> y1 >> x2 >> y2;
  auto water = gen_vec<bool>({ H + 2, W + 2 });
  for (i32 i = 1; i <= H; ++i) {
    for (i32 j = 1; j <= W; ++j) {
      char c;
      std::cin >> c;
      water[i][j] = (c == '.');
    }
  }
  auto dist = gen_vec<std::pair<i32, i32>>({ H + 2, W + 2, 4 }, std::make_pair(inf32, inf32));
  using state = std::tuple<i32, i32, i32, i32, i32>;
  std::priority_queue<state, std::vector<state>, std::greater<state>> que;
  auto push = [&](i32 d, i32 r, i32 x, i32 y, i32 k) {
    if (!water[x][y]) {
      return;
    }
    if (dist[x][y][k] > std::make_pair(d, r)) {
      dist[x][y][k] = std::make_pair(d, r);
      que.emplace(d, r, x, y, k);
    }
  };
  for (i32 k = 0; k < 4; ++k) {
    push(0, 0, x1, y1, k);
  }
  while (!que.empty()) {
    auto [d, r, x, y, t] = que.top();
    show(x, y, t, d, r);
    que.pop();
    if (std::make_pair(d, r) > dist[x][y][t]) {
      continue;
    }
    if (r < 0) {
      push(d, r + 1, x + dx[t], y + dy[t], t);
    }
    for (i32 k = 0; k < 4; ++k) {
      push(d + 1, -(K - 1), x + dx[k], y + dy[k], k);
    }
  }
  std::pair<i32, i32> ans(inf32, inf32);
  for (i32 k = 0; k < 4; ++k) {
    if (ans > dist[x2][y2][k]) {
      ans = dist[x2][y2][k];
    }
  }
  if (ans.first == inf32) {
    std::cout << "-1\n";
  }
  else {
    std::cout << ans.first << '\n';
  }
  return 0;
}


Measured memory_bytes: 284888