Can anyone help clear up some subnet confusion.

Hello,
Given the following:
ip address 128.107.0.1/30
How do they get the mask to be .252?
255.255.255.252
My questions is when /30 or /24 or anything after the slash, how do you calculate subnet mask? I for some odd reason just can't get it.
Given the following:
ip address 128.107.0.1/30
How do they get the mask to be .252?
255.255.255.252
My questions is when /30 or /24 or anything after the slash, how do you calculate subnet mask? I for some odd reason just can't get it.
Comments
Example: 128.107.0.1 /30
The /30 means there are 30 bits to identify the (N)ETWORK. The remaining two identify the (H)OSTS.
NNNNNNNN.NNNNNNNN.NNNNNNNN.NNNNNNHH
If we look at the octets a little closer, each bit has a value based on its position.
Bit: 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8
Value: 128 - 64 - 32 - 16 - 8 - 4 - 2 - 1 (<-- same values for each octet)
If you add the values, in each octet, where the bit is for the network, that is how you get 252, or 248, 255, or 192, etc.
A /30 mask means 255.255.255.252 because the first 3 octets have 8 bits each, and every one of them are part of the network. The last octet has the first 6 bits part of the network.
So, to get 252 in the last octet, you MUST have the 128 bit, the 64 bit, the 32 bit, the 16 bit, the 8 bit, and the 4 bit all part of the network, because when you add them up, it equal 252. There is no other way to get 252 out of those values.
The only possible values in a mask are 128, 192, 224, 240, 248, 252, 254, 255. If you look at those numbers closely and compare them to the bit values, you'll see a pattern.
It takes practice and time to get it. You'll hit that "Aha!" moment. Start with practicing in the last octet, then move on the the 3rd and 2nd octet.
Hope my explanation helps and wasn't confusing.
Going to the left, I know that a block size of 16 (/28 ) doubled is 32, so /27 is 30 hosts usable, with 1 each reserved for network ID and broadcast.
This is how I wrapped my head around subnetting. It works on all octets and classes.