<?php
$letters = array( array("a", "b", "c", "d", "e","1"),
array("f", "g", "h", "i", "j","2"),
array("k", "l", "m", "n", "o","3"),
array("p", "r", "q", "s", "t","4"),
array("u", "v", "w", "x", "y","5"),
array("z", "0", "9", "8", "7","6"));
$neighbour =array(-1, 0, 1);
$say=1;
for($x[1] = 0; $x[1] < count($letters); ++$x[1]) {
for($y[1] = 0; $y[1] < count($letters[$x[1]]); ++$y[1]) {
$say++;
foreach ($neighbour as $neigh){
$x[2]=$x[1]+$neigh;
if ($x[2]>-1 AND $x[2]<count($letters) ) {
foreach ($neighbour as $neigh){
$y[2]=$y[1]+$neigh;
if ($y[2]>-1 AND $y[2]<count($letters[$x[2]])) {
if ($x[2] != $x[1] OR $y[2] != $y[1]){
$say++;
foreach ($neighbour as $neigh){
$x[3]=$x[2]+$neigh;
if ($x[3]>-1 AND $x[3]<count($letters) ) {
foreach ($neighbour as $neigh){
$y[3]=$y[2]+$neigh;
if ($y[3]>-1 AND $y[3]<count($letters[$x[3]])) {
if ($x[3] != $x[1] OR $y[3] != $y[1]){
if ($x[3] != $x[2] OR $y[3] != $y[2]){
$say++;
foreach ($neighbour as $neigh){
$x[4]=$x[3]+$neigh;
if ($x[4]>-1 AND $x[4]<count($letters) ) {
foreach ($neighbour as $neigh){
$y[4]=$y[3]+$neigh;
if ($y[4]>-1 AND $y[4]<count($letters[$x[4]])) {
if ($x[4] != $x[1] OR $y[4] != $y[1]){
if ($x[4] != $x[2] OR $y[4] != $y[2]){
if ($x[4] != $x[3] OR $y[4] != $y[3]){
$say++;
foreach ($neighbour as $neigh){
$x[5]=$x[4]+$neigh;
if ($x[5]>-1 AND $x[5]<count($letters) ) {
foreach ($neighbour as $neigh){
$y[5]=$y[4]+$neigh;
if ($y[5]>-1 AND $y[5]<count($letters[$x[5]])) {
if ($x[5] != $x[1] OR $y[5] != $y[1]){
if ($x[5] != $x[2] OR $y[5] != $y[2]){
if ($x[5] != $x[3] OR $y[5] != $y[3]){
if ($x[5] != $x[4] OR $y[5] != $y[4]){
$say++;
foreach ($neighbour as $neigh){
$x[6]=$x[5]+$neigh;
if ($x[6]>-1 AND $x[6]<count($letters) ) {
foreach ($neighbour as $neigh){
$y[6]=$y[5]+$neigh;
if ($y[6]>-1 AND $y[6]<count($letters[$x[6]])) {
if ($x[6] != $x[1] OR $y[6] != $y[1]){
if ($x[6] != $x[2] OR $y[6] != $y[2]){
if ($x[6] != $x[3] OR $y[6] != $y[3]){
if ($x[6] != $x[4] OR $y[6] != $y[4]){
if ($x[6] != $x[5] OR $y[6] != $y[5]){
$say++;
foreach ($neighbour as $neigh){
$x[7]=$x[6]+$neigh;
if ($x[7]>-1 AND $x[7]<count($letters) ) {
foreach ($neighbour as $neigh){
$y[7]=$y[6]+$neigh;
if ($y[7]>-1 AND $y[7]<count($letters[$x[7]])) {
if ($x[7] != $x[1] OR $y[7] != $y[1]){
if ($x[7] != $x[2] OR $y[7] != $y[2]){
if ($x[7] != $x[3] OR $y[7] != $y[3]){
if ($x[7] != $x[4] OR $y[7] != $y[4]){
if ($x[7] != $x[5] OR $y[7] != $y[5]){
if ($x[7] != $x[6] OR $y[7] != $y[6]){
$say++;
}}}}}}}}}}
}}}}}}}}}
}}}}}}}}
}}}}}}}
}}}}}}
}}}}}
}}
echo $say;
?>