How do I calculate the current number of spaces between two columns of data in a line of a file, such so that I can determine how many additional spaces it will take to bring the second column to position 22 (0-based), so that I can change the line to put the correct number of spaces between the two columns of data?

I already have the position of the last non-spc-char of the first column, and also the position of the first non-spc-char of the second column. Do I just subtract the former from the latter? That would get the number of existing spaces, but then what? How do I figure out how many additional spaces I need to bring the second column of data to position 22?