use List::Util qw(min max sum);

use bigint;

my @cnt = split / /, <>;
@cnt = sort {$a <=> $b} @cnt;
$ans = int (($cnt[0] + $cnt[1] + (min ($cnt[2], 2 * ($cnt[0] + $cnt[1])))) / 3);
print $ans, "\n";

use List::Util qw(min max);

use bigint;
use integer;

my @cnt = split / /, <>;
@cnt = sort {$a <=> $b} @cnt;
my $ans = $cnt[0];
$cnt[1] -= $cnt[0];
$cnt[2] -= $cnt[0];
$ans += min ($cnt[1], $cnt[2], ($cnt[1] + $cnt[2]) / 3);
print $ans, "\n";

use List::Util qw(min max);

use bigint;
use integer;

my @cnt = split / /, <>;
@cnt = sort @cnt;
my $ans = $cnt[0];
$cnt[1] -= $cnt[0];
$cnt[2] -= $cnt[0];
$ans += min ($cnt[1], $cnt[2] / 2);
print $ans, "\n";

use List::Util qw(min max);

use bigint;
use integer;

my @cnt = split / /, <>;
@cnt = sort @cnt;
my $ans = $cnt[0];
$cnt[1] -= $cnt[0];
$cnt[2] -= $cnt[0];
$ans += min ($cnt[1], $cnt[2], ($cnt[1] + $cnt[2]) / 3);
print $ans, "\n";

use List::Util qw(min max sum);

use bigint;
use integer;

my @cnt = split / /, <>;
@cnt = sort {$a <=> $b} @cnt;
$ans = ($cnt[0] + $cnt[1] + (min ($cnt[2], 2 * ($cnt[0] + $cnt[1])))) / 3;
print $ans, "\n";

use List::Util qw(min max sum);

use bigint;
use integer;

my @cnt = split / /, <>;
@cnt = sort {$a <=> $b} @cnt;
$cnt[2] = min ($cnt[2], 2 * ($cnt[0] + $cnt[1]));
$ans = (sum @cnt) / 3;
print $ans, "\n";


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

my ($n, $k) = split ' ',<>;
my @input = split ' ', <>;
my @data;
for my $i(0..@input-1){
    push @data, [$input[$i], $i+1];
}
@data = sort {$a->[0] <=> $b->[0]} @data;
my ($sum,@res) = (0,());
foreach(@data){
    last if $sum + $_->[0] > $k;
    $sum += $_->[0];
    push @res, $_->[1];
}
print scalar @res , "\n@res";


<>;

map $h{ $_ } ++, grep $_, split ' ', <>;

print 0 + keys %h

#!/usr/bin/perl

use warnings;
use strict;

$\ = $/;

while(<>){

	my %h;

	map $h{ $_ } ++, grep $_ > 0, split ' ', <>;

	print 0 + keys %h;
	}


#!/usr/bin/perl

use strict;
use warnings;

=pot
1 George and Martha Washington
2 John and Abigail Adams
3 Thomas Jefferson
4 James and Dolley Madison
5 James and Elizabeth Monroe
6 John Quincy and Louisa Adams
7 Andrew and Rachel Jackson
8 Martin and Hannah Van Buren
9 William and Anna Harrison
10 John Tyler
11 James and Sarah Polk
12 Zachary and Margaret Taylor
13 Millard and Abigail Fillmore
14 Franklin and Jane Pierce
15 James Buchanan
16 Abraham and Mary Lincoln
17 Andrew and Eliza Johnson
18 Ulysses and Julia Grant
19 Rutherford and Lucy Hayes
20 James and Lucretia Garfield
21 Chester and Ellen Arthur
22 Grover Cleveland and Maria Halpin
23 Benjamin Harrison
24 Grover and Frances Cleveland
25 William and Ida McKinley
26 Theodore Roosevelt
27 William and Helen Taft
28 Woodrow and Ellen Wilson
29 Warren G. Harding
30 Calvin and Grace Coolidge
31 Herbert and Lou Hoover
32 Franklin and Eleanor Roosevelt
33 Harry and Bess Truman
34 Dwight and Mamie Eisenhower
35 John and Jackie Kennedy
36 Lyndon and Lady Bird Johnson
37 Richard and Pat Nixon
38 Gerald and Betty Ford
39 Jimmy and Rosalynn Carter
40 Ronald Reagan
=cut

my @a = (
    'Washington',
    'Adams',
    'Jefferson',
    'Madison',
    'Monroe',
    'Adams',
    'Jackson',
    'Van Buren',
    'Harrison',
    'Tyler',
    'Polk',
    'Taylor',
    'Fillmore',
    'Pierce',
    'Buchanan',
    'Lincoln',
    'Johnson',
    'Grant',
    'Hayes',
    'Garfield',
    'Arthur',
    'Cleveland',
    'Harrison',
    'Cleveland',
    'McKinley',
    'Roosevelt',
    'Taft',
    'Wilson',
    'Harding',
    'Coolidge',
    'Hoover',
    'Roosevelt',
    'Truman',
    'Eisenhower',
    'Kennedy',
    'Johnson',
    'Nixon',
    'Ford',
    'Carter',
    'Reagan',
);

chomp($_ = <>);
print $a[$_ - 1];

@_=split/,/,'"Washington", "Adams", "Jefferson", "Madison", "Monroe", "Adams", "Jackson", "Van Buren", "Harrison", "Tyler", "Polk", "Taylor", "Fillmore", "Pierce", "Buchanan", "Lincoln", "Johnson", "Grant", "Hayes", "Garfield", "Arthur", "Cleveland", "Harrison", "Cleveland", "McKinley", "Roosevelt", "Taft", "Wilson", "Harding", "Coolidge", "Hoover", "Roosevelt", "Truman", "Eisenhower", "Kennedy", "Johnson", "Nixon", "Ford", "Carter", "Reagan"';
$_=$_[<>-1];
s/^\W*|\W*$//g;
print;
print "\n"

#!/usr/bin/perl

use strict;
use warnings;

=pot
1 George and Martha Washington
2 John and Abigail Adams
3 Thomas Jefferson
4 James and Dolley Madison
5 James and Elizabeth Monroe
6 John Quincy and Louisa Adams
7 Andrew and Rachel Jackson
8 Martin and Hannah Van Buren
9 William and Anna Harrison
10 John Tyler
11 James and Sarah Polk
12 Zachary and Margaret Taylor
13 Millard and Abigail Fillmore
14 Franklin and Jane Pierce
15 James Buchanan
16 Abraham and Mary Lincoln
17 Andrew and Eliza Johnson
18 Ulysses and Julia Grant
19 Rutherford and Lucy Hayes
20 James and Lucretia Garfield
21 Chester and Ellen Arthur
22 Grover Cleveland and Maria Halpin
23 Benjamin Harrison
24 Grover and Frances Cleveland
25 William and Ida McKinley
26 Theodore Roosevelt
27 William and Helen Taft
28 Woodrow and Ellen Wilson
29 Warren G. Harding
30 Calvin and Grace Coolidge
31 Herbert and Lou Hoover
32 Franklin and Eleanor Roosevelt
33 Harry and Bess Truman
34 Dwight and Mamie Eisenhower
35 John and Jackie Kennedy
36 Lyndon and Lady Bird Johnson
37 Richard and Pat Nixon
38 Gerald and Betty Ford
39 Jimmy and Rosalynn Carter
40 Ronald Reagan
=cut

my @a = (
    'Washington',
    'Adams',
    'Jefferson',
    'Madison',
    'Monroe',
    'Adams',
    'Jackson',
    'Van Buren',
    'Harrison',
    'Tyler',
    'Polk',
    'Taylor',
    'Fillmore',
    'Pierce',
    'Buchanan',
    'Lincoln',
    'Johnson',
    'Grant',
    'Hayes',
    'Garfield',
    'Arthur',
    'Halpin',
    'Harrison',
    'Cleveland',
    'McKinley',
    'Roosevelt',
    'Taft',
    'Wilson',
    'Harding',
    'Coolidge',
    'Hoover',
    'Roosevelt',
    'Truman',
    'Eisenhower',
    'Kennedy',
    'Johnson',
    'Nixon',
    'Ford',
    'Carter',
    'Reagan',
);

chomp($_ = <>);
print $a[$_ - 1];

chomp($n=<>);
@_=split/\n/,"    1.1 George Washington
    1.2 John Adams
    1.3 Thomas Jefferson
    1.4 James Madison
    1.5 James Monroe
    1.6 John Quincy Adams
    1.7 Andrew Jackson
    1.8 Martin Van Buren
    1.9 William Henry Harrison
    1.10 John Tyler
    1.11 James K. Polk
    1.12 Zachary Taylor
    1.13 Millard Fillmore
    1.14 Franklin Pierce
    1.15 James Buchanan
    1.16 Abraham Lincoln
    1.17 Andrew Johnson
    1.18 Ulysses S. Grant
    1.19 Rutherford B. Hayes
    1.20 James A. Garfield
    1.21 Chester A. Arthur
    1.22 Grover Cleveland
    1.23 Benjamin Harrison
    1.24 William McKinley
    1.25 Theodore Roosevelt
    1.26 William Howard Taft
    1.27 Woodrow Wilson
    1.28 Warren G. Harding
    1.29 Calvin Coolidge
    1.30 Herbert Hoover
    1.31 Franklin D. Roosevelt
    1.32 Harry S. Truman
    1.33 Dwight D. Eisenhower
    1.34 John F. Kennedy
    1.35 Lyndon B. Johnson
    1.36 Richard Nixon
    1.37 Gerald Ford
    1.38 Jimmy Carter
    1.39 Ronald Reagan
    1.40 George H. W. Bush
    1.41 Bill Clinton
    1.42 George W. Bush
    1.43 Barack Obama";
for (@_){
if (/$n/){
    s/\s*1\.\d+\s\w+\s//;
    s/.*\.\s//;
    print;
    print "\n";
    last
    }
}

@_=split/,/,'"Washington", "Adams", "Jefferson", "Madison", "Monroe", "Adams", "Jackson", "Van Buren", "Harrison", "Tyler", "Polk", "Taylor", "Fillmore", "Pierce", "Buchanan", "Lincoln", "Johnson", "Grant", "Hayes", "Garfield", "Arthur", "Cleveland", "Harrison", "Cleveland", "McKinley", "Roosevelt", "Taft", "Wilson", "Harding", "Coolidge", "Hoover", "Roosevelt", "Truman", "Eisenhower", "Kennedy", "Johnson", "Nixon", "Ford", "Carter", "Reagan"';
$_=$_[<>-1];
s/\W//g;
print;
print "\n"

$n=<>;
@_=split/\n/,"    1.1 George Washington
    1.2 John Adams
    1.3 Thomas Jefferson
    1.4 James Madison
    1.5 James Monroe
    1.6 John Quincy Adams
    1.7 Andrew Jackson
    1.8 Martin Van Buren
    1.9 William Henry Harrison
    1.10 John Tyler
    1.11 James K. Polk
    1.12 Zachary Taylor
    1.13 Millard Fillmore
    1.14 Franklin Pierce
    1.15 James Buchanan
    1.16 Abraham Lincoln
    1.17 Andrew Johnson
    1.18 Ulysses S. Grant
    1.19 Rutherford B. Hayes
    1.20 James A. Garfield
    1.21 Chester A. Arthur
    1.22 Grover Cleveland
    1.23 Benjamin Harrison
    1.24 William McKinley
    1.25 Theodore Roosevelt
    1.26 William Howard Taft
    1.27 Woodrow Wilson
    1.28 Warren G. Harding
    1.29 Calvin Coolidge
    1.30 Herbert Hoover
    1.31 Franklin D. Roosevelt
    1.32 Harry S. Truman
    1.33 Dwight D. Eisenhower
    1.34 John F. Kennedy
    1.35 Lyndon B. Johnson
    1.36 Richard Nixon
    1.37 Gerald Ford
    1.38 Jimmy Carter
    1.39 Ronald Reagan
    1.40 George H. W. Bush
    1.41 Bill Clinton
    1.42 George W. Bush
    1.43 Barack Obama";
for (@_){
if (/$n/){
    s/\s*1\.\d+\s\w+\s//;
    s/.*\.\s//;
    print;
    print "\n";
    last
    }
}

$n=<>;
@_=split/\n/,"    1.1 George Washington
    1.2 John Adams
    1.3 Thomas Jefferson
    1.4 James Madison
    1.5 James Monroe
    1.6 John Quincy Adams
    1.7 Andrew Jackson
    1.8 Martin Van Buren
    1.9 William Henry Harrison
    1.10 John Tyler
    1.11 James K. Polk
    1.12 Zachary Taylor
    1.13 Millard Fillmore
    1.14 Franklin Pierce
    1.15 James Buchanan
    1.16 Abraham Lincoln
    1.17 Andrew Johnson
    1.18 Ulysses S. Grant
    1.19 Rutherford B. Hayes
    1.20 James A. Garfield
    1.21 Chester A. Arthur
    1.22 Grover Cleveland
    1.23 Benjamin Harrison
    1.24 William McKinley
    1.25 Theodore Roosevelt
    1.26 William Howard Taft
    1.27 Woodrow Wilson
    1.28 Warren G. Harding
    1.29 Calvin Coolidge
    1.30 Herbert Hoover
    1.31 Franklin D. Roosevelt
    1.32 Harry S. Truman
    1.33 Dwight D. Eisenhower
    1.34 John F. Kennedy
    1.35 Lyndon B. Johnson
    1.36 Richard Nixon
    1.37 Gerald Ford
    1.38 Jimmy Carter
    1.39 Ronald Reagan
    1.40 George H. W. Bush
    1.41 Bill Clinton
    1.42 George W. Bush
    1.43 Barack Obama";
for (@_){
chomp;
if (/$n/){
    s/\s*1\.\d+\s\w+\s//;
    s/.*\.\s//;
    print;
    print "\n";
    last
    }
}


#!/usr/bin/perl -wl

use strict;

while( <> ){
    my( $n, $k ) = split;
    my( $min ) = sort { $a <=> $b } $n - $k, $k - 1;

    print $n + $n - 1 + $min + 1 + $n;
    }

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

while (<>) {
    my ($n, $k) = split;
    my ($step) = sort {$a <=> $b} ($n - $k, $k - 1);
    $step += $n - 1;
    print $step + 2 * $n + 1;
}


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

chomp($len = <>);
chomp($line = <>);
@a = split //, $line;
$i = 0;
$ans = 0;
while ($i < $len) {
	$j = $i++;
	while ($i<$len && $a[$i] eq $a[$j]) {
		++$i;
	}
	$ans += $i-$j-1;
}
say $ans;

use strict;
use warnings;

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

my $in = <>;
chomp($in);
my @s = split('', $in);

my $n=0;

# r b g
# if ff or bb or gg we have to remove one stone
# if this stone==next stone, remove this stone. move to next....

for (my $i=0; $i<$stones-1; $i++) {
    if ($s[$i] eq $s[$i+1]) {
        $n++;
    }
}

print $n;

use strict;
use warnings;

<>;
$_ = <>;
chomp;
my @l = split '';
my $res = 0;
for my $i (1..@l-1) {
    $res++ if ($l[$i] eq $l[$i-1]);
}
print "$res\n";

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

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

my @chrs = split("", $s);
my $i = 0;
my $cnt = 0;
while ($i < ($n - 1)) {
    if ($chrs[$i] eq $chrs[$i + 1]) {
        # <STDIN>;
        splice(@chrs, $i, 1);
        $cnt += 1;
        $n -= 1;
    } else {
        $i += 1;
    }
}
print $cnt;
# print $n;
# print $s;

<STDIN>;
@str = split(//, <STDIN>);
$count = 0;

for($i = 0; $i < $#str; $i++)
{
    if($str[$i] eq $str[$i + 1])
    {
        ++$count;
    }
}
print STDOUT $count;

<stdin>; chomp($_ = <stdin>); my ($last, $res)=("", 0); for(split("")){ if( $last eq $_ ){ $res += 1 }else{ $last = $_ } } print "$res\n"

#!/bin/perl

$n = <STDIN>;
$s = <STDIN>;
chomp $s;

$s =~ s/R+/c/g;
$s =~ s/G+/c/g;
$s =~ s/B+/c/g;

print ( $n - length $s );

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

my $n = <STDIN>; $_ = <STDIN>;
foreach my $c (qw[R G B]) { s/$c+/$c/g }
print $n + 1 - length . "\n";

#!/usr/bin/perl

use strict;
use warnings;

<>;
chomp($_ = <>);
my @a = split //;
my $res = 0;
my $pre = shift @a;
while (@a) {
    my $cur = shift @a;
    ++$res if $pre eq $cur;
    $pre = $cur;
}
print "$res\n";

#!/bin/perl

$n = <STDIN>;
$s = <STDIN>;
chomp $s;

$b = $s;

$s =~ s/R+/c/;
$s =~ s/G+/c/;
$s =~ s/B+/c/;

print ( ( length $b ) - ( length $s ) );


#!/usr/bin/perl

$PI=3.14159265358979323846;
$MOD=1000000007;

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

<>;
@_=split/ /,<>;
chomp (@_);
@_= sort num_rev @_;
$first = shift @_;
$last = pop @_;
@_= reverse @_;
unshift @_, $first;
push @_, $last;
print "@_";

#***********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

$PI=3.14159265358979323846;
$MOD=1000000007;

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

<>;
@_=split/ /,<>;
chomp (@_);
@_= sort num_rev @_;
$first = shift @_;
$last = pop @_;
@_= sort @_;
unshift @_, $first;
push @_, $last;
print "@_\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

$PI=3.14159265358979323846;
$MOD=1000000007;

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

<>;
@_=split/ /,<>;
@_= sort num_rev @_;
$first = shift @_;
$last = pop @_;
@_= sort @_;
unshift @_, $first;
push @_, $last;
print "@_";

#***********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

$PI=3.14159265358979323846;
$MOD=1000000007;

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

<>;
@_=split/ /,<>;
@_= sort num_rev @_;
$first = shift @_;
$last = pop @_;
@_= sort @_;
print $first, " @_ ", $last;

#***********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

$PI=3.14159265358979323846;
$MOD=1000000007;

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

<>;
@_=split/ /,<>;
chomp (@_);
@_= sort num_rev @_;
$first = shift @_;
$last = pop @_;
@_= sort @_;
unshift @_, $first;
push @_, $last;
print "@_";

#***********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;

$\ = $/;

my $debug = 0;

while(!eof){
	$_ = join '', map ~~<>, 1 .. 4;
	y/./,/;

	my @rxs;

	for my $join ( map { '.' x $_ } 0, 3, 4, 5 ){
		for my $arrange ( 'xx,xx' =~ /(?=(...))/g ){
			push @rxs, join $join, split '', $arrange;
			}
		}

	my $re = join '|', @rxs;

	$debug and print $re;

	print /$re/gs ? "YES" : "NO";

	$debug and print "pos:", pos, "[$&]";
	}

#!/usr/bin/perl

use warnings;
use strict;

$\ = $/;

my $debug = 0;

while(!eof){
	$_ = join '', split ' ', join '', map ~~<>, 1 .. 4;
	y/./,/;

	my @rxs;

	for my $join ( map { '[^o]' x $_ } 0, 2, 3, 4 ){
		for my $arrange ( 'xx,xx' =~ /(?=(...))/g ){
			push @rxs, join $join, split '', $arrange;
			}
		}

	$debug and print "/xx,|x,x|,xx|x...x...,|x...,...x|,...x...x|x....x....,|x....,....x|,....x....x|/";

	my $re = join '|', @rxs;

	$debug and print $re;

	print /$re/ ? "YES" : "NO";

	}