Shimano has a pretty easy method for measuring what you need. First you need to know where your junction a and b are going to be. Are you going to use the more expensive 3 way cable on the bars or daisy chain with individual wires? In general take the measurement, go to the nearest even length rounding up. Add 50mm.
If your junction B is in the seat tube then measure the seat tube, length of seatpost - add together and add 250-300mm