#include <bits/stdc++.h>
using namespace std;
int T, n, m, s, n1, m1, n2, m2, pw[20];
int diff(int x, int y) {
  if (x > y) swap(x, y);
  static int st1[20], st2[20];
  int tp1 = 0, tp2 = 0, ret = 0;
  while (x) st1[++tp1] = x % 10, x /= 10;
  while (y) st2[++tp2] = y % 10, y /= 10;
  for (int i = 1; i <= tp1; i++)
    if (st1[i] != st2[i]) ++ret;
  for (int i = tp1 + 1; i <= tp2; i++)
    if (st2[i] != 0) ++ret;
  return ret;
}
int sum(int x, int lim) {
  if (lim <= 1) return x;
  --lim;
  static int st[20];
  int tp = 0;
  while (x) st[++tp] = x % 10, x /= 10;
  int ret = 0;
  for (int i = tp; i > lim; i--) {
    ret += pw[i - lim - 1] * st[i];
  }
  return ret;
}
long long cal(int n1, int m1, int n2, int m2) {
  if (n1 == n2 && m1 == m2) return 0;
  if (n1 == n2) return sum(m2, s) - sum(m1, s);
  long long ret = sum(m - 1, s) - sum(m1, s);
  if (n1 != n2) ret += 1ll * ((n2 - 1) - (n1 + 1) + 1) * sum(m - 1, s);
  ret += sum(m2, s);
  int d = diff(m - 1, 0);
  ret += sum(n2, s - d) - sum(n1, s - d);
  return ret;
}
int main() {
  cin >> n >> m >> s >> n1 >> m1 >> n2 >> m2;
  pw[0] = 1;
  for (int i = 1; i < 10; i++) pw[i] = 10 * pw[i - 1];
  if (make_pair(n1, m1) <= make_pair(n2, m2))
    cout << cal(n1, m1, n2, m2);
  else
    cout << cal(n1, m1, n - 1, m - 1) + (diff(n - 1, 0) + diff(m - 1, 0) >= s) +
                cal(0, 0, n2, m2);
  return 0;
}
