unittest
{
	assert( [ "1", "24 30" ].parse.expand.solve == 7 );
	assert( [ "2", "6 8", "3 3" ].parse.expand.solve == 4 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	auto lrs = new long[ 2 ][ n ];
	foreach( ref lr; lrs )
	{
		input.popFront;
		lr = input.front.split.to!( long[] );
	}
	return tuple( lrs );
}

auto solve( long[ 2 ][] lrs )
{
	return lrs.map!( ( a ) => 1 + a[ 1 ] - a[ 0 ] ).reduce!( ( a, b ) => a + b );
}
