You then need to factor in the day trips you would like to make, such as Toledo, Segovia or Cuenca, and add nights accordingly. For Madrid, if you want to visit the museums I feel 4 full days is sufficient to see the main sights and get a feel for the city. For Sevilla, 3 full days should be sufficient.