import 'dart:async';
import 'dart:io';
import 'dart:convert';

Stream<String> get lineStream =>
    stdin.transform(utf8.decoder).transform(const LineSplitter());

Future<List<String>> readLines() async {
  final lines = <String>[];
  await for (var line in lineStream) {
    lines.add(line);
  }
  return lines;
}

void main() async {
  final lines = await readLines();
  final k = int.parse(lines[0]);
  if (k % 2 == 0 && k % 5 == 0) {
    print('-1');
    return;
  }
  var i = 1;
  var x = 7 % k;
  var s = <int>{};
  while (!s.contains(x)) {
    if (x == 0) {
      print('$i');
      return;
    }
    s.add(x);
    x = (x * 10 + 7) % k;
    i++;
  }
  print('-1');
}