#!/usr/bin/perl

use v5.30;
use strict;

my $in = 345;

my $pos = 0;
my $val;
for (1 .. 50_000_000) {
	$pos += $in;
	if ($_ > 1) {
		$pos %= $_;
	} else {
		$pos = 0;
	}
	$pos++;
	$val = $_ if $pos == 1;
}

say $val;

