Pass custom variable to block.html.twig
You will need to preprocess the block instead of the page. Preprocessing pages will not pass a variable to the block. See hook_preprocess_block. If you are needing to determine values based on how many times a block is rendered you can look into using drupal_static to store variables that can be reused during the rendering process. 

Drupal static example:

$first_row = &amp;drupal_static('first_row');

if ($first_row == 2) {
  // I equal 2
}

// Since I am passed by reference I can alter and will keep my value.
$first_row++;