Find the value of $a$ for which there is exactly one real value of $x$ such that $f(x) = a,$ where \[f(x) = x^3 + 4x - 31 + 2x + 18.\]