#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
bool vis[505][N];
int d, s;
struct Node {
  int x, y;
  vector<int> co;
};
queue<Node> q;
bool BFS() {
  Node t;
  memset(vis, 0, sizeof(vis));
  vis[0][0] = 1;
  t.x = t.y = 0;
  t.co.clear();
  q.push(t);
  while (!q.empty()) {
    t = q.front();
    q.pop();
    for (int i = 0; i <= 9; i++) {
      int xx = (t.x * 10 + i) % d, yy = t.y + i;
      if (vis[xx][yy] || yy > s) continue;
      vis[xx][yy] = true;
      Node p;
      p = t;
      p.x = xx, p.y = yy, p.co.push_back(i);
      if (xx == 0 && yy == s) {
        for (int j = 0; j < p.co.size(); j++) printf("%d", p.co[j]);
        putchar('\n');
        return true;
      }
      q.push(p);
    }
  }
  return false;
}
int main() {
  scanf("%d%d", &d, &s);
  if (BFS() == 0) printf("-1\n");
}
