SMS: Dynamic programming