#include using namespace std; int main() { int L, R, M; cin >> L >> R >> M; set s; for (int i = L; i <= R; i++) { s.insert(i % M); if (s.size() == M) break; } cout << s.size() << endl; return 0; }