What type of person are you when you’re faced with an extravagantly difficult challenge?

I discovered the answer to my question during the two years I sat in a prison cell.

I've always been endlessly optimistic, and the type of person who believes a lesson is learned in every experience. Attitude and perspective matter. With the right perspective, you can believe that every challenge will present a silver lining.

I went into prison with a similar attitude. The result has been a stronger, more focused, refined version of my previous self.

Some people get stuck in the vicious prison cycle, pass blame, go in and out their entire lives, and choose not to learn their lessons. People on the streets can allow themselves to become so overwhelmed in life that it seems impossible to overcome anything. Neither person has mastered their mental strength, but with the proper tools and techniques they can smash through these challenges.

Here are some tough mindsets I learned while doing two years that have made me mentally unstoppable:

1. Self awareness.

“Conquer thyself; till thou hast done this, thou art but a slave.”

Replace the word “slave” with “inmate,” and you can see my point. People want to change the world, but they can’t change themselves. Until you master yourself, you won’t be able to master anything.

Mental toughness is based around oneself. The first step in mastering this mental strength is mastering your own physical, emotional and spiritual states. How do you react to negative situations? How do you show up in life? How do you look to other people? Do your dreams and goals align with your everyday actions and decisions?

This first step is self reflection on an honest inventory of the person you are right now.

Related: Why Mindset Trumps Strategy Every Time

2. Self image.

Self image begins by believing in yourself, and believing you CAN accomplish great things. I read this in a book:

“Self image is not mental trickery. It is a scientifically proven agent of control. The self image identifies and motivates the necessary behavior and connects it to the desired outcome. The key is to create the self image desired, decide who you want to be and how you want to live, and then continuously tell yourself that you have what it takes to be that person. The self-image will guide and direct actions and behaviors until the self-image becomes the reality.”

You will act like the sort of person you want to be. Will power is not the answer, self image is.

3. Positive self talk.

The mind has roughly 60,000 thoughts per day. Mental toughness is centered around your thoughts. Everyone has negative thoughts, but the truly mental tough are able to capture those negative thoughts and replace them with positive ones. The more positive thoughts you have, the more success you obtain.

Let’s do some quick math: 60,000 thoughts per day x 365 days per year = 21,900,000 thoughts per year. To have a positive healthy emotional state, your positive thoughts must outweigh the negative. That means you need to have at least 10,950,001 positive thoughts per year.

In bleak circumstances the mind is prone to more negativity. It is vital in those times you focus even harder on taking those thoughts captive, and discipline yourself to replace them with positive thoughts. While in prison, I would use this mental trick I learned:

When a negative thought came into my mind, I would use some sort of tool or instrument to get it out. For instance, “I’m never going to be able to accomplish my startup goals while sitting in this prison cell.” Instead of letting that thought fester, I would envision the thought as a big pile of rubbish, and envision a bulldozer pushing that thought and pile of trash, right out of the edge of my mind.

I used all different types of objects to visually rid myself of negative thoughts. Use this trick.

4. Nothing to lose.

“It's only after we've lost everything that we're free to do anything.” - Tyler Durden.

There's freedom in purging your life of all that you own. After two years in prison I had lost everything, and left with $200.00 to my name (note: the joy of freedom has no price). I lived with a friend when I got home, and worked quickly to start a business. I negotiated relentlessly, worked hard and gave it everything. What did I have to lose?

Nothing to lose has afforded me infinite possibility. The prison experience allows me to be grateful for the things I do have.

5. Comfortable in the unknown.

The prison journey is a combination of unknown stops at every turn. An inmate is constantly moved around the system, presented with new situations and cellmates, different tiers with different people all throughout his or her prison stay.

The only certainty is uncertainty. Figuring out how to adapt to the changing environment and changing scenarios, empowered me to get comfortable in the unknown.

Most of the time we get upset, or react negatively to a situation, it is because that situation didn’t go as we planned it. Think back to a situation that you reacted negatively towards, and 90 percent of the time you can pinpoint that reaction to your expectation of how that situation was supposed to occur.

Realizing this, and living in the uncertainty, allowed me to be fluid with my expectations. Don’t take this the wrong way, that doesn’t mean I just let life happen to me, but rather I controlled the things I could control (like myself, my reactions to situations, and my discipline) and released control of things I could not control. For instance, rather than get upset when the yard was locked down because of riot or fight, which caused me to miss my workout, I chose to work out in my cell instead.

This skill has translated to my startup success, as a startup is full of uncertainty and unknowns.

Related: 3 Truths You Must Embrace to Lead Your Team to the Summit

6. Distraction free.

“I was most happy when pen and paper were taken from me and I was forbidden from doing anything. I had no anxiety about doing nothing by my own fault, my conscience was clear, and I was happy. This was when I was in prison.” - Daniil Kharms.

Our complex, miraculous and intricate brains were not designed to deal with nagging bosses, paying bills or watching Kardashian repeats. An amazing thing happens when you remove the distractions. You gain some serious mental clarity. The world makes more sense, your dreams become clearer and your thought patterns get stronger.

Removing distractions provides you mental clarity. Mental clarity provides you mental strength.

7. Freedom through captivity.

“Nobody wants to get locked up, although 'locked up' is a matter of perspective. There can be people who are out who are in prison mentally and emotionally and worse off than those who are behind bars.” - Wesley Snipes

Some of the calmest, most peaceful, intelligent people I’ve ever met are doing life in the penitentiary. Let's get metaphysical here. There's an ancient prison trick that has been used thousands of years and dates back earlier than Confucius. For the captive who allows it, enlightenment happens.

There's a certain freedom in grasping this somewhat allusive reality: nobody can take your mind prisoner if you don't allow it. We are all free to think and feel how we choose. Be wise in your choices.

8. Vivid thoughts.

Dark gray cells, dark gray clothes, dark gray food, dark gray food trays, dark gray bunks, everything is dark gray in prison. Which leaves it up to the individual to see in color.

There is an inherent benefit to generating the mental focus yourself. People learn faster by visualizing success rather than by watching it on tape. In athletic training, research shows that every minute of visual realization is worth seven minutes of physical practice.

When sitting in my dark gray cell with my books, newspapers and magazines, while writing, reading and researching the tech sector, I would visualize myself in Silicon Valley at partner meetings, with my new startup, raising capital from prominent venture capitalists.

I used to handwrite articles to be posted on Entrepreneur.com. I’d visualize myself on the cover of Entrepreneur, Inc. Magazine, Wired and Fast Co. I still use these visualization techniques to accomplish goals. At the bottom of this article, I’ve provided a couple examples.

9. Relentlessly train your mind.

I realized that, even in prison, my schedule and time were in my control. Unlike my fellow inmates who spent their time playing cards, watching TV and “shucking and jiving” all day, I focused on training my mind.

In those two years: I read 197 books. I wrote two books. I learned a new language (Korean). I taught my fellow inmates all about business and startups. I studied physics and history. I wrote every single day for two years straight. I incessantly trained and disciplined my mind.

My routine became the saving grace that allowed me to relentlessly train my mind.

Related: This Simple Technique Trains Your Brain to Conjure Your Best-Ever Ideas

10. Relentless solution-based mentality.

I met endless problems, and relentlessly focused on solutions to all of those problems.

Research shows that most people achieve solution focused thoughts about 40 percent of the time, while individuals with relentless solution focus replace 100 percent of negative thinking with thoughts focused on solutions.

When obstacles come your way, do you accept the problems, or focus on solutions?

11. Overcoming obstacles.

After successfully accomplishing two years in prison I felt invincible. Conquering major life hurdles will give you an infinite supply of self confidence and self worth. I left with, and maintain, the mentality that if I can accomplish prison, I can accomplish anything.

Use your experiences effectively. Let the negative catapult you to the positive. Here are some key takeaways:

1. What is one thing that you keep talking about doing? Figure out how to do it today. Stop procrastinating. Procrastination is a thief that robs you of self control. This will help you take one step in conquering yourself. It can be as minor as getting up 20 minutes earlier and starting the day by reading, or as major as planning how to quit your job. Figure out how to take back control of one area of your life.

2. Take five minutes today to sit down in a quiet place and fully visualize the success of a goal. For instance, I have an athletic competition coming up next weekend. For the past two weeks, I’ve been visualizing myself competing, going through the course, feeling the excitement and visualizing myself successfully accomplishing the different movements of the event. I start with the beginning of the event with as many details as possible, to warming up, putting on my shoes and even drinking my Progenex Force pre-training formula, all the way to the end of the event, where my team obviously wins. I see us celebrating, receiving the award and allow myself to feel the excitement and joy of winning. I replay this reel in my mind throughout the day. When I have a moment to stop and think, I’ll sit diligently and focus on the reel. I’ve also been doing this with my wedding (which is in two weeks). I imagine the people there, the sounds we’ll hear, the food we’ll eat, the music playing, the excitement and joy.

3. Figure out what distractions you have in life. Focus on the different areas in work and your personal life. Write down those distractions, and remove them. For instance, I no longer have Facebook or Instagram apps on my phone. I would find myself going to these apps between meetings, or while waiting somewhere. Now, I instead use my visualization techniques to focus on more positive thoughts. This little productivity hack has saved me endless hours of social media distractions. Try it.

Mental strength is a skill that can be taught and acquired. It is based on self awareness, self image and positive thoughts. Any time you feel angry, sad, frustrated or just generally uncomfortable, repeat positive thoughts over and over again. It might take a million thoughts to create the habit, but stay at it.

Welcome negative experiences, challenge yourself and discipline your mind to be the mentally toughest version of yourself. It will pay off in ways you can’t even dream or imagine.

Related: Express Gratitude for Where You Are Right Now, and Say It Out Loud