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

main(_) ->
    {ok, [N]} = io:fread("", "~d"),
    Edge = find_edge(N),
    Rest = N - find_n(Edge - 1),
    S = alpha(Rest, Edge),
    io:format("~s~n", [S]),
    halt().

find_edge(N) ->
    find_edge(0, N).
find_edge(E, N) ->
    case find_n(E) > N of
        true ->
            E;
        false ->
            find_edge(E + 1, N)
    end.

find_n(0) ->
    1;
find_n(N) ->
    floor(math:pow(26, N)) + find_n(N - 1).

alpha(N, X) ->
    alpha(N, X, []).
alpha(_, 0, Acc) ->
    Acc;
alpha(N, X, Acc) ->
    Char = (N rem 26) + $a,
    NewN = N div 26,
    alpha(NewN, X - 1, [Char|Acc]).
