#! usr/bin/perl

use strict;
use warnings;

sub max {
    my ($a,$b)=@_;
    $a>$b ? $a : $b;    
}

chomp(my $line = <STDIN>);
my ($K,$S) = split ' ',$line;

my $count=0;
foreach my$x(0..$S/3) {
    foreach my$y(max($x,$S-$x-$K)..($S-$x)/2) {
        my $z = $S-$x-$y;
        if (($x==$y)&&($y==$z)) {$count += 1;next};
        if (($x==$y)||($y==$z)) {$count += 3;next};
        $count += 6;
    }
}

print "$count\n"