#!/usr/bin/perl -w

# Counts the paragraphs in its input

my $para_count = 0;

while (<>) {
	$_ = trim($_);
	if ($_) {
		$para_count++;

		my $the_rest;
		do {
			$the_rest = <>;
			goto DONE if not defined($the_rest);
			$the_rest = trim($the_rest);
		} while ($the_rest);
	}
}
printf "%d  \n", $para_count;
exit 0;


sub trim {
	my $in = shift;
	$in =~ s/^\s*(\S*)\s*$/$1/s;
	return $in;
}
