#include <bits/stdc++.h>
using namespace std;
int a, b;
int ToInt(char a, char b) { return (a - '0') * 10 + (b - '0'); }
void Enter() {
  char a1, a2, dummy, b1, b2;
  cin >> a1 >> a2 >> dummy >> b1 >> b2;
  a = ToInt(a1, a2);
  b = ToInt(b1, b2);
}
inline int Duration(int a, int b, int c, int d) { return (c - a) * 60 + d - b; }
int Solve() {
  for (int c = 0; c < 24; ++c) {
    int d = c % 10 * 10 + c / 10;
    if (d > 59) continue;
    if (c > a || (c == a && d >= b)) return Duration(a, b, c, d);
  }
  return Duration(a, b, 24, 0);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  Enter();
  cout << Solve();
}
