import java.util.Scanner; import java.util.TreeSet; public class PB { public static void main(String[] args){ Scanner in = new Scanner(System.in); float n = in.nextFloat(); while(n>0){ TreeSet

ps = new TreeSet

(); float x = in.nextFloat(); float y = in.nextFloat(); while(x<=y){ ps.add(new P(x,y)); x = in.nextFloat(); y = in.nextFloat(); } float ans=n; float l=0, r=0; for(P p : ps){ if(p.x>=r){ ans-=r-l; l=p.x; r=p.y; } else { if(p.y>r) r = p.y; } } ans-=r-l; System.out.printf("The total planting length is %.1f\n", ans); n = in.nextFloat(); } } private static class P implements Comparable

{ public float x; public float y; public P(float x, float y){ this.x = x; this.y = y; } @Override public int compareTo (P arg0) { if(Math.abs(this.x-arg0.x)<1e-5){ return (this.y-arg0.y)>0?1:-1; } return (this.x-arg0.x)>0?1:-1; } } }