#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from copy import deepcopy

def is_increasing(l:list[str]) -> bool:
    for i in range(1,len(l)):
        pre, n  = int(l[i-1]), int(l[i])
        if pre >= n or n-pre > 3:
            return False
    return True

def is_decreasing(l:list[str]) -> bool:
    for i in range(1, len(l)):
        pre, n  = int(l[i - 1]), int(l[i])
        if pre <= n or pre-n > 3:
            return False
    return True


def check_line(lin:str) -> bool:
    l = lin.split()
    for i in range(len(l)):
        l2 = deepcopy(l)
        l2.pop(i)
        if is_increasing(l2) or is_decreasing(l2):
            return True
    return False


if __name__ == "__main__":
    safe = 0
    input_file = open("input.txt", "r")
    for line in input_file:
        if check_line(line):
            safe += 1
    input_file.close()
    print(f'Safe:{safe}')