#!/usr/bin/perl
use v5.10;

($n, $m) = split / /, <>;
$n==1 and say 1 and exit;
$m-1<$n-$m and say $m+1 or say $m-1;


#!/bin/perl

$str=<>;
@ns=split(' ',$str);
$str=<>;
@a=split(' ',$str);

$m=0; $sum=0;
foreach $i (@a) {
    $m = $i if ($i > $m);
    $sum += $i;
}

if ($sum-$m <= @ns[1]) {
    print "YES"
}else {
    print "NO"
}


#!/usr/bin/perl

use 5.012;
use warnings;

chomp(my $l = <>);
my ($n, $m) = split / /, $l;
my $day = 1;
while ($n--) {
	$n++ if $day++ % $m == 0;
}
print --$day;


#!/usr/bin/perl -w

use strict;

chomp($_ = <>);
my ($T, $S, $q) = split;
my $i = 0;

$T = $T / $S;
while($T > $q ** $i) {
    $i++;
}

print $i, "\n";


#!/bin/perl -w
use strict;
use warnings;

my $s = <>;
chomp $s;
$s =~ s|/+|/|g;
$s =~ s|([^/])/$|$1|g;
print "$s\n";


chomp($_=<>);
$_=join'',sort split/ /;
if (s/(.)\1\1\1//){$a=/(.)\1/?Elephant:Bear}
else {$a=Alien}
print $a


#!/usr/bin/perl

use warnings;
use strict;

$\ = $/;

while(<>){
	my( $n, $k, $x ) = split;

	@_ = split ' ', <>;

	my @A = splice @_, 0, $n - $k;

	print +( unpack "%32i" . @A, pack 'i' . @A, @A ) + $k * $x;
	}


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

sub min{
    return $_[0] < $_[1]? $_[0]:$_[1];
}
my $n;my $m;my $a;my $b;

($n, $m, $a, $b) = split(' ', <>);

if($a * min($m,$n) < $b){
    print $a * $n;
    exit 0;
}
my $res = 0;
while($m <= $n){
    $res += $b;
    $n -= $m;
}
$res += min($a * $n, $b);
print $res;


#!/usr/bin/perl
# your code goes here

chomp($line = lc <>);
$line =~ s/[a,o,y,e,u,i]//g;
$line =~ s/(\w)/.$1/g;
print $line;


#!/usr/bin/env perl

use strict;
use warnings;

my $a = <>;
chomp $a;

my $b = <>;
chomp $b;

my $c = $a+$b;

$a =~ s/0//g;
$b =~ s/0//g;
$c =~ s/0//g;

printf "%s\n", (($a+$b==$c) ? 'YES' : 'NO');


use strict;
use warnings;

my $input = <STDIN>;
my ($x, $y, $z, $t1, $t2, $t3) = split / /, $input;
my $stime = abs($t1*($y-$x));
my $ltime = $t2*(abs($z-$x) + abs($x-$y))+3*$t3;
if ($stime >= $ltime) {
    print "YES";
} else {
    print "NO";
}


chomp(my $wake=<>);
my ($wh, $wm) = split /:/, $wake;
chomp(my $sleep=<>);
my ($sh, $sm) = split /:/, $sleep;
$wh-- and $wm+=60 if $wm<$sm;
$wh+=24 if $wh<$sh;
printf "%02d:%02d\n", $wh-=$sh, $wm-=$sm;


#!/usr/bin/perl -w
#
use strict;

chomp(my $s = <>);
chomp(my $t = <>);

my $s_len = length($s);

my @s = split('', $s);
my @t = split('', $t);
my $res;
my $i;
for $i (0..$s_len-1) {
    if(ord($s[$i]) > ord($t[$i])) {
        print "No such string\n";
        exit;
    }
    elsif(ord($t[$i]) - ord($s[$i]) > 1) {
        $res .= chr(ord($s[$i]) + 1);
        $res .= substr($s, $i + 1);
        last;
    }
    elsif(ord($t[$i]) - ord($s[$i]) == 1) {
        if($i == $s_len - 1) {
           print "No such string\n";
           exit;
        }
        else {
           my $flag = 0;

           # find char not z
           my $j = $i+1;
           while($j <= $s_len-1) {
               if($s[$j] ne 'z') {
                   $flag = 1;
                   last;
               }
               $j ++;
           }

           if($flag) {
               $res .= $s[$i];
               $res .= substr($s, $i + 1, $j - $i -1);
               $res .= chr(ord($s[$j]) + 1);
               $res .= substr($s, $j + 1);
               last;
           }

           $j = $i+1;
           while($j <= $s_len-1) {
               if($t[$j] ne 'a') {
                   $flag = 1;
                   last;
               }
               $j ++;
           }

           if($flag) {
               $res .= $t[$i];
               $res .= substr($t, $i + 1, $j - $i - 1);
               $res .= chr(ord($t[$j]) - 1);
               $res .= substr($t, $j + 1);
               last;
           }

           print "No such string\n";
           exit;
        }
    }
    else {
        if($i == $s_len-1) {
           print "No such string\n";
           exit;
        }
        #$s[$i] = $t[$i]
        $res .= $s[$i];
        next;
    }
}

print $res,"\n";


#!/usr/bin/perl
use v5.10;
use integer;

sub min {
	my ($a, $b) = (shift, shift);
	return $a<$b ? $a:$b;
}

($n, $k, $l, $c, $d, $p, $nl, $np) = split / /, <>;
$ans = min(min($k*$l/$nl, $c*$d), $p/$np);
say $ans / $n;


#!/usr/bin/perl
use v5.10;

($n, $m) = split / /, <>;
($ans, $tmp) = (1, 0);
foreach (split / /, <>) {
	$tmp += $_;
	$tmp>$m and ++$ans and $tmp=$_;
}
say $ans;


#!/usr/bin/perl

use warnings;
use strict;

$\ = $/;

while(<>){
	chomp;

	my $iaz = 'a';

	s/./ $& le $iaz && 1 == length( $iaz ) ? $iaz ++ : $& /ge;

	print $iaz eq 'aa' ? $_ : -1;
	}


use strict;
my $n = <>;
my $ans = 0;
for(my $i = 1; $i < $n; $i++){
  if($n % $i == 0){
    $ans++;
  }
}
print $ans;


#!/usr/bin/env perl

use bigint;

sub factorial {
    my $n = shift;
    if ($n==0) {
        return 1;
    } else {
        return $n*factorial($n-1);
    }
}

sub subfactorial {
    my $n = shift;
    my $sub = shift;
    if ($n==$sub) {
        return 1;
    } else {
        return $n*subfactorial($n-1, $sub);
    }
}

$n = <STDIN>;
$result = $n % 2 ? 1 : 2;
print "$result\n";


chomp (my $n = <STDIN>);
chomp (my @arr = split /\s+/, <STDIN>);

my $minDiff = 99999;
my $x;
for ($i = 2; $i < @arr; $i++) {
  if (($arr[$i] - $arr[$i - 2]) < $minDiff) {
    $minDiff = ($arr[$i] - $arr[$i - 2]);
    $x = $i - 1;
  }
}

splice @arr, $x, 1;

my @res;
for ($i = 1; $i < @arr; $i++) {
  push @res, $arr[$i] - $arr[$i - 1];
}

@res = sort {$a <=> $b} @res;
printf "$res[-1]\n";


$n = <STDIN>;
$x = <STDIN>;
$y = <STDIN>;

@x = split(/ /,$x);
@y = split(/ /,$y);

print 'Karen';


print <STDIN> =~ /[HQ9]/ ? "YES" : "NO";


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

my ($n, $m) = split ' ',<>;
my $nsteps = int(($n+1)/2);
my $mul = int(($nsteps+$m-1)/$m);
print $mul*$m > $n ? -1 : $mul*$m;


chomp($_=<>);
chomp($a=<>);
@a=split//,$a;
for $i(1..@a){
/\|/, length $` > length $' ? s/$/pop@a/e : s/^/pop@a/e ;
}
/\|/, print length $` == length $' ? $_ : "Impossible"


#!/usr/bin/perl
use v5.10;

sub max {
	my ($x, $y) = (shift, shift);
	return $x>$y ? $x:$y;
}
($a, $b, $c, $d) = split / /, <>;
$Misha = max($a/10*3, $a-$a/250*$c);
$Vasya = max($b/10*3, $b-$b/250*$d);
($Misha==$Vasya and say "Tie") or ($Misha>$Vasya and say "Misha") or say "Vasya";


# read two lines of input
my $n = <STDIN>;
my $b = <STDIN>;
chomp ( $b );

# put each character into its own index
# in the array
my @arr = split m//, $b;

# variable which store the offset from the center
# in vertically and horizontally (on the x and y axes)
my $vert, $horz;
$vert = $horz = 0;

# calculate the final position after n moves
for ( my $i = 0; $i < @arr; $i += 1 ) {

    if ( $arr[ $i ] eq "U" ) { $vert += 1; }
    elsif ( $arr[ $i ] eq "D" ) { $vert -= 1; }
    elsif ( $arr[ $i ] eq "R" ) { $horz += 1; }
    elsif ( $arr[ $i ] eq "L" ) { $horz -= 1; }

}

# the answer is the difference between the number
# of moves and the euclidean distance from the center
print (@arr - ((abs $vert) + (abs $horz)));
print "\n";


#!/usr/bin/perl
# your code goes here
use v5.10;

chomp($n = <>);
say (($n%2 == 0) ? $n/2 : ($n-1)/2-$n);


#!/usr/bin/perl

use warnings;
use strict;

$\ = $/;

while(<>){
	my %A;
	my %B;

	$A{1} = 0;
	$A{2} = 0;
	map { $A{ $_ } ++ } split ' ', <>;
	map { $B{ $_ } ++ } split ' ', <>;
	my $f = 0;
	my $cnt = 0;

	for my $key (keys %A){
		my $diff = $A{ $key } - $B{ $key };
		$diff % 2 and ++ $f and last;
		$diff > 0 and $cnt += $diff / 2;
		}

	print $f ? -1 : $cnt;

	}


#!/usr/bin/perl
# your code goes here
use v5.10;

<> and say (join ' ', (sort {$a <=> $b} split / /, <>));


use strict;
use warnings;

my $username = substr(<>, 0, -1);
my %set_of_letters = map{$_ => 1} split(//, $username);
#my $number_of_different_letters = keys %set_of_letters;
#print $number_of_different_letters % 2 ? "IGNORE HIM!\n" : "CHAT WITH HER!\n";

print keys (%set_of_letters) % 2 ? "IGNORE HIM!\n" : "CHAT WITH HER!\n";


$\ = $/;

my %ans;

sub solve {
	my $i = shift;
#	print "<$i>";
	1 == length $i and do { push @ans, $i; return 0 };
	$solve = 0;

	for my $j (split //, 'RGB'){
		$ci = $i;
		if (1 < ($e = (() = $ci =~ /$j/g)) ){
#			print $e, '|', $ci;
			$ci =~ s/$j//;
#			print $ci;
			1 == length $ci and do { $ans{ $ci } ++; return 0 };
		#	$solve = 1;
			solve( $ci );
			}
		else {
			;
			}
		}

	for my $j ( qw(RGB GBR RBG) ){
		$ci = $i;
		($x, $y, $z) = split //, $j;
		if ($ci =~ /$x/ and $ci =~ /$y/){
			$ci =~ s/$x//;
			$ci =~ s/$y//;
			$ci =~ s/$z\K/$z/ or $ci =~ s/^/$z/;
#			print "$j:-$i";
			1 == length $ci and do { $ans{ $ci } ++; return 0 };
		#	$solve = 1;
			solve( $ci );
			}
		else {
			;
			}
		}

		#$solve and solve( $i );
	}

while(<>){
	$_ = <>, chomp;

	$_ = join '', sort split //;
	s/(.)\1{2,}/ $1 x 2 /eg;

	%ans = ();
	(1 == length) ? $ans{ $_ } ++ : solve( $_ );
	print sort keys %ans;

	}


#!perl -w
use strict;
use warnings;

main();

sub main {
    my ($a, $b, $r) = map int, split /\D/, <>;
    if ( ($r * 2 <= $a) && ($r * 2 <= $b) ) {
        print "First";
    } else {
        print "Second";
    }
}

__END__


$,=" ";
$_=<>;
chomp;
s/(A|E|I|O|U|Y)+/ /g;
my $ans=0;
for my $k (split / /)
{
  if($ans<length($k))
  {
    $ans=length($k);
  }
}
$ans++;

print $ans , "\n";


#!perl

use strict;
use warnings;

main();

sub main {
    my $str = <>;
    chomp $str;
    my @sym = split //, $str;
    my $nmax = 0;
    my $max = $sym[0];
    foreach my $i (@sym) {
        if ( $i gt $max ) {
            $max = $i;
            $nmax = 1;
        } elsif ( $i eq $max ) {
            $nmax++;
        }
    }
    print $max x $nmax;
}

__END__


#!/usr/bin/perl

$PI=3.14159265358979323846;
$MOD=1000000007;

#    <>=~/ /;
    <>=~/ (\d+) /;
#    <>=~/ (\d+) (\d+) /;

$max=max($`,$1,$');
$min=min($`,$1,$');
$sum=$`+$1+$';
$dif=$sum-$max;

if ($dif<$max){
	print "Impossible";
	}
elsif ($sum %2){
	print "Impossible";
	}
else{
	$a=($dif-$max);

$x=$`+$1;
$y=$1+$';
$z=$'+$`;

$x-=$a;
$y-=$a;
$z-=$a;
$m=min($x,$y,$z);
$x-=$m;
$y-=$m;
$z-=$m;
# print " $x $y $z\n";
$x+=$a/2;
$y+=$a/2;
$z+=$a/2;
print "$x $y $z\n";
}

#***********SUBS************

sub num {$a <=> $b}
sub num_rev {$b <=> $a}
sub rev {$b cmp $a}

sub p{print}
sub n{print "\n"}
sub pn{p,n}
sub pn_mas {pn for @_}

# Transpose "charbox"
sub transpose{
    $i=@m=@_;
    chomp @m;
    while ($i--){
        $t[$i]=~s/$/chop/e for @m
    }
return @t
}

# Transpose "value sets"
sub transpose_space{
    my @t;
    for (@_){
        my $j=0;
        s/\d+/($t[$j++].="$& ")?$&:$&/eg;
        }
    chop @t;
return @t
}

sub div{
    my ($n, $k)=@_;
return ($n - $n % $k) / $k
}

sub uniq{
    my @m=sort @_;
    push @u, my $i=shift @m;
    for (@m){
        $i eq $_ or push @u, $_;
        $i=$_;
        }
return @u
}

sub max{
    my $max=shift;
    $max<$_ and $max=$_ for @_;
return $max
}

sub min{
    my $min=shift;
    $min>$_ and $min=$_ for @_;
return $min
}

# count (kas_ieskoma, masyvas)
sub count{
    my $i=0;
    $_ eq $_[0] and $i++ for @_;
return --$i
}


#Scott Heinrich - A01273823
use 5.010;

my $n = <>;
chomp($n);

my $xstring = <>;
chomp($xstring);

my $x = () = $xstring =~ /x/g;
my $X = () = $xstring =~ /X/g;
my @xArray = split(//, $xstring);

if ($x > $X)
{
  my $r = ($x-$X)/2;
  say $r;
  my $i = 0;
  while($r > 0)
  {
    if($xArray[$i] eq "x")
    {
      $r--;
      $xArray[$i] = "X";
    }
    $i++;
  }
}
else
{
  my $r = ($X-$x)/2;
  say $r;
  my $i = 0;
  while($r > 0)
  {
    if($xArray[$i] eq "X")
    {
      $r--;
      $xArray[$i] = "x";
    }
    $i++;
  }
}
say join("", @xArray);


#	use integer;
#	use List::Util qw(max maxstr min minstr sum);
$\ = $/;

{
local $/;
$_ = <DATA>;
s/ \( [^()]*? \) //xg;
%h = split
}

while(<>){
	chomp;
	print $_ < 20 ?
	$h{ $_ }
	:
	do {
	($a, $b) = split // ;
	$h{ $a.q(0) } . (
	$b ? q(-) . $h{ $b } : '' )
	}

}

__DATA__
0 	zero (nought) 	10 	ten
1 	one 	11 	eleven
2 	two 	12 	twelve (a dozen) 	20 	twenty (a score)
3 	three 	13 	thirteen 	30 	thirty
4 	four 	14 	fourteen 	40 	forty (no "u")
5 	five 	15 	fifteen (note "f", not "v") 	50 	fifty (note "f", not "v")
6 	six 	16 	sixteen 	60 	sixty
7 	seven 	17 	seventeen 	70 	seventy
8 	eight 	18 	eighteen (only one "t") 	80 	eighty (only one "t")
9 	nine 	19 	nineteen 	90 	ninety (note the "e")


#!/usr/bin/perl

$PI=3.14159265358979323846;
$MOD=1000000007;

#    <>=~/ /;
#    <>=~/ (\d+) /;
#    <>=~/ (\d+) (\d+) /;

while (<>){
	chomp;
	($a,$b,$c,$d)=@_=sort num split/ /;

	$t=$s=0;
	$d<$b+$c and $t++;
	$c<$b+$a and $t++;
	$d==$b+$c and $s++;
	$c==$b+$a and $s++;

	$t and ((print "TRIANGLE\n"), next);
	$s and ((print "SEGMENT\n"), next);
	print "IMPOSSIBLE\n";

	}

#***********SUBS************

sub num {$a <=> $b}
sub num_rev {$b <=> $a}
sub rev {$b cmp $a}

sub p{print}
sub n{print "\n"}
sub pn{p,n}
sub pn_mas {pn for @_}

# Transpose "charbox"
sub transpose{
    $i=@m=@_;
    chomp @m;
    while ($i--){
        $t[$i]=~s/$/chop/e for @m
    }
return @t
}

# Transpose "value sets"
sub transpose_space{
    my @t;
    for (@_){
        my $j=0;
        s/\d+/($t[$j++].="$& ")?$&:$&/eg;
        }
    chop @t;
return @t
}

sub div{
    my ($n, $k)=@_;
return ($n - $n % $k) / $k
}

sub uniq{
    my @m=sort @_;
    push @u, my $i=shift @m;
    for (@m){
        $i eq $_ or push @u, $_;
        $i=$_;
        }
return @u
}

sub max{
    my $max=shift;
    $max<$_ and $max=$_ for @_;
return $max
}

sub min{
    my $min=shift;
    $min>$_ and $min=$_ for @_;
return $min
}

# count (kas_ieskoma, masyvas)
sub count{
    my $i=0;
    $_ eq $_[0] and $i++ for @_;
return --$i
}


<>;
chomp(my $str = lc <>);
my %hash = map{$_, 1} split //, $str;
my $ans = "NO\n";
$ans = "YES\n" if (scalar keys %hash == 26);
print $ans;


use strict;
use warnings;

my $x = <>;
chomp $x;

if ($x > 1) {
	print "$x $x\n";
} else  {
	print "-1\n";
}


#!/usr/bin/perl
use warnings;
use strict;
chomp( my $k = <STDIN> );
my @ai = split( / /, <STDIN> );
@ai = reverse sort { $a <=> $b } @ai;
my $sum   = 0;
my $count = 0;

while ( $sum < $k ) {
    last if $count == @ai;
    $sum += $ai[ $count++ ];

    #print $count," ",$sum,"\n";
}
$count = -1 if $count == @ai && $sum < $k;
print $count;


use bigint;

( $n, $k ) = split ' ', <>;

print $k < 2 ? $n : eval '0b' . 1 x length sprintf "%b", $n


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

chomp(my $line = <STDIN>);
(my $n, my $time) = split(" ", $line);
chomp($line = <STDIN>);
my @children = split("", $line);
for (my $j = 0; $j < $time; $j++) {
    my $i = $n - 1;
    while ($i > 0) {
        if ($children[$i] eq 'G' && $children[$i - 1] eq 'B') {
            $children[$i] = 'B';
            $children[$i - 1] = 'G';
            $i -= 2;
        } else {
            $i -= 1;
        }
    }
}
print @children;


$_=<>;
chomp;
s/\[\]/p/g;
s/\(\)/s/g;
s/8</z/g;
$a=$_;

$_=<>;
chomp;
s/\[\]/p/g;
s/\(\)/s/g;
s/8</z/g;
$b=$_;

while ($a){
	$A=chop $a;
	$B=chop $b;
	$A eq 'p' and $B eq 's' and $i++;
	$A eq 'p' and $B eq 'z' and $i--;
	$A eq 's' and $B eq 'p' and $i--;
	$A eq 's' and $B eq 'z' and $i++;
	$A eq 'z' and $B eq 'p' and $i++;
	$A eq 'z' and $B eq 's' and $i--;
	}
print $i ? ($i > 0 ? "TEAM 1 WINS" : "TEAM 2 WINS" ) : "TIE"


<>; $_ = <>; chomp;
s/RU|UR/1/g;
print length;


$n = <>;

if ($n % 2) {
    print "black\n";
}
else {
    print "white\n1 2\n";
}


#!/usr/bin/perl

use strict;
use warnings;

my @str=split('',<>);
my $f=0;
my $s=0;
foreach my $count(0..$#str-1){
	if($str[$count]==4){
		$f++;
	}
	if($str[$count]==7){
		$s++;
	}
}
if($f==0 && $s==0){
	print -1;
}else{
	if($f>=$s){
		print 4;
	} else{
		print 7;
	}
}


#!/usr/bin/perl
use strict;
use warnings FATAL => 'all';
use List::MoreUtils qw(firstidx);
my $i=0;
for(<STDIN>)
{
     chomp;
     $i++;
     $_=index $_,'1';
     if($_!=-1)
     {
          $_=abs ($_/2 +1-3)+abs($i-3);
          print;
          last;
     }}


#!perl

use strict;
use warnings;

my ($m,$n) = split /\s+/ , <STDIN> ;
my $out;
if (  $m * $n % 2 ){
    $out = ($m*$n-1)/2 ;
}else{
    $out = $m*$n /2 ;
}

print "$out\n" ;


($a, $b) = split " ", <>;
($cnt, $burned, $to_burn) = (0, 0, $a);
while ($to_burn > 0)
{
    ++$cnt, --$to_burn, ++$burned;
    if ($burned == $b)
    {
        ++$to_burn;
        $burned = 0;
    }
}

print $cnt;


#!/usr/bin/env perl

use bigint;

sub factorial {
    my $n = shift;
    if ($n==0) {
        return 1;
    } else {
        return $n*factorial($n-1);
    }
}

sub subfactorial {
    my $n = shift;
    my $sub = shift;
    if ($n==$sub) {
        return 1;
    } else {
        return $n*subfactorial($n-1, $sub);
    }
}

$n = <STDIN>;
$result = $n / 2520;
print "$result\n";


#!/usr/bin/perl

$line = <STDIN>;
$l = <STDIN>;

my @array1 = split ' ', $l;

$result = 0;
for my $val ( @array1 ){
	$result += abs($val);
}

print $result;


use strict;
use feature "state";
use Math::BigInt;

sub g {
	my $arg_bits = shift;
	state ($bits, $currentbit, $allset);
	if ($arg_bits != $bits) {
		$bits = $arg_bits;
		$currentbit = $bits - 2;
		$allset = Math::BigInt->new("2");
		$allset->bpow($bits);
		$allset->bdec();
	}
	my $v;
	if ($currentbit >= 0) {
		my $m = Math::BigInt->new("1");
		$m->blsft($currentbit) if $currentbit > 0;
		$v = $allset->copy();
		$v->bxor($m);
		$currentbit--;
	}
	$v;
}

sub calc {
	my @a = map Math::BigInt->new($_), @_;
	my @w = map length($_->as_bin()) - 2, @a;
	my $s = 0;

	for ($w[0]..$w[1]) {
		while (my $g = g($_)) {
			if ($a[0]->bcmp($g) <= 0 && $a[1]->bcmp($g) >= 0) {
				$s++;
			}
		}
	}
	$s;
}

if ($ENV{TEST}) {
	use Test::More;
	for (<DATA>) {
		chomp;
		my ($s1, $s2, $expect) = split;
		is(calc($s1, $s2), $expect);
	}
	done_testing();
} else {
	my @s = split(" ", <STDIN>); chomp(@s);
	print calc(@s), "\n";
}

__DATA__
5 10 2
2015 2015 1
100 105 0
72057594000000000 72057595000000000 26


#!perl
$inp = <STDIN>;
@human = split(/\D/,$inp);
if (!$human[0] and $human[1]) {
	print "Impossible";
} else {
	@result = ($human[1] > $human[0]? $human[1]: $human[0], $human[0] + $human[1] - ($human[1]? 1: 0));
	print "@result";
}


#!/usr/bin/env perl

use strict;
use warnings;
use feature qw/ say /;

# essential
my @tokens = ();

sub read_line {
    chomp (my $line = <STDIN>);
    return $line;
}

sub read_token {
    @tokens = split q{ }, read_line() if @tokens == 0;
    return shift @tokens;
}

sub min {
    my @numbers = @_;
    my $min = shift @numbers;
    for ( @numbers ) {
        $min = $min<$_ ? $min : $_;
    }
    return $min;
}

sub max {
    my @numbers = @_;
    my $max = shift @numbers;
    for ( @numbers ) {
        $max = $max > $_ ? $max : $_;
    }
    return $max;
}

sub sum {
    my @numbers = @_;
    my $sum = 0;
    for (@numbers) {
        $sum += $_;
    }
    return $sum;
}

sub remainder {
    my ($dividend, $divisor) = @_;
}

# solve

my $n = read_token;
my $m = read_token;
my $k = read_token;

my $min = min($m, $k);

if ($min >= $n) {
    say 'Yes';
}
else {
    say 'No';
}


#!usr/bin/perl
#use warnings;
#use strict;
#use autodie;
#use diagnostics;
use utf8;
use 5.010;
use 5.012;
use 5.014;
my($n,$dif,$sum,$count,$add)=(0,2,1,1,2);
chomp($n=<STDIN>);
while($count ne $n)
{
    $count++;
    $sum+=$dif;
    $dif+=$add;
    $add++;
}
say $sum;


# nEro
$n=<STDIN>;
$s=<STDIN>;
@a=split('',$s);
foreach $i (@a)
{
	if($i ge 'A' and $i le 'Z'){ $ans++;}
	if($mx<$ans){$mx=$ans;}
	if($i eq ' '){ $ans=0;}

}
print 0+$mx,"\n";


#!/usr/local/bin/perl
chomp($text1 = <STDIN>);
if(defined(text1)){
    chomp($text2 = <STDIN>);
    $text2 = scalar reverse $text2;
    if($text1 eq $text2) {
        print "YES\n";
    }
    else {
        print "NO\n";
    }
}


($n, $m) = split " ", <>;
print $n > $m ? "First" : "Second"


sub solve {
	my $n = shift;
	print int($n / 3) * 2 + int($n % 3 > 0);
};

my $n = <>;
solve($n);


#!/usr/bin/perl

use strict;

my ( $n, $pos, $l, $r ) = split ' ', <>;
my $dl = abs($pos - $l);
my $dr = abs($pos - $r);
my $ans = 0;
if (1 < $l && $r < $n) {
    $ans = ($dl < $dr ? $dl : $dr) + $r - $l + 2;
} elsif (1 < $l) {
    $ans = $dl + 1;
} elsif ($r < $n) {
    $ans = $dr + 1;
}
print $ans, "\n";


print ((sort {$a<=>$b} split/ /,<>)[0]%2? Akshat:Malvika)


#!/usr/bin/perl
# your code goes here
use v5.10;

$atb{$_}++ foreach(split //, <>);
$atb{$_}++ foreach(split //, <>);
$btb{$_}++ foreach(split //, <>);
$btb{"\n"} = $atb{"\n"};
# say scalar(keys %atb);
# say scalar(keys %btb);
foreach (keys %atb) {
	# say $_,': ',$atb{$_},' ', $btb{$_};
	$atb{$_}!=$btb{$_} and say "NO" and exit;
}
foreach (keys %btb) {
	# say $_,': ',$atb{$_},' ', $btb{$_};
	$atb{$_}!=$btb{$_} and say "NO" and exit;
}
say "YES";


print eval join '', map s/ \d+ /-/r, join ' ', sort {$b <=> $a} split ' ', <>


#!/usr/bin/perl

<>;

my $line = <>;
chomp $line;

my @seq = split /\s+/, $line;
my @oseq = sort {$a <=> $b} @seq;
#print "@oseq\n";
my $sum = 0;
my $pred;
foreach my $i (0 .. $#oseq) {
	#print ($oseq[$i]-$pred) if $i % 2;
	$sum += ($oseq[$i]-$pred) if $i % 2;
	$pred = $oseq[$i];
}
#print "\n";
print "$sum\n";


$_ = <>, chomp;
for $i (0 .. length){
for $j (a .. z){
	substr $c = $_, $i, 0, $j;
	$a = $c if $c eq reverse $c
}
}
print $a ? $a : NA


use List::Util qw(sum);

my $cups = sum (split " ", <>);
my $meds = sum (split " ", <>);
my $shelves = <>;
if ((int $cups / 5 + ($cups % 5 > 0)) + (int $meds / 10 + ($meds % 10 > 0)) <= $shelves) {
    print "YES";
} else {
    print "NO";
}


use 5.016;
use strict;
use warnings;

sub can {
  my ($d, @songs) = @_;

  my $c = 0;
  while (@songs) {
    return -1 if $d < $songs[0];

    $d -= shift @songs;

    if (@songs) {
      return -1 if $d < 10;
      $d -= 10;
      $c += 2;
    }
  }

  $c += int($d / 5);

  $c;
}

my (undef, $d) = split ' ', <>;
my @songs = split ' ', <>;

say can($d, @songs);


$a{ $_ }++ for split ' ', <>;
while ( ($n, $c)=each(%a) ) {
	$out=[qw(0 2 3 3 3)]->[$c-1] * $n;
	$maxout=$out>$maxout?$out:$maxout;
	$sumall+=$c*$n;
}
print $sumall-$maxout, "\n";


#!/usr/bin/perl -w

use strict;

$_ = <>;
chomp;
print join '+', sort { $a <=> $b } split /\+/;
print "\n";


$ch=<>;
chomp$ch;
$l=length$ch;

for($i=1;$i<=$l;$i++){
$nom{$ch}=1;
$ch=substr($ch,$l-1,1).substr($ch,0,$l-1);

}
@number=keys%nom;
$num=@number;
print $num;


#!/usr/bin/perl

use strict;
use warnings;

chomp($_ = <>);
chomp(my $n = <>);

for (split //, lc) {
    my $m = ord $_;
    if ($m < 97 + $n) {
        print chr($m & ~0x20);
    } else {
        print chr($m | 0x20);
    }
}


#!/usr/bin/perl

use warnings;
use strict;

$\ = $/;

while(<>){
	my( $n , $m, $z ) = split;
	my $cnt = 0;

	for (1 .. $z){
		($_ % $n) + ($_ % $m) or $cnt ++;

		}

	print $cnt;
	}


#!/usr/bin/perl

$input_line = <STDIN>;
chop($input_line);
($n,$k)= split(/[ \t]+/,$input_line);
$counter = 0;
$input_line = <STDIN>;
chop($input_line);
@a= split(/[ \t]+/,$input_line);
@s=();
@t=();
$i = 0;
for ($counter = 0; $counter < $n; $counter++){
	unless ($a[$counter] ~~ @s){$s[$i] = $a[$counter];	$t[$i++]=$counter+1;}
}

if ($k <= $i){
	print("YES\n");
	for($i=0; $i < $k; $i++){print ("$t[$i] ");}
}else{
	print("NO");
}
print ("\n");


#!/usr/bin/perl

use warnings;
use strict;

$\ = $/;

while(<>){
	my( $n, $m, $k ) = split;
	$_ = <>;
	s/\d+/ $& > $k || $& == 0 ? "x" : "o" /eg;
	s/\s//g;
	substr $_, $m - 1, 1, 'X';

	my @lengths;
	/Xx*o/ and push @lengths, length $&;
	$_ = reverse;
	/Xx*o/ and push @lengths, length $&;

	print 10 * ( ( sort { $a <=> $b } @lengths )[ 0 ] - 1 );
	}


my $str = <STDIN>;
my $f = 0;
my $n = 0;
my @names = ("Danil", "Olya", "Slava","Ann","Nikita");
for (my $i = 0; $i < 5; $i++){
my $idx  = index($str, $names[$i]);
my $idx2 = index($str, $names[$i],$idx + 1);
	if ($idx != -1) {
		if ($idx2 != -1) {
			$n = 1;
		}
		else {
			$f++;
		}
	}
}
if ($f == 1 && $n == 0){
	print "YES";
}
else{
	print "NO";
}


$have = 0;
foreach $s (<STDIN>) {
    if ($s =~ /C|M|Y/) {
        $have = 1;
    }
}
print $have eq 1 ? "#Color\n" : "#Black&White\n";


#!/usr/bin/env perl
package Codeforces::Task::_;
use v5.10;
use strict;
#use warnings;

sub min{my($a,$b)=@_;if($a<$b){return$a;}else{return$b;}}
sub max{my($a,$b)=@_;if($a>$b){return$a;}else{return$b;}}

sub solve {
    my $a = <>;
    $a =~ s/(?<=.)dot(?=.)/\./g;
    $a =~ s/(?<=.)at(?=.)/@/;
    print "$a\n";
}

sub main {
    my $t = 1;
#    $t = int(<>);
    while ($t--) {
        solve();
    }
    return 0;
}

exit(main(@ARGV));


#!/usr/bin/perl

use warnings;
use strict;

$\ = $/;

while(<>){
	my( $l, $r, $x, $y, $k, $ok ) = split;

	for my $i ( $x .. $y ){
		$l <= $i * $k and $i * $k <= $r and do {
			$ok = 1;
			last;
			}
		}

	print $ok ? "YES" : "NO";

	}


#!/usr/bin/perl
$_ = <>;
if (/[aeiouy]\W*$/i) {
    print "YES"
} else {
    print "NO";
}


#!/usr/bin/perl

use warnings;
use strict;

$\ = $/;

while(<>){
	my( $A, $B ) = split;
	my( $x, $y, $z ) = split ' ', <>;

	my $nA = $x * 2;
	my $nB = $z * 3;
	$nA += $y;
	$nB += $y;

	$nA -= $A;
	$nB -= $B;

	my $need = ( $nA >= 0 ? $nA : 0 ) + ( $nB >= 0 ? $nB : 0 );

	print $need;
	}


#!/usr/bin/perl

use warnings;
use strict;

$\ = $/;

<>;

while(<>){
	chomp;

	$_ = 'a' x $_;

	print /^(a{3}|a{7})+$/ ? "YES" : "NO";

	}


#!/usr/bin/perl

$PI=3.14159265358979323846;
$MOD=1000000007;

#    <>=~/ /;
#    <>=~/ (\d+) /;
#    <>=~/ (\d+) (\d+) /;

while(<>=~/ /){
	print max(0,3*$`-$');
	n();
	}

#***********SUBS************

sub num {$a <=> $b}
sub num_rev {$b <=> $a}
sub rev {$b cmp $a}

sub p{print}
sub n{print "\n"}
sub pn{p,n}
sub pn_mas {pn for @_}

# Transpose "charbox"
sub transpose{
    $i=@m=@_;
    chomp @m;
    while ($i--){
        $t[$i]=~s/$/chop/e for @m
    }
return @t
}

# Transpose "value sets"
sub transpose_space{
    my @t;
    for (@_){
        my $j=0;
        s/\d+/($t[$j++].="$& ")?$&:$&/eg;
        }
    chop @t;
return @t
}

sub div{
    my ($n, $k)=@_;
return ($n - $n % $k) / $k
}

sub uniq{
    my @m=sort @_;
    push @u, my $i=shift @m;
    for (@m){
        $i eq $_ or push @u, $_;
        $i=$_;
        }
return @u
}

sub max{
    my $max=shift;
    $max<$_ and $max=$_ for @_;
return $max
}

sub min{
    my $min=shift;
    $min>$_ and $min=$_ for @_;
return $min
}

# count (kas_ieskoma, masyvas)
sub count{
    my $i=0;
    $_ eq $_[0] and $i++ for @_;
return --$i
}


#!/usr/bin/perl

use warnings;
use strict;

$\ = $/;

while(<>){
	@_ = split ' ', <>;

	my $sum = 0;

	$sum += $_ for @_;

	my $max = ( sort { $b <=> $a } @_ )[ 0 ];

	while( 1 ){
		if( $max * @_ - $sum > $sum ){
			last;
			}
		else{
			$max ++;
			}
		}

	print $max;
	}


# Codeforces Beat Round #72
# Problem A -- Chips
$n = <>;
$result = ($n / 2 * 3);
print "$result\n";


#! /usr/bin/env perl

use 5.020;
use warnings;

sub max {
    my $m = shift;
    while (defined (my $n = shift)) {
        if ($n > $m) { $m = $n }
    }
    return $m;
}

my $n = <>;
chomp $n;

say 0 + max grep /\d/, $n, $n =~ s/\d$//r, $n =~ s/\d(?=.$)//r;


#!/usr/bin/perl

use warnings;
use strict;

$\ = $/;

while(<>){
	my( $p, $y ) = split;

	my $OK = -1;

	my $i = $y;

	while( $OK == -1 ){
		last if $i == $p;
		my $si = sqrt $i;
		my $min = $si;
		$p < $min and $min = $p;
		my $ok = 1;
		for my $j ( reverse 2 .. $min ){
			$i % $j == 0 and $ok = 0;
			}
		$ok == 1 and $OK = $i;
		$ok == 1 and last;
		$i --;
		}

	print $OK;
	}


use strict;
use warnings;

sub gcd {
    my ($a, $b) = @_;
    return $a if !$b;
    return gcd($b, $a % $b);
}

my ($a, $b, $n) = split ' ', <>;

my $res = 1;
while ($n) {
    $n -= gcd($n, $res ? $a : $b);
    $res = 1 - $res;
}

print $res;


#!/usr/bin/perl

use warnings;
use strict;

$\ = $/;

while(<>){
	my $i = 0;

	/Q.*?A.*?Q(?{ $i ++ })(?!)/;

	print $i;
	}


#!/usr/bin/env perl

use strict;
use warnings;
use feature qw /say/;

<STDIN>;

my $str = <STDIN>;
chomp $str;
my $last_idx = length($str) - 1;

my $min = 104;
my @actg = qw/ A C T G /;

LABEL:
for my $idx (0..$last_idx-3) {
    my $i = 0;
    my $count = 0;
    while ( $i < 4 ) {
        $count += count_of_replacing(substr($str, $idx+$i, 1), $actg[$i++]);
        if ( $count > $min ) {
            next LABEL;
        }
    }
    $min = $count;
}

say $min;

sub count_of_replacing {
    my ($a, $b) = @_;
    my $count = abs(ord($a) - ord($b));
    $count = ($count > 13) ? 26-$count : $count;
}


#!/usr/bin/perl

use strict;
use warnings;
use integer;

<>;
while (<>) {
	/(\d+)/;
	print + ($1 / 7) + ($1 % 7 > 0), "\n";
}


#!/usr/bin/perl -w

use strict;

chomp($_ = <>);
my ($n, $m, $k) = split;
chomp($_ = <>);
my @a = split;
@a = sort { $b <=> $a } @a;
if ($k >= $m) {
    print "0\n";
    exit 0;
}
my $res = -1;
for my $i (0 .. $#a) {
    $k += $a[$i] - 1;
    if ($k >= $m) {
        $res = $i + 1;
        last;
    }
}
print "$res\n";


#!/usr/bin/perl -w

use strict;

chomp(my $n = <>);
if ($n <= 2) {
    print "-1\n";
} else {
    my @a = reverse 1 .. $n;
    print "@a\n";
}


use 5.016;
use strict;
use warnings;

my ($l, $b) = split ' ', <>;
my $c = 0;
while ($l <= $b) {
  $c++;
  $l *= 3;
  $b *= 2;
}

say $c;


use Math::BigInt qw(blcm);use integer;($x,$y,$a,$b)=split/ /,<>;$l=blcm($x,$y);print$b/$l-($a-1)/$l;


#!/usr/bin/perl

use warnings;
use strict;

$\ = $/;

while(<>){
	my( $k, $A, $B ) = split;

	my $cnt = eval join '+', map { int $_ / $k } $A, $B;

	$cnt ||= -1;

	not int $A / $k and $B % $k and $cnt = -1;
	not int $B / $k and $A % $k and $cnt = -1;

	print $cnt;
	}


use List::Util qw/sum/;

my $n = <>;
my $ticket = <>;
chomp ($n, $ticket);
my $first = substr $ticket, 0, $n/2;
my $second = substr $ticket, $n/2;
print +($ticket =~ /^[47]+$/ && (sum split //, $first) == (sum split //, $second)) ? 'YES' : 'NO';


$_=<>;chomp;
%h = map {$_=> 1;} split / /;
print( 4 - scalar keys %h);


#!/usr/bin/perl

use 5.012;
use warnings;
use integer;

my $num = <>;
print $num / 5 + ($num % 5 != 0);


#!/usr/bin/env perl

use strict;
use warnings;

my $line = <>;
chomp $line;

my ($a, $b) = split ' ', $line;

$b = reverse($b);

print $a + $b, "\n";


#!/usr/bin/env perl

use strict;
use warnings;
use feature qw/ say /;

# essential
my @tokens = ();

my $n = read_token();
my $k = read_token();

while ( $k > 0 ) {
    my $r = $n % 10;
    if ( $r == 0 ) {
        $n = int($n / 10);
        $k--;
    }
    else {
        $r = min($r, $k);
        $k -= $r;
        $n -= $r;
    }
}
say $n;

sub read_line {
    chomp (my $line = <STDIN>);
    return $line;
}

sub read_token {
    @tokens = split q{ }, read_line() if @tokens == 0;
    return shift @tokens;
}

sub min {
    my @numbers = @_;
    my $min = shift @numbers;
    for ( @numbers ) {
        $min = $min<$_ ? $min : $_;
    }
    return $min;
}

sub max {
    my @numbers = @_;
    my $max = shift @numbers;
    for ( @numbers ) {
        $max = $max > $_ ? $max : $_;
    }
    return $max;
}

sub sum {
    my @numbers = @_;
    my $sum = 0;
    for (@numbers) {
        $sum += $_;
    }
    return $sum;
}


#!/bin/bash/perl
use warnings;
$inputLine=0;
$possible=1;

while($inputLine!=8 && $possible==1){
    $inputRow1=<>;
    @inputRow=split(" ",$inputRow1);
    $inputRow1=$inputRow[0];
    @inputRow=split("",$inputRow1);
    #first check alternate
    if(($inputRow1 ne "WBWBWBWB")&&($inputRow1 ne "BWBWBWBW") ){
        $possible=0;
    }
    ++$inputLine;
}
if($possible==1){
    print "YES";
}
else{
    print "NO";
}


#!/usr/bin/perl -w
$_ = <>;
chomp;
my $n = $_;

my $m = sqrt;

my @flag = ();

for (2..$m) {
    $flag[$_] = 1;
}
my $i;
my $j;
my $len_prime;
my @nums;
my @prime;
my $re;

for ( $i = 2; $i <= $m; ++$i) {
    if ( $flag[$i] == 1 ) {
        for ( $j = $i * 2; $j <= $m; $j += $i) {
            $flag[$j] = 0;
        }
    }
}
for ( $i = 2; $i <= $m; ++$i ) {
    if ( $flag[$i] == 1 ) {
        push @prime, $i;
    }
}
#print "@prime\n";

$len_prime = @prime;
$i = 0;
$nums[0] = 1;

while ( $n > 1 ) {
    last unless defined $prime[$i];

    while ( $n % $prime[$i] == 0) {
        if ( $nums[-1] != $prime[$i] ) {
            push @nums, $prime[$i];
        }
        $n /= $prime[$i];
    }
    $i++;
}
push @nums, $n;

$re = 1;
for ( @nums ) {
    $re *= $_;
}
$\ = $/;

print $re;


print <> =~ /[^aeioun][^aeiou]/ ? "NO" : "YES"


#!/usr/bin/perl
# your code goes here
use v5.10;

chomp($line = <>);
my @a = ();
length($_)>0 and push @a,$_ foreach(split "WUB", $line);
say join ' ', @a;


#!/usr/bin/perl -w
use strict;
use warnings;

my $k = <>;
chomp $k;
my $s = <>;
chomp $s;
my @str = split(//, $s);

my %letters;
my @res;

my $num = 0;

for (my $i = 0; $i <= $#str; $i++) {
  if (!defined($letters{$str[$i]})) {
    $letters{$str[$i]} = 1;
    push(@res, $i);
    $num++;
  }
  if ($num == $k) {
    last;
  }
}
push(@res, $#str + 1);

if ($num != $k) {
  print "NO\n";
} else {
  print "YES\n";
  for (my $i = 0; $i < $#res; $i++) {
    print substr($s, $res[$i], $res[$i+1] - $res[$i]);
    print "\n";
  }
}


@a=qw(Sheldon Leonard Penny Rajesh Howard);
$n=<>;
$i=1;

while ($n>$i*5){
$n-=$i*5;
$i*=2;
}

print $a[($n-1)%($i*5)/$i]


use strict;
use warnings;

my ($n, $m) = split / /, <STDIN>;
my $i = 1;
while ($i <= $n && $i * 5 + $m <= 240){
	$m += $i * 5;
	++$i;
}
print $i - 1;


#!/usr/bin/perl

for $next (1..11) {
    $var = <STDIN>;
    chomp $var;
    push(@seq, $var);
}

for $next (1..11) {
    $var = pop @seq;
    $aresult = sqrt(abs($var));
    $bresult = ($var ** 3) * 5;
    $result = $aresult + $bresult;

    if($result <= 400) {
        printf STDOUT q{ f(%d) = %.2f }, $var, $result;
        print STDOUT "\n";
    }
    if($result > 400) {
        printf STDOUT q{ f(%d) = MAGNA NIMIS! }, $var;
        print STDOUT "\n";
    }
}


use strict ;
use warnings ;

my @input = split(/ /,<STDIN>);

my $n = $input[0];
my $a = $input[1];
my $b = $input[2];

my @result = (1..$n);

my $answer = 0;

foreach(@result){
	if($_>$a && $_>=($n-$b)){
		$answer++;
	}
}
print $answer;


chomp($_ = <stdin>); my ($c, $all, $n) = split(" "); for(1..$n){ $all -= $c*$_ } if($all >= 0){ print "0\n" }else{ print abs($all),"\n" }


use strict;
use warnings;

use Data::Dumper;

my $stop= 1;
my %as;

sub main {

    my $in= *STDIN;

    my $r= <$in>; chomp($r);

    $as{$r}= 1;

    my $y= 0;
    while (! $y) {
        ($y, $r)= _f($r);
        $stop++;
        exit if $stop == 200;
    }

    print scalar(keys(%as));
}

sub _f {
    my ($n)= @_;

    $n += 1;
    my @x= split('',$n);

    while ($x[(scalar(@x)-1)] == 0) {
        pop @x;
    }

    my $res= (
        scalar(@x) == 1 &&
        (exists $as{join('', @x)})
    );
    $as{join('', @x)}= 1;

    return (
        $res,
        join('', @x)
    );

}

main() unless caller();


#!/usr/bin/perl

use warnings;
use strict;

$\ = $/;

while(<>){
	$_ = <>, chomp;

	s/\b$1\b// while /(\b\d+\b).*?(\b\1\b)/;

	print 0 + split;
	print join ' ', split;
	}


chomp($m=<>);
@cs = split / /, <>;
($x, $y) = split / /, <>;
$sum+=$_ foreach (@cs);
for $v (0..$m-1) {
	$left += $cs[$v];
	$right = $sum - $left;
	# print "v=$v, left=$left, right=$right\n";
	if (($left>=$x && $left<=$y) && ($right>=$x && $right<=$y)) {
		print +($v+2), "\n";
		exit;
	}
}

print "0\n";