$nick(#channel,0) returns the total users on #channel, so when a user joins #channel it will /mode #channel +l (total number of users + 2)

$calc does the adding part, type //echo -a $calc(2 + 2), it will return 4, u can do addition,subtraction,multiplication etc.. with $calc