Compare 2 integer inputs and pick the closest one to target

How can I compare 2 integer inputs from player A and player B and then pick the closest one to my target answer?

i.e the correct answer is 1500 and player A inputs 500 and player B inputs 2000. So the closest answer is B’s.

Hope it’s clear. Can you help me with that?

Use the absolute value of the input - answer.Mathf.Abs(input - answer); Then see which one is lower.

Thank you.