Count up the generations from the first person to the first common ancestor, and from the second person to that common ancestor. Subtract one from the lower of the two values to get the degree, and the difference between the two values is the number of times removed.
So if person A has a great-grandfather who is person B's grandfather then they would be first cousins, once removed. Likewise if A had a great-great-grandfather who was B's great grandfather then they would be second cousins, once removed.
More, much more, can be found in the wikipedia article on cousins.