M-estimation and complexity regularization