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

main(_) ->
    {ok, [N]} = io:fread("", "~d"),
    L = find_z_list(N),
    io:format("~p~n", [length(L)]),
    halt().


find_z_list(N) ->
    sets:to_list(sets:from_list(find_z_list(N, factorize(N), [], []))).
find_z_list(1, _L, _Used, Acc) ->
    Acc;
find_z_list(N, [H|T], Used, Acc) ->
    case N =:= H * H of
        true ->
            [H * H|Acc];
        false ->
            case lists:member(H, Used) of
                true ->
                    find_z_list(N, T, Used, Acc);
                false ->
                    case N rem H == 0 of
                        true ->
                            NewN = N div H,
                            find_z_list(NewN, factorize(NewN), [H|Used], [NewN|Acc]);
                        false ->
                            find_z_list(N, T, Used, Acc)
                    end
            end
    end.


factorize(N) ->
    lists:usort(lists:delete(1, factorize(N, floor(math:sqrt(N)), 2, [], [N]))).
factorize(N, _SqrtN, D, F, L) when N div D == 1 ->
    lists:append(lists:reverse(F), L);
factorize(_N, SqrtN, D, F, L) when SqrtN < D ->
    lists:append(lists:reverse(F), L);
factorize(N, SqrtN, D, F, L) ->
    case N rem D == 0 of
        true ->
            D2 = N div D,
            factorize(N, SqrtN, D + 1, [D|F], [D2|L]);
        false ->
            factorize(N, SqrtN, D + 1, F, L)
    end.
