How do I build an ego/immense self confidence?

r/

I’m 18M, this year has been so ass, I worked hard for an exam…so hard I spent 2 years tryna learn random stuff, so random like basically what reaction takes place in burning of coal on a train to the ingredients of my elastic underwear. It’s been weird. I gave this exam on 29th January and managed to get a rank of under 20k out of 1.5m who say for this exam. Just after the exam I had my certificate exams (their like the exams which signify that you’ve passed high school), which I fucked up so bad, I was unwell, I had severe gastroenteritis (a level below typhoid)…however I remained calm and will potentially score 80%…I feel so dejected, I messed up chemistry so bad, I’m barely pass in it. On top of that, I’m unable to study for the level 2 of the exam I was taking (the 29th Jan one)…I feel whatever I’m touching is turning into ashes, I make targets everyday and I’m unable to complete them, I’m consistently scoring low marks in mocks too…could someone tell me how I can build that ego again inside me or the self confidence to keep myself motivated again. I feel I need intrinsic motivation which I’m lacking at this point…