#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline T1 min(T1 a, T2 b) {
  return a < b ? a : b;
}
template <typename T1, typename T2>
inline T1 max(T1 a, T2 b) {
  return b < a ? a : b;
}
namespace ae86 {
const int bufl = 1 << 15;
char buf[bufl], *s = buf, *t = buf;
inline int fetch() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, bufl, stdin);
    if (s == t) return EOF;
  }
  return *s++;
}
inline long long ty() {
  long long a = 0;
  int b = 1, c = fetch();
  while (!isdigit(c)) b ^= c == '-', c = fetch();
  while (isdigit(c)) a = a * 10 + c - 48, c = fetch();
  return b ? a : -a;
}
}  // namespace ae86
using ae86::ty;
long long hv, mv;
inline long long cut(long long a, int x) {
  while (--x > 0 && a) a /= 10;
  return a;
}
inline int cntnot0(long long a) {
  int ret = 0;
  while (a) {
    if (a % 10) ret++;
    a /= 10;
  }
  return ret;
}
int tar;
inline long long finder(long long h, long long m) {
  return cut(h, tar - cntnot0(mv - 1)) + cut(m, tar) + cut(mv - 1, tar) * h;
}
int main() {
  hv = ty(), mv = ty(), tar = ty();
  long long hl = ty(), ml = ty(), hr = ty(), mr = ty();
  long long ans = finder(hr, mr) - finder(hl, ml);
  if (hr < hl || (hr == hl && mr < ml))
    ans += finder(hv - 1, mv - 1) + (cntnot0(hv - 1) + cntnot0(mv - 1) >= tar);
  printf("%lld\n", ans);
  return 0;
}
