Alright, let's solve this problem step by step. We have 51022 and 46977, and we're subtracting the second number from the first.

Step 1: We'll start by subtracting the digit 7 and the borrow 0 from 2 in column 1 and get -5.
We add -5 to 10 and get 5 as the first digit of the result.

Step 2: We'll start by subtracting the digit 7 and the borrow 1 from 2 in column 2 and get -6.
We add -6 to 10 and get 4 as the next digit of the result.

Step 3: We'll start by subtracting the digit 9 and the borrow 1 from 0 in column 3 and get -10.
We add -10 to 10 and get 0 as the next digit of the result.

Step 4: We'll start by subtracting the digit 6 and the borrow 1 from 1 in column 4 and get -6.
We add -6 to 10 and get 4 as the next digit of the result.

Step 5: We'll start by subtracting the digit 4 and the borrow 1 from 5 in column 5 and get 0.
0 is the next digit of our result.

So, 51022 - 46977 = 4045.