import gzip
import sys

def count_features(filename):
    helix = 0
    transmem = 0
    both = 0
    
    with gzip.open(filename, 'rt', encoding='utf-8') as f:
        has_helix = False
        has_transmem = False
        
        for line in f:
            if line.startswith('FT   HELIX'):
                has_helix = True
            elif line.startswith('FT   TRANSMEM'):
                has_transmem = True
            elif line.startswith('//'):
                if has_helix:
                    helix += 1
                if has_transmem:
                    transmem += 1
                if has_helix and has_transmem:
                    both += 1
                has_helix = False
                has_transmem = False
    
    return helix, transmem, both

def main():
    if len(sys.argv) != 2:
        print("Использование: python count.py UP000264006.swiss.gz")
        sys.exit(1)
    
    filename = sys.argv[1]
    helix, transmem, both = count_features(filename)
    
    print(f"HELIX: {helix}")
    print(f"TRANSMEM: {transmem}")
    print(f"BOTH: {both}")

if __name__ == "__main__":
    main()