Appeal from a judgment of the County Court of Otsego County (Mogavero, Jr., J.), rendered June 10, 1985, convicting defendant upon his plea of guilty of the crimes of grand larceny in the second degree and petit larceny.
Defendant was charged with a total of 17 counts in two separate indictments. Pursuant to a plea bargain, defendant pleaded guilty to grand larceny in the second degree and petit larceny. Pursuant to that plea bargain, defendant was to be sentenced as a second felony offender to a prison term of IV2 to 3 years on the grand larceny charge. Sentencing on the petit larceny charge was to be postponed for three years or until defendant was released from imprisonment on the grand larceny charge. County Court thereafter sentenced defendant in strict accordance with this plea bargain.
*354On appeal, defendant first challenges the constitutionality of the second felony offender statute (Penal Law § 70.06). Since he never raised such argument prior to sentencing and, apparently, did not move to vacate the sentence (see, CPL 440.10), defendant failed to preserve this issue for appellate review (see, People v Lee, 109 AD2d 894; People v Velasquez, 107 AD2d 726). Moreover, were we to consider the issue in the interest of justice, we would find his challenge to the constitutionality of Penal Law § 70.06 to be without merit, as we have in the past (see, People v Davis, 111 AD2d 945, 946; People v Saxbury, 95 AD2d 871, 872).
With regard to the sentence imposed by County Court, we find that such sentence was unauthorized as a matter of law. The court adjudicated defendant a second felony offender. Having been so adjudicated, defendant should have been sentenced to, at the very least, a term of 2 to 4 years on the conviction for grand larceny in the second degree, a class D felony (see, Penal Law § 70.06 [2], [3] [d]; [4] [b]). Under the statute, County Court was powerless to impose the UA-to-3year term that was promised (see, People v Grant, 92 AD2d 985). Although this error was neither raised before County Court nor addressed in the brief of either party on appeal, this court cannot permit a sentence which is invalid as a matter of law to stand (see, CPL 470.15 [2] [c]; People v Gustafson, 101 AD2d 920, 921; People v Grant, supra). Accordingly, we reverse and remit the matter to County Court where defendant should be given the opportunity to withdraw his guilty plea and stand trial or, should he not choose that option, be resentenced in compliance with the statute (see, People v Grant, supra).
Judgment reversed, on the law, and matter remitted to the County Court of Otsego County for further proceedings not inconsistent herewith. Kane, J. P., Main, Casey, Mikoll and Yesawich, Jr., JJ., concur.