The NAND Gate is obtained by combining AND gate and NOT gate. The output Y of AND gate is inverted by the NOT gate to get the final output Y.

A |
B |
Y' |
Y |

0 | 0 | 0 | 1 |

0 | 1 | 0 | 1 |

1 | 0 | 0 | 1 |

1 | 1 | 1 | 0 |

The truth table of a NAND gate shows that it gives output 1 when at least one of the inputs is 0.