#!/usr/bin/perl use strict; use warnings; my $s = q~1\A\563\M\1\Y\Y\Y\A\N\N\N\N\(A)[N]\N\N\N\N\S3/P2\N~; my $anz = $s =~ tr/\\//; print $anz;