#include <bits/stdc++.h>
using namespace std;
int c[505];
long long f[505][505];
const long long mo = 998244353;
long long dfs(int l, int r) {
  if (r <= l) return 1;
  if (~f[l][r]) return f[l][r];
  int p = l;
  for (int k = l; k <= r; k++)
    if (c[k] < c[p]) p = k;
  long long lsum = 0, rsum = 0;
  for (int k = l; k <= p; k++) {
    long long cur = 1;
    cur *= (dfs(l, k - 1) * dfs(k, p - 1)) % mo;
    cur %= mo;
    lsum += cur;
  }
  for (int k = p; k <= r; k++) {
    long long cur = 1;
    cur *= (dfs(p + 1, k) * dfs(k + 1, r)) % mo;
    cur %= mo;
    rsum += cur;
  }
  lsum %= mo;
  rsum %= mo;
  return f[l][r] = (lsum * rsum) % mo;
}
int main() {
  memset(f, -1, sizeof(f));
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
  cout << dfs(1, n) << endl;
  return 0;
}
