K2 uses Joomla! pagination, so you need to change this function in Joomla! core files (or better - use overrides).
Changing core file:
1. Find 'your_site_root/libraries/joomla/html/pagination.php'.
2. Find:
// Set the pagination iteration loop values.
$displayedPages = 10;'
3. Change it to (for 5 pages):
// Set the pagination iteration loop values.
$displayedPages = 5;'
Done.
To use overrides you must copy file to your template folder ( 'your_site_root/templates/YOUR_TEMPLATE/html/' - but if your template uses this file (some templates do), better change your core file.