#!/bin/bash

slots_total=0

for i in /apps/??*/VERSION ; do
	grep "${1}" ${i} > /dev/null
	if [ ${?} -eq 1 ]; then
		res=`expr match "$(cat ${i})" ".*SLOTS=\([0-9]*\)"`
		let slots_total=${slots_total}+${res}
	fi
done

echo ${slots_total}
