One day Vasya was lying in bed watching his electronic clock to fall asleep quicker.

Vasya lives in a strange country, where days have h hours, and every hour has m minutes. Clock shows time in decimal number system, in format H:M, where the string H always has a fixed length equal to the number of digits in the decimal representation of number h - 1. To achieve this, leading zeros are added if necessary. The string M has a similar format, and its length is always equal to the number of digits in the decimal representation of number m - 1. For example, if h = 17, m = 1000, then time equal to 13 hours and 75 minutes will be displayed as "13:075".

Vasya had been watching the clock from h1 hours m1 minutes to h2 hours m2 minutes inclusive, and then he fell asleep. Now he asks you to count how many times he saw the moment at which at least k digits changed on the clock simultaneously.

For example, when switching 04:19  →  04:20 two digits change. When switching 23:59  →  00:00, four digits change.

Consider that Vasya has been watching the clock for strictly less than one day. Note that the last time Vasya saw on the clock before falling asleep was "h2:m2". That is, Vasya didn't see the moment at which time "h2:m2" switched to the next value.

Input

The first line of the input file contains three space-separated integers h, m and k (2 ≤ h, m ≤ 109, 1 ≤ k ≤ 20). The second line contains space-separated integers h1, m1 (0 ≤ h1 < h, 0 ≤ m1 < m). The third line contains space-separated integers h2, m2 (0 ≤ h2 < h, 0 ≤ m2 < m).

Output

Print a single number — the number of times Vasya saw the moment of changing at least k digits simultaneously.

Please do not use the %lld specificator to read or write 64-bit integers in C++. It is preferred to use the cin stream (also you may use the %I64d specificator).

Examples

Input

5 5 2
4 4
2 1


Output

3


Input

24 60 1
0 0
23 59


Output

1439


Input

24 60 3
23 59
23 59


Output

0

Note

In the first example Vasya will see the following moments of time: 4:4 <image> 0:0  →  0:1  →  0:2  →  0:3  →  0:4 <image> 1:0  →  1:1  →  1:2  →  1:3  →  1:4 <image> 2:0  →  2:1  →  2:2  →  2:3  →  2:4. Double arrow (<image>) marks the sought moments of time (in this example — when Vasya sees two numbers changing simultaneously).

In the second example k = 1. Any switching time can be accepted, since during switching of the clock at least one digit is changed. Total switching equals to 24·60 = 1440, but Vasya have not seen one of them — the switching of 23:59 <image> 00:00.

In the third example Vasya fell asleep immediately after he began to look at the clock, so he did not see any change.
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int DIG = 11;
struct tT {
  int h, m;
} beg, en;
int h, m, k;
void init();
void input();
void work();
long long getans(int hh, int mm);
int getcc(int x, int nk);
int getn0(int x) {
  int cc = 0;
  while (x) {
    if (x % 10) ++cc;
    x /= 10;
  }
  return cc;
}
string tos(int a) {
  string s;
  for (int i = 0; i < DIG; ++i) {
    s = static_cast<char>(a % 10 + '0') + s;
    a /= 10;
  }
  return s;
}
int main() {
  init();
  input();
  work();
}
void init() { ios::sync_with_stdio(false); }
void input() {
  scanf("%d%d%d", &h, &m, &k);
  scanf("%d%d", &beg.h, &beg.m);
  scanf("%d%d", &en.h, &en.m);
}
void work() {
  long long ans = getans(en.h, en.m) - getans(beg.h, beg.m);
  if (en.h < beg.h || (en.h == beg.h && en.m < beg.m)) {
    ans += getans(h - 1, m - 1);
    if (getn0(h - 1) + getn0(m - 1) >= k) ++ans;
  }
  printf("%I64d\n", ans);
}
long long getans(int hh, int mm) {
  return (1LL * hh * getcc(m - 1, k) + getcc(mm, k) +
          getcc(hh, (((k - getn0(m - 1)) > (1)) ? (k - getn0(m - 1)) : (1))));
}
int getcc(int x, int nk) {
  int ans = 0, bs = 0;
  string nx = tos(x);
  for (int i = 0; i < DIG; ++i) {
    bs *= 10;
    bs += nx[i] - '0';
    if (DIG - i == nk) ans = bs;
  }
  return ans;
}
