From Bangalore reach Tirupathi first it’s 6 hours journey. There are lot of trains operating to Tirupathi. From Tirupathi a day later take a train to Rameshwaram. It is a long overnight journey. Since you are visiting Tirupathi you can plan a trip to kalahasthi. From Rameshwaram don’t miss out on Kanyakumari, dhanushkodi and beaches. Totally you might need 5 days for the trip. It’s based on travel time which is longest from Tirupathi to Rameshwaram.