#!/usr/bin/perl

use v5.30;
use strict;

my @start = (883, 879);
# my @start = (65, 8921);
my @f = (16807, 48271);

sub gen {
	my ($i,$gen) = @_;
	$start[$i] = $start[$i] * $f[$i] % 2147483647;
	return $start[$i] & 0xFFFF;
}
my $matches = 0;
for (1 .. 40_000_000) {
	$matches++ if gen(0, $_) == gen(1, $_);
}

say $matches;
