<?php
  fscanf(STDIN, "%s", $S);
  fscanf(STDIN, "%s", $T);
  if($S == "SSS"){
    $aS = "S";
    $bS = "S";
    $cS = "S";
  }else if($S == "SSC"){
    $aS = "S";
    $bS = "S";
    $cS = "C";
  }else if($S == "SSR"){
    $aS = "S";
    $bS = "S";
    $cS = "R";
  }else if($S == "SCS"){
    $aS = "S";
    $bS = "C";
    $cS = "S";
  }else if($S == "SRS"){
    $aS = "S";
    $bS = "R";
    $cS = "S";
  }else if($S == "CSS"){
    $aS = "C";
    $bS = "S";
    $cS = "S";
  }else if($S == "RSS"){
    $aS = "R";
    $bS = "S";
    $cS = "S";
  }else if($S == "SCC"){
    $aS = "S";
    $bS = "C";
    $cS = "C";
  }else if($S == "SCR"){
    $aS = "S";
    $bS = "C";
    $cS = "R";
  }else if($S == "SRC"){
    $aS = "S";
    $bS = "R";
    $cS = "C";
  }else if($S == "SRR"){
    $aS = "S";
    $bS = "R";
    $cS = "R";
  }else if($S == "CSC"){
    $aS = "C";
    $bS = "S";
    $cS = "C";
  }else if($S == "CSR"){
    $aS = "C";
    $bS = "S";
    $cS = "R";
  }else if($S == "RSC"){
    $aS = "R";
    $bS = "S";
    $cS = "C";
  }else if($S == "RSR"){
    $aS = "R";
    $bS = "S";
    $cS = "R";
  }else if($S == "CCS"){
    $aS = "C";
    $bS = "C";
    $cS = "S";
  }else if($S == "CRS"){
    $aS = "C";
    $bS = "R";
    $cS = "S";
  }else if($S == "RCS"){
    $aS = "R";
    $bS = "C";
    $cS = "S";
  }else if($S == "RRS"){
    $aS = "R";
    $bS = "R";
    $cS = "S";
  }else if($S == "CCC"){
    $aS = "C";
    $bS = "C";
    $cS = "C";
  }else if($S == "CCR"){
    $aS = "C";
    $bS = "C";
    $cS = "R";
  }else if($S == "CRC"){
    $aS = "C";
    $bS = "R";
    $cS = "C";
  }else if($S == "RCC"){
    $aS = "R";
    $bS = "C";
    $cS = "C";
  }else if($S == "CRR"){
    $aS = "C";
    $bS = "R";
    $cS = "R";
  }else if($S == "RCR"){
    $aS = "R";
    $bS = "C";
    $cS = "R";
  }else if($S == "RRC"){
    $aS = "R";
    $bS = "R";
    $cS = "C";
  }else if($S == "RRR"){
    $aS = "R";
    $bS = "R";
    $cS = "R";
  }
  if($T == "SSS"){
    $aT = "S";
    $bT = "S";
    $cT = "S";
  }else if($T == "SSC"){
    $aT = "S";
    $bT = "S";
    $cT = "C";
  }else if($T == "SSR"){
    $aT = "S";
    $bT = "S";
    $cT = "R";
  }else if($T == "SCS"){
    $aT = "S";
    $bT = "C";
    $cT = "S";
  }else if($T == "SRS"){
    $aT = "S";
    $bT = "R";
    $cT = "S";
  }else if($T == "CSS"){
    $aT = "C";
    $bT = "S";
    $cT = "S";
  }else if($T == "RSS"){
    $aT = "R";
    $bT = "S";
    $cT = "S";
  }else if($T == "SCC"){
    $aT = "S";
    $bT = "C";
    $cT = "C";
  }else if($T == "SCR"){
    $aT = "S";
    $bT = "C";
    $cT = "R";
  }else if($T == "SRC"){
    $aT = "S";
    $bT = "R";
    $cT = "C";
  }else if($T == "SRR"){
    $aT = "S";
    $bT = "R";
    $cT = "R";
  }else if($T == "CSC"){
    $aT = "C";
    $bT = "S";
    $cT = "C";
  }else if($T == "CSR"){
    $aT = "C";
    $bT = "S";
    $cT = "R";
  }else if($T == "RSC"){
    $aT = "R";
    $bT = "S";
    $cT = "C";
  }else if($T == "RSR"){
    $aT = "R";
    $bT = "S";
    $cT = "R";
  }else if($T == "CCS"){
    $aT = "C";
    $bT = "C";
    $cT = "S";
  }else if($T == "CRS"){
    $aT = "C";
    $bT = "R";
    $cT = "S";
  }else if($T == "RCS"){
    $aT = "R";
    $bT = "C";
    $cT = "S";
  }else if($T == "RRS"){
    $aT = "R";
    $bT = "R";
    $cT = "S";
  }else if($T == "CCC"){
    $aT = "C";
    $bT = "C";
    $cT = "C";
  }else if($T == "CCR"){
    $aT = "C";
    $bT = "C";
    $cT = "R";
  }else if($T == "CRC"){
    $aT = "C";
    $bT = "R";
    $cT = "C";
  }else if($T == "RCC"){
    $aT = "R";
    $bT = "C";
    $cT = "C";
  }else if($T == "CRR"){
    $aT = "C";
    $bT = "R";
    $cT = "R";
  }else if($T == "RCR"){
    $aT = "R";
    $bT = "C";
    $cT = "R";
  }else if($T == "RRC"){
    $aT = "R";
    $bT = "R";
    $cT = "C";
  }else if($T == "RRR"){
    $aT = "R";
    $bT = "R";
    $cT = "R";
  }
  $ans = 0;
  if($aS == $aT){
    $ans ++;
  }
  if($bS == $bT){
    $ans ++;
  }
  if($cS == $cT){
    $ans ++;
  }
  echo "$ans\n";
?>

Measured memory_bytes: 3700