#!/usr/bin/env perl
# use strict;
use warnings;
use integer;

# decimal string addition
sub sadd
{
    my ($a,$b) = @_;

    my $alen = length $a;
    my $blen = length $b;

    # pad the shorter string with leading zeros
    if ($alen < $blen) {
	$a = ('0'x($blen - $alen)) . $a;
    }
    elsif ($blen < $alen) {
	$b = ('0'x($alen - $blen)) . $b;
    }

    my $carry = '0';
    my $ret = '';
    while ($a ne '') {
	my $sum = $carry + (substr $a, -1) + (substr $b, -1);
	$ret = ($sum % 10) . $ret;
	$carry = $sum / 10;
	$a = substr $a, 0, -1;
	$b = substr $b, 0, -1;
    }

    if ($carry > 0) {
	$ret = $carry . $ret;
    }

    return $ret;
}

# decimal string subtraction
sub ssub
{
    my ($a,$b) = @_;

    my $alen = length $a;
    my $blen = length $b;

    # we assume $a >= $b

    # pad the shorter string with leading zeros
    if ($blen < $alen) {
	$b = ('0'x($alen - $blen)) . $b;
    }

    my $borrow = '0';
    my $ret = '';
    while ($a ne '') {
	my $diff = (substr $a, -1) - (substr $b, -1) - $borrow;
	if ($diff < 0) {
	    $borrow = 1;
	    $diff += 10;
	}
	else {
	    $borrow = 0;
	}
	$ret = $diff . $ret;
	$a = substr $a, 0, -1;
	$b = substr $b, 0, -1;
    }

    # $borrow == 0 at this point, or else the answer will be wrong

    return $ret;
}

# unsigned decimal string multiplication (faster)
sub smul
{
    my ($a,$b) = @_;

    my $alen = length $a;
    my $blen = length $b;

    # pad the shorter string with leading zeros
    if ($alen < $blen) {
	$a = ('0'x($blen - $alen)) . $a;
	$alen = $blen;
    }
    elsif ($blen < $alen) {
	$b = ('0'x($alen - $blen)) . $b;
    }

    # $alen is the common length of both strings

    return $a * $b
	if $alen <= 2;

    my $midlen = $alen / 2;
    my $alow = substr $a, -$midlen;
    $a = substr $a, 0, -$midlen; # the high half of $a
    my $blow = substr $b, -$midlen;
    $b = substr $b, 0, -$midlen; # the high half of $b

    my $ll = smul($alow, $blow);
    my $hh = smul($a, $b);
    my $prod = smul(sadd($a,$alow),sadd($b,$blow));
    my $lhhl = ssub($prod,sadd($ll,$hh));

    # arithmetic shift left (by powers of 10) by appending trailing zeros
    $lhhl .= '0' x $midlen;
    $hh .= '00' x $midlen;

    my $ret = sadd(sadd($ll,$lhhl),$hh);

    return $ret;
}


$a = $ARGV[0];
$b = $ARGV[1];

$ans = smul($a, $b);

# remove leading zeros
$ans =~ s/^0+//;

$ans = '0' if $ans eq '';

print $ans . "\n";
