How to get the count of filtered sets?

{
   set {
     _:user <messages> _:msg (read = false) .
   }
}

how can I get the count of user’s unread messages ?

{
  data(func: eq(name, "A")) {
    unread : count(messages @facets(eq(read, false))) 
  }
}

See https://dgraph.io/docs/query-language/facets/#filtering-on-facets

should I add @count directive to the messages too ?

Not necessarily. This directive is only for when you want to index values for query at root.