#!/usr/bin/perl

use v5.30;
use strict;

use List::Util qw(min max);

my $res = 0;
while (<>) {
	my @a = split /\s+/;
	my $m1 = min @a;
	my $m2 = max @a;
	$res += $m2-$m1;
}

say $res;

