#include <bits/stdc++.h>
int main() {
  int i, j, k;
  long int N;
  int s[12];
  int n3, n5, n7;
  long int num, tmp;
  long int ans = 0;
  long int power = 0;
  for (i = 0; i < 12; i++) {
    s[i] = 0;
  }
  scanf("%ld", &N);
  for (i = 0; i < 1000000; i++) {
    s[0] += 1;
    num = 0;
    tmp = 0;
    n3 = 0;
    n5 = 0;
    n7 = 0;
    power = 1;
    for (j = 0; j < 11; j++) {
      if (s[j] == 4) {
        s[j] = 1;
        s[j + 1] += 1;
      }
      if (s[j] == 1) {
        num += 3 * power;
        n3 += 1;
      } else if (s[j] == 2) {
        num += 5 * power;
        n5 += 1;
      } else if (s[j] == 3) {
        num += 7 * power;
        n7 += 1;
      }
      tmp += s[j] * power;
      power = power * 10;
    }
    if (n3 * n5 * n7 > 0) {
      ans += 1;
    }
    if (num >= N) {
      break;
    }
  }
  printf("%ld %ld\n", num, tmp);
  printf("%ld", ans);
  return 0;
}
