Appeal from a judgment of the Supreme Court, Erie County (John E O’Donnell, J.), rendered March 20, 2003. The judgment convicted defendant, upon his plea of guilty, of robbery in the second degree (two counts).
It is hereby ordered that the judgment so appealed from be and the same hereby is unanimously modified on the law by vacating the sentence and as modified the judgment is affirmed, and the matter is remitted to Supreme Court, Erie County, for resentencing.
Memorandum: Defendant appeals from a judgment convicting him upon his plea of guilty of two counts of robbery in the second degree (Penal Law § 160.10 [2] [b]). Contrary to the contention of defendant, his waiver of the right to appeal is valid and effective (see generally People v Calvi, 89 NY2d 868, 871 [1996]; People v Callahan, 80 NY2d 273, 280 [1992]; People v Brown, 281 AD2d 962 [2001], lv denied 96 NY2d 899 [2001]). That waiver, however, does not encompass a challenge to the legality of the sentence (see People v Seaberg, 74 NY2d 1, 9 [1989]; People v Fehr, 303 AD2d 1039 [2003], lv denied 100 NY2d 538 [2003]), nor is preservation of such a challenge required (see People v Fuller, 57 NY2d 152, 156 [1982]). Supreme Court sentenced defendant as a second felony offender to concurrent determinate terms of imprisonment of seven years, stating “I have no choice, . . . that’s the minimum sentence that I’m allowed to impose . . . .” Actually, the minimum sentence that the court could have imposed was concurrent determinate terms of imprisonment of five years (see Penal Law § 70.06 [6] [b]). “The failure of the court to apprehend the extent of its discretion deprived defendant of the right to be sentenced as provided by law” (People v Hager, 213 AD2d 1008, 1008 [1995]; see People v Endresz, 1 AD3d 888, 888-889 [2003]; People v John, 288 AD2d 848, 850 [2001], lv denied 97 NY2d 705 [2002]; People v Woodard, 201 AD2d 896 [1994]). We therefore modify the judgment by vacating defendant’s sentence, and we remit the matter to Supreme Court for resentencing. Present—Hurlbutt, J.P., Scudder, Kehoe, Gorski and Hayes, JJ.