-module('Main').
-export([main/1]).

ccase(X, DIDI, Ans) ->
	case X of
      X when X =:= DIDI -> 1;
      X -> 0
  	end.

loop(Le, Ri, Di, Now, Ans) ->
    
	DIDI = Now rem Di,
    case Now of
        Now when Now >= Ri -> io:format("~B~n", [Ans + ccase(0, DIDI, Ans)]);
        Now when Now < Ri -> loop(Le, Ri, Di, Now + 1, Ans + ccase(0, DIDI, Ans))
	end.


solve() ->
	[L, R, D] = input("~d~d~d"),
    A = 42,
    loop(L, R, D, L, 0),
    ok.

main(_) ->
    solve(),
    halt().

input(Pat) ->
    {ok, L} = io:fread("", Pat),
    L.


