uses wincrt;

const { year lengths in seconds }
      solaryear  = 365*24*60*60 + 5*60*60 + 48*60 + 46;
      leapyear   = 366*24*60*60;
      commonyear = 365*24*60*60;

function isleapyear(year:longint):boolean;
  begin
    isleapyear := (((year mod 4=0) and not (year mod 100=0)) or (year mod 400=0)) and not (year mod 4000 = 0);
  end;

var year,discrepancy,i:longint;

begin
  write('Enter the year: '); read(year);

  discrepancy := 0;

  for i := 2 to year do
    begin
      if isleapyear(i) then
        discrepancy := discrepancy + solaryear - leapyear
      else
        discrepancy := discrepancy + solaryear - commonyear;
    end;

    write(abs(discrepancy) div (60*60),' hours, ',
           (abs(discrepancy) mod (60*60)) div 60,' minutes, ',
           (abs(discrepancy) mod (60)),' seconds, ');
    if discrepancy < 0 then
      writeln('behind the solar calendar')
    else
      writeln('ahead of the solar calendar');

end.