#!/usr/bin/perl -w

use strict;

my $max = 0;
while (<>) {
	chomp;
	y/FBRL/0110/;
	my $seat =  eval "0b$_";
	$max = $seat if $max < $seat;
}

print $max, "\n";
