Problem

Source: 2018 Saudi Arabia GMO TST II p2

Tags: number theory, Digits, divisible



Two positive integers $m$ and $n$ are called similar if one of them can be obtained from the other one by swapping two digits (note that a $0$-digit cannot be swapped with the leading digit). Find the greatest integer $N$ such that N is divisible by $13$ and any number similar to $N$ is not divisible by $13$.