#!/usr/bin/perl -w

use v5.16;
use strict;

my $in = 33100000;

my $maxh = $in;

my @houses;
for my $elf (1 .. $maxh) {
	my $h = $elf;
	my $count = 50;
	do {
		$houses[$h] += 11*$elf;
		$maxh = $h if $houses[$h] >= $in;
		$h += $elf;
	} while ($h <= $maxh && --$count);
}

for my $h (1 .. $maxh) {
	next if $houses[$h] < $in;
	say $h;
	last;
}

