Addition of numbers in unix

Hi
I have a file with specified format .
Hxxxxxxxyyyyyggggggguuuuuuuuuurrrrrrrrrrrrrrrrrrrrrrrr
xxxxxxxxyyyyyggggggguuuuuuuuuurrrrrrrrrrrrrrrrrrrrrrrr
xxxxxxxxyyyyyggggggguuuuuuuuuurrrrrrrrrrrrrrrrrrrrrrrr
xxxxxxxxyyyyyggggggguuuuuuuuuurrrrrrrrrrrrrrrrrrrrrrrr
xxxxxxxxyyyyyggggggguuuuuuuuuurrrrrrrrrrrrrrrrrrrrrrrr
xxxxxxxxyyyyyggggggguuuuuuuuuurrrrrrrrrrrrrrrrrrrrrrrr
Yxxxxxxxyyyyyggggggguuuuuuuuuurrrrrrrrrrrrrrrrrrrrrrrr
I have to add all yyyyy (location 9,13)in all the lines and get the sum.But not the lines starting with H n Y .
Pls tell me how to do this in awk
Anubha

look into awk's "substr" function.

i donno awk
can u pls tell me the command

/^[^YH]/ { sum += substr($0, 9, 4) }
END { printf("sum->[%d]\n", sum) }