Assume that n2−54m+3>0. If n2−54m+3=1, then 54m+3=n2−1=(n−1)(n+1). Since n is obviously even the numbers n−1 and n+1 must be coprime, which implies n−1=1 and n+1=54m+3. This is not possible. If n is divisible by 5, then n2−54m+3≥5, if n is of the form n=5k±1, then
n2−54m+3≡1(mod5), and if n=5k±2, then n2−54m+3≡4(mod5). Since none of the remainders are equal to 2 or 3 and n2−54m+3>1, we conclude that n2−54m+3≥4.
Now, assume 54m+3−n2>0. This number cannot be equal to either 2 or 3. We can see this by considering the remainders modulo 5, because 54m+3−n2 is either divisible by 5 (and hence greater than or equal to 5), or n has the form n=5k±1 or n=5k±2. So, either 54m+3−n2≡−1≡4(mod5) or 54m+3−n2≡−4≡1(mod5).
Assume there exist m and n such that 54m+3−n2=1. We can rewrite the equation as
n2=54m+3−1=(5−1)(54m+2+54m+1+⋯+5+1)==4(54m+2+54m+1+⋯+5+1).
This implies that 54m+2+54m+1+⋯+5+1 is a perfect square. If it is equal to l2, then (l−1)(l+1)=5(54m+1+54+⋯+5+1). Let us consider the expression 54m+1+54+⋯+5+1 modulo 4. We have
54m+1+54+⋯+5+1≡1+1+⋯+1+1≡(4m+2)≡2(mod4),
since there are 4m+2 summands in the sum. This sum is therefore divisible by 2 but not by 4. So, (l−1)(l+1) is even. On the other hand, l−1 and l+1 have the same parity, so (l−1)(l+1) is divisible by 4, a contradiction. The numbers m and n such that 54m+3−n2=1 do not exist.
We have shown that n2−54m+3 and 54m+3−n2 cannot be equal to 0, 1, 2 or 3, so the smallest possible value of ∣54m+3−n2∣ is 4 and this value is attained when n=11 and m=0, for example.