#include using namespace std; uint8_t d[130000000]; int main() { int l, r, m; cin >> l >> r >> m; for (int i = l; i <= r; ++i) { d[i % m / 8] |= 1 << i % m % 8; } int c = 0; for (int i = 0; i < 130000000; ++i) { for (int j = 0; j < 8; ++j) { if (d[i] << j >> 7) c++; } } cout << c << endl; return 0; }