Is there an easy method for finding the length of a diagnol line in a grid. Say, if I have:

Code:
x x x x x x x x x x
x x x x x x x x x x
x x x x x x x x x x
x x x x x x x x x x
x x x x x x x x x x
x x x x x x x x x x
And I know that x is 6 and y is 4 (bottom x). How could I find the length of any diagnol line, no matter where it starts?