There are many ways to answer this question. Maybe the most important internal motivation is to think about the reasons that lead you to enroll in the program of your choice, and keep that as your horizon. Some external motivators that may help you are: set a studying schedule and stick to it, set challenging but realistic goals, be organized, seek help from professors and classmates when needed, create a study support group, find ways to connect with the course material to help you engage with it, use different study methods (for example writing, sketching, video or audio recording, group studying). There are many more strategies to stay motivated depending on your background and personality. Look for more strategies online!