//Codeforcesで128bit整数を使いたいとき
//→__int128_tを使う&GNU C++17 (64)で提出する
 
//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
//イテレーション
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//x:コンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF32 2147483647 //2.147483647×10^{9}:32bit整数のinf
#define INF64 9223372036854775807 //9.223372036854775807×10^{18}:64bit整数のinf
#define MOD 1000000007 //問題による
//略記
#define F first
#define S second
//出力(空白区切りで昇順に)
#define coutALL(x) for(auto i=x.begin();i!=--x.end();i++)cout<<*i<<" ";cout<<*--x.end()<<endl;
 
//aをbで割る時の繰上げ,繰り下げ
ll myceil(ll a,ll b){return (a+(b-1))/b;}
ll myfloor(ll a,ll b){return a/b;}
 
int ri() {int n;cin >> n;return n;}
#define ro(a) {cout << a << endl;}
 
void printVector(const std::vector<int>& vec) {
	for (int value : vec) {
		cout << value << " ";
	}
	cout << endl;
}
 
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	} else {
		return a.first < b.first;
	}
}

ll factorial(ll N) {
	ll f = 1;
	REP(i, N) {
		f *= i+1;
	}
	return f;
}
 
signed main() {
	float A = ri(), B = ri(), C = ri(), D = ri();
	if (C * D - B <= 0) {
		ro(-1);
		return 0;
	}
	float tmp = A / (C * D - B);
	ro(ceil(tmp));
}
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
//#include <atcoder/all>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

const ll mod = 998244353;

vector<int> par, rnk;
void init(int N){ par.resize(N); rnk.assign(N,0); rep(i,N) {par[i] = i;} }
int root(int x) { return par[x] == x? x : par[x] = root(par[x]); }
bool same(int x, int y) { return root(x) == root(y); }
void unite(int x, int y){
  x = root(x); y = root(y);
  if(x==y) return;
  if(rnk[x] < rnk[y]) par[x] = y;
  else{
    par[y] = x;
    if(rnk[x] == rnk[y]) rnk[x]++;
  }
}

ll mpow(ll a, ll x){
  ll res = 1;
  while(x > 0){
    if(x & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    x >>= 1;
  }
  return res;
}

int main(){
  ll N; cin >> N;
  vector<ll> f(N); rep(i,N) cin >> f[i];
  rep(i,N) f[i]--;
  init(N);
  ll cnt = 0;
  rep(i,N){
    unite(i,f[i]);
  }
  set<int> st;
  rep(i,N) st.insert(root(i));
  cnt=sz(st);
  cout << (mpow(2,cnt)+mod-1)%mod << endl;
  return 0;
}
