type TDigitCounter = array[0..9] of Integer; procedure InitCounter(var a: TDigitCounter); begin FillChar(a, SizeOf(a), #0); end; function CountDigits(n: Integer): TDigitCounter; var r: TDigitCounter; begin InitCounter(r); while n>0 do begin inc(r[n mod 10]); n:=n div 10; end; CountDigits:=r; end; function DigitCountsEqual(dc1, dc2: TDigitCounter): Boolean; var r: Boolean; i: Integer; begin r:=True; for i:=0 to 9 do r:=r and (dc1=dc2); DigitCountsEqual:=r; end; var n1, n2: Integer; begin Readln(n1); Readln(n2); Writeln(DigitCountsEqual(CountDigits(n1), CountDigits(n2))); Readln; end.