The first number is the chassis.... 1, 3, 5, 6, 7, 8 etc... and now there is a 4 as well. In general, the bigger the number, the larger the car.
The last two numbers refer to the engine. At one point, there was some relation to the displacement but in general the bigger the number, the more power. If the car is the "M" version, it will be the top power train level.
The "i" suffix doesn't mean anything any more. "is" suffix would be a higher tune version. For example 335i vs 335is .... the latter has a bit more power but is essentially the same motor.
"x" means awd...
Be careful when shopping.... many people falsely or mistakenly use "M" badges or use "M" loosely in their descriptions. I'm sure if you post links to an ad here, members will be all over it which will help you...