
65 P.3d 223 (2003)
2003 MT 33
STATE of Montana, Plaintiff and Respondent,
v.
Michael D. FISHER, Defendant and Appellant.
No. 02-706.
Supreme Court of Montana.
Submitted on Briefs February 6, 2003.
Decided February 25, 2003.
Michael D. Fisher, pro se, Warm Springs, Montana, For Appellant.
Honorable Mike McGrath, Attorney General; Jennifer Anders, Assistant Attorney General, Helena, Montana, Thomas R. Scott, County Attorney, Dillon, Montana, For Respondent.
Justice W. WILLIAM LEAPHART delivered the Opinion of the Court.
¶ 1 Michael D. Fisher appeals from the sentence imposed by the District Court of the Fifth Judicial District, Beaverhead County. He contends that the sentence is illegal in that, contrary to the provisions of § 46-18-403, MCA, it does not credit his time spent in jail prior to conviction against the fine imposed by the court. We determine that there is merit to Fisher's appeal, and we reverse and remand for new sentencing.
¶ 2 The issue presented for review is whether § 46-18-403, MCA, requires that a sentencing court give a defendant credit for time incarcerated prior to conviction against both his jail sentence and any fine imposed.

Background
¶ 3 In April 2002, Fisher was charged with felony DUI (fifth offense) and with two misdemeanors, driving without liability insurance and driving while his driving privileges had been suspended as a result of earlier DUI convictions.
¶ 4 Fisher pled guilty to the DUI charge and to driving with a suspended license in exchange for the State's agreement to dismiss the other misdemeanor. In addition, the State agreed to recommend a thirteen-month commitment to the Department of Corrections, followed by three years probation, in addition to several fines, costs, fees and surcharges.
¶ 5 Upon accepting Fisher's pleas, the District Court imposed sentence on May 13, 2002, committing Fisher to the DOC for thirteen months, followed by five years probation. On the misdemeanor offense, the court ordered Fisher to serve thirty days in the county jail, to run concurrently. In the sentence, the court gave Fisher thirty-seven days credit for time served in the county jail from the date of his arrest to the date of sentencing. Further, the court imposed fines, as follows: $1,000 fine for the felony DUI, $450 reimbursement for public defender costs, $40 surcharge, $50 victim/witness fee, $10 technology fee, and $20 probationary supervision fee.
*224 ¶ 6 On August 5, 2002, Fisher filed a Motion to Amend the Judgment and Sentence. In his motion, Fisher requested that the court modify the judgment so as to give him thirty-one days credit toward his fine obligation at a rate of $47 per day, which would discharge his fine obligation entirely. He further asked that the remaining six days credit be applied toward his DOC commitment. Concluding that it lacked authority to amend the sentence, the District Court denied the motion to amend.
¶ 7 Fisher then filed a pro se petition to vacate fines with this Court. We construed the petition as a timely notice of appeal and asked the State to respond, which it has.
¶ 8 Fisher cites our decision in City of Billings v. Layzell (1990), 242 Mont. 145, 789 P.2d 221, for the proposition that a defendant must be given credit for time served against any fine imposed.
¶ 9 The State contends that the District Court correctly concluded that it did not have jurisdiction to modify the sentence imposed. Section 46-18-116(3), MCA, provides that a court can correct a factually erroneous sentence at any time, but that illegal sentences must be dealt with through appeal or postconviction relief. The State contends that this statute does not apply since Fisher did not allege that the sentence was factually erroneous or that there was a conflict between the oral sentence and the written judgment. In the State's view, the court imposed a legal sentence when it committed Fisher to the DOC for thirteen months, imposed a fine and gave him credit for time served against his sentence, pursuant to § 46-18-403(1), MCA. It is the State's position that, whether the court credits the time served against the sentence pursuant to subsection (1) or against the fine pursuant to subsection (2) is a matter of discretion. For the reasons set forth below, we disagree.

Discussion
¶ 10 Section 46-18-403, MCA, provides as follows:
Credit for incarceration prior to conviction. (1) Any person incarcerated on a bailable offense and against whom a judgment of imprisonment is rendered must be allowed credit for each day of incarceration prior to or after conviction, except that the time allowed as a credit may not exceed the term of the prison sentence rendered.
(2) Any person incarcerated on a bailable offense who does not supply bail and against whom a fine is levied on conviction of the offense must be allowed a credit for each day of incarceration prior to conviction, except that the amount allowed or credited may not exceed the amount of the fine. The daily rate of credit for incarceration must be established annually by the board of county commissioners by resolution. The daily rate must be equal to the actual cost incurred by the detention facility for which the rate is established.
¶ 11 We have interpreted the provisions of subsection (2) in City of Billings v. Layzell. Layzell argued that the district court's failure to credit his thirty days of pretrial incarceration against his $200 fine was a violation of his constitutional rights. We concluded that it was unnecessary to address his constitutional arguments since the district court's failure to comply with Montana's statutory mandate was sufficient to reverse the sentence. Referring to the language in § 46-18-403(2), MCA (1987), we held: "The statutory language is mandatory. It requires the District Court to give credit for pretrial detention accrued because the defendant did not make bail. Layzell's thirty-day pretrial detention is more than sufficient to discharge his fine." Layzell, 242 Mont. at 154, 789 P.2d at 226.
¶ 12 The question presented by the instant case is whether the sentencing court has discretion to choose between giving credit against the sentence or giving credit against the fine. We determine that the statute is not discretionary. As we pointed out in Layzell, subsection (2) of the statute[1] mandates that credit "shall" be allowed against the *225 fine. The language of subsection (1) is mandatory as well. It provides that a defendant "must be allowed credit" against his sentence for all incarceration prior to or after conviction. The subsections are not worded in the disjunctive. They are independent and mandatory.
¶ 13 We hold that a sentencing court has no discretion in applying § 46-18-403, MCA. It must employ both subsections and give the defendant credit for each day of incarceration against both the sentence and any fine imposed. Once a valid sentence has been pronounced, the sentencing court has no jurisdiction to modify it except to correct factual errors. Section 46-18-116(3), MCA; Brown v. State, 2002 MT 209N, ¶ 12, 2002 WL 31059709. However, a sentence which does not comply with Montana statutory law is illegal and must be addressed in the manner provided by law for appeal and postconviction relief. Section 46-18-116(3), MCA.
¶ 14 As we did in Layzell, we reverse and remand for resentencing in accordance with this opinion.
We concur: KARLA M. GRAY, C.J., and JAMES C. NELSON, TERRY N. TRIEWEILER, PATRICIA COTTER, JIM REGNIER and JIM RICE, JJ.
NOTES
[1]  In contrast to the "shall" language of the 1987 statute, the 1995 statute provides that the defendant "must be allowed credit." Further, in lieu of a flat rate of $10 per day, the 1995 version provides that the daily rate of credit must be established annually by the Board of County Commissioners.
